Skip to content

Commit c8f805a

Browse files
committed
Touch scroll and mouse wheel scroll speed config parameters.
1 parent b6a46aa commit c8f805a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.textile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ There are some options you can pass when initializing scrollbar:
8383
| <code>animationSpeed</code> | <code>Integer</code> | <code>300</code> | Speed of the animation of programmatic scrolling. It's possible to edit it with <code>setAnimationSpeed</code> method. Animation speed equal to <code>0</code> means no animation.|
8484
| <code>hScroll</code> | <code>Boolean</code> | <code>true</code> | Indicates whether or not, horizontal scrollbar should be shown when it's necessary. |
8585
| <code>skin</code>|<code>String</code>|<code>undefined</code>|A css skin class that will be added to the scrolled container. You can define it in html as well as here in options. Note that skin has to be defined in one of those ways.|
86+
| <code>swipeSpeed</code>|<code>Integer</code>|<code>1</code>|Indicates how fast touch scroll should be. When you swipe your finger by <code>x</code> pixels the content will be scrolled by <code>swipeSpeed * x</code> pixels.|
8687
| <code>updateOnWindowResize</code> | <code>Boolean</code> | <code>false</code> | Indicates whether scrollbar should recalculate thumb size when window is resized. See <code>demos/resize.html</code> for an example.|
8788
| <code>vScroll</code> | <code>Boolean</code> | <code>true</code> | Same as above but applies to vertical scrollbar. |
89+
| <code>wheelSpeed</code>|<code>Integer</code>|<code>40</code>|Indicates how fast mouse wheel scroll should be. When you make the smallest possible mouse wheel move, the content will be scrolled by <code>wheelSpeed</code> pixels.|
8890

8991
For example:
9092

jquery.custom-scrollbar.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
vScroll: true,
99
updateOnWindowResize: false,
1010
animationSpeed: 300,
11-
onCustomScroll: undefined
11+
onCustomScroll: undefined,
12+
swipeSpeed: 1,
13+
wheelSpeed: 40
1214
}
1315

1416
var Scrollable = function (element, options) {
@@ -361,7 +363,7 @@
361363

362364
touchScroll: function (event) {
363365
if (this.touchScrolling && event.touches && event.touches.length == 1) {
364-
var delta = -this.sizing.mouseDelta(this.scrollEvent, event.touches[0]);
366+
var delta = -this.sizing.mouseDelta(this.scrollEvent, event.touches[0]) * this.scrollable.options.swipeSpeed;
365367
this.scrollOverviewBy(delta);
366368
this.setScrollEvent(event.touches[0]);
367369
event.stopPropagation();
@@ -375,9 +377,9 @@
375377
},
376378

377379
mouseWheelScroll: function (deltaX, deltaY) {
378-
var delta = this.sizing.wheelDelta(deltaX, deltaY) * -10;
380+
var delta = -this.sizing.wheelDelta(deltaX, deltaY) * this.scrollable.options.wheelSpeed;
379381
if (delta != 0)
380-
this.scrollThumbBy(delta);
382+
this.scrollOverviewBy(delta);
381383
},
382384

383385
mouseClickScroll: function (event) {

0 commit comments

Comments
 (0)