Skip to content

Commit

Permalink
horizontally scroll on trackpads (refs cubiq#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
abstraktor committed Jul 30, 2014
1 parent 44d992b commit b35dba3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
9 changes: 8 additions & 1 deletion build/iscroll-infinite.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function IScroll (el, options) {
this.options = {

mouseWheelSpeed: 20,
mouseWheelScrollsHorizontally: false,

snapThreshold: 0.334,

Expand Down Expand Up @@ -947,7 +948,13 @@ IScroll.prototype = {
wheelDeltaX *= this.options.invertWheelDirection;
wheelDeltaY *= this.options.invertWheelDirection;

if ( !this.hasVerticalScroll ) {
if ( !this.hasHorizontalScroll ) {
wheelDeltaX = 0;
} else if ( !this.hasVerticalScroll && this.options.mouseWheelScrollsHorizontally ) {
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
} if ( !this.hasVerticalScroll ) {
wheelDeltaY = 0;
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
}
Expand Down
9 changes: 8 additions & 1 deletion build/iscroll-probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function IScroll (el, options) {
resizeScrollbars: true,

mouseWheelSpeed: 20,
mouseWheelScrollsHorizontally: false,

snapThreshold: 0.334,

Expand Down Expand Up @@ -1069,7 +1070,13 @@ IScroll.prototype = {
wheelDeltaX *= this.options.invertWheelDirection;
wheelDeltaY *= this.options.invertWheelDirection;

if ( !this.hasVerticalScroll ) {
if ( !this.hasHorizontalScroll ) {
wheelDeltaX = 0;
} else if ( !this.hasVerticalScroll && this.options.mouseWheelScrollsHorizontally ) {
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
} if ( !this.hasVerticalScroll ) {
wheelDeltaY = 0;
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
}
Expand Down
9 changes: 8 additions & 1 deletion build/iscroll-zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ function IScroll (el, options) {
resizeScrollbars: true,

mouseWheelSpeed: 20,
mouseWheelScrollsHorizontally: false,

snapThreshold: 0.334,

Expand Down Expand Up @@ -1233,7 +1234,13 @@ IScroll.prototype = {
wheelDeltaX *= this.options.invertWheelDirection;
wheelDeltaY *= this.options.invertWheelDirection;

if ( !this.hasVerticalScroll ) {
if ( !this.hasHorizontalScroll ) {
wheelDeltaX = 0;
} else if ( !this.hasVerticalScroll && this.options.mouseWheelScrollsHorizontally ) {
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
} if ( !this.hasVerticalScroll ) {
wheelDeltaY = 0;
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
}
Expand Down
9 changes: 8 additions & 1 deletion build/iscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function IScroll (el, options) {
resizeScrollbars: true,

mouseWheelSpeed: 20,
mouseWheelScrollsHorizontally: false,

snapThreshold: 0.334,

Expand Down Expand Up @@ -1060,7 +1061,13 @@ IScroll.prototype = {
wheelDeltaX *= this.options.invertWheelDirection;
wheelDeltaY *= this.options.invertWheelDirection;

if ( !this.hasVerticalScroll ) {
if ( !this.hasHorizontalScroll ) {
wheelDeltaX = 0;
} else if ( !this.hasVerticalScroll && this.options.mouseWheelScrollsHorizontally ) {
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
} if ( !this.hasVerticalScroll ) {
wheelDeltaY = 0;
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wheel/build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"insert": {
"OPTIONS": "\t\tmouseWheelSpeed: 20,",
"OPTIONS": "\t\tmouseWheelSpeed: 20,\n\t\tmouseWheelScrollsHorizontally: false,",
"NORMALIZATION": "\tthis.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;",
"_init": "\t\tif ( this.options.mouseWheel ) {\n\t\t\tthis._initWheel();\n\t\t}"
}
Expand Down
8 changes: 7 additions & 1 deletion src/wheel/wheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@
wheelDeltaX *= this.options.invertWheelDirection;
wheelDeltaY *= this.options.invertWheelDirection;

if ( !this.hasVerticalScroll ) {
if ( !this.hasHorizontalScroll ) {
wheelDeltaX = 0;
} else if ( !this.hasVerticalScroll && this.options.mouseWheelScrollsHorizontally ) {
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
} if ( !this.hasVerticalScroll ) {
wheelDeltaY = 0;
wheelDeltaX = wheelDeltaY;
wheelDeltaY = 0;
}
Expand Down

0 comments on commit b35dba3

Please sign in to comment.