Skip to content

Instantly share code, notes, and snippets.

@Fresheyeball
Forked from hotmeteor/vertical-enable.iscroll.js
Last active December 25, 2015 08:19
Show Gist options
  • Save Fresheyeball/6946017 to your computer and use it in GitHub Desktop.
Save Fresheyeball/6946017 to your computer and use it in GitHub Desktop.
var point, pointStartX, pointStartY, deltaX, deltaY, isHorizontal;
var scroller = new iScroll('scrollerId', {
vScroll: false,
vScrollbar: false,
hScrollbar: false,
snap: 'li',
momentum: false,
onBeforeScrollStart: function(e) {
point = e.touches[0];
pointStartX = point.pageX;
pointStartY = point.pageY;
deltaX = Math.abs(point.pageX - pointStartX);
deltaY = Math.abs(point.pageY - pointStartY);
if(deltaX >= deltaY){ isHorizontal = true; }
},
onBeforeScrollMove: function(e) {
if (isHorizontal) { e.preventDefault(); }
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment