From 7f439ca5f8113736c52065957dc3c14d739ae56a Mon Sep 17 00:00:00 2001 From: Schleuse Date: Tue, 29 May 2018 17:37:09 +0200 Subject: [PATCH] Added option swipeEasingFriction --- README.md | 12 +++--- examples/options-swipeEasingFriction.html | 48 +++++++++++++++++++++++ src/handlers/touch.js | 4 +- src/index.js | 1 + types/perfect-scrollbar.d.ts | 1 + 5 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 examples/options-swipeEasingFriction.html diff --git a/README.md b/README.md index 1a84abc..949c25f 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@

Minimalistic but perfect custom scrollbar plugin

-

+

Downloads - License - npm + License + npm YouTube Video Views

@@ -55,14 +55,14 @@ Check out the [Live Preview](https://mdbootstrap.com/snippets/standard/marveluck - [Twitter](https://twitter.com/MDBootstrap) - - [Facebook](https://www.facebook.com/mdbootstrap) + - [Facebook](https://www.facebook.com/mdbootstrap) - [Pinterest](https://pl.pinterest.com/mdbootstrap) - [Dribbble](https://dribbble.com/mdbootstrap) - [LinkedIn](https://www.linkedin.com/company/material-design-for-bootstrap) - + - [YouTube](https://www.youtube.com/channel/UC5CF7mLQZhvx8O5GODZAhdA) ## Get Free Material Design for Bootstrap 5 @@ -77,7 +77,7 @@ Check out the [Live Preview](https://mdbootstrap.com/snippets/standard/marveluck diff --git a/examples/options-swipeEasingFriction.html b/examples/options-swipeEasingFriction.html new file mode 100644 index 0000000..7569fd9 --- /dev/null +++ b/examples/options-swipeEasingFriction.html @@ -0,0 +1,48 @@ + + + + + + + + +
+
+ swipeEasingFriction: 0.2 +
+
+
+
+ swipeEasingFriction: 0.05 +
+
+ + + + diff --git a/src/handlers/touch.js b/src/handlers/touch.js index 599d238..52b7059 100644 --- a/src/handlers/touch.js +++ b/src/handlers/touch.js @@ -196,8 +196,8 @@ export default function(i) { applyTouchMove(speed.x * 30, speed.y * 30); - speed.x *= 0.8; - speed.y *= 0.8; + speed.x *= 1 - i.settings.swipeEasingFriction; + speed.y *= 1 - i.settings.swipeEasingFriction; }, 10); } } diff --git a/src/index.js b/src/index.js index 451cd64..a52f787 100644 --- a/src/index.js +++ b/src/index.js @@ -22,6 +22,7 @@ const defaultSettings = () => ({ suppressScrollX: false, suppressScrollY: false, swipeEasing: true, + swipeEasingFriction: 0.2, useBothWheelAxes: false, wheelPropagation: true, wheelSpeed: 1, diff --git a/types/perfect-scrollbar.d.ts b/types/perfect-scrollbar.d.ts index 88b6e60..dc713e3 100644 --- a/types/perfect-scrollbar.d.ts +++ b/types/perfect-scrollbar.d.ts @@ -9,6 +9,7 @@ declare namespace PerfectScrollbar { suppressScrollX?: boolean; suppressScrollY?: boolean; swipeEasing?: boolean; + swipeEasingFriction?: number; useBothWheelAxes?: boolean; wheelPropagation?: boolean; wheelSpeed?: number;