ftlabs / ftscroller

FTScroller is a cross-browser Javascript/CSS library to allow touch, mouse or scrollwheel scrolling within specified elements, with pagination, snapping and bouncing support.
MIT License
1.19k stars 121 forks source link

Fixing Dolfin2 problem with touchmove event #23

Open waldbaerkoch opened 11 years ago

waldbaerkoch commented 11 years ago

Samsung's Dolfin 2 browser has a problem with touchmove events: clientY seems to be increased by the difference between pageY and clientY at touchstart. I triy to workaround this problem by addiing

var _isDolfin2 = (/Dolfin\/2\./).test(navigator.userAgent);

in the outermost closure,

var _diffY;

in the FTScroller constructor,

_diffY = _isDolfin2 ? touchEvent.pageY - touchEvent.clientY : 0;

at the end of _onTouchStart,

 _updateScroll(touchEvent.clientX, touchEvent.clientY - _diffY, moveEvent.timeStamp, moveEvent);

instead of

_updateScroll(touchEvent.clientX, touchEvent.clientY, moveEvent.timeStamp, moveEvent);

in _onTouchMove, and

_diffY = 0;

at the end of _onTouchEnd.

rowanbeentje commented 11 years ago

Hacky but very sensible :) Thanks for taking the time to debug this one - I need a little time to replicate this just to play around with the fix, but this'll probably be merged exactly as you suggest.