Skip to content

Instantly share code, notes, and snippets.

@dustintheweb
Last active September 15, 2020 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustintheweb/5446076 to your computer and use it in GitHub Desktop.
Save dustintheweb/5446076 to your computer and use it in GitHub Desktop.
Simulate a horizontal touch scroll event in skrollr.js
// >> Horizontal Touch Scroll Simulator >>>>>>>>>>>>>>>
// prereq: skrollr.js: https://github.com/Prinzhorn/skrollr
function fakeHorzScroll(){
var tStartX, tStopY, touch, mXPos, xPro;
$(window).bind('touchstart', function(e) {
tStartX = e.originalEvent.touches[0].pageX;
e.preventDefault();
});
$(window).bind('touchmove',function(){
move = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
mXPos = move.pageX;
xPro = mXPos-tStartX;
y = skrollr.init().getScrollTop();
newScroll = y+xPro;
skrollr.init().animateTo(newScroll, {duration: 500});
});
}
if ($('html.touch').exists()) {
fakeHorzScroll();
}
@AlexDCA348
Copy link

AlexDCA348 commented Sep 15, 2020

Hi ! Trying your code, but not working...
Are you still working on it ?
Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment