Overscroll, Android and Touchevents #51

Closed
KingRial opened this Issue Apr 2, 2012 · 0 comments

Comments

Projects
None yet
2 participants
Contributor

KingRial commented Apr 2, 2012

I am just opening this issues to talk about "Touchevents" and mobiles.
Right now overscroll is working really fine on iPad/iPhone mobiles because it uses the HTML5 css features "overflowScrolling".

Unluckily Android clients (until the latest realease) cannot use such feature and the library must use "touchevents" to handle the scrolling.

I succesfully used the touchevents to scroll.
There is still a little problem to understand a "simple click" was done; if such event occurs the event must not be stopped with preventDefault().

I still have to understand hot to fork/commit correctlu on github but I'd like to share this little solution which needs improvment.

just changed the "events" variable to add touch events:
events = {
drag: 'mousemove touchmove',
end: 'mouseup mouseleave click touchend touchcancel',
hover: 'mouseenter mouseleave',
ignored: 'select dragstart drag',
scroll: 'scroll',
start: 'mousedown touchstart',
wheel: 'mousewheel DOMMouseScroll'
},

and added a simple check in the drag function:
drag = function (event) {
//ADDED to handle Touch Events datas correctly
if(event.originalEvent.touches){
event.pageX=event.originalEvent.touches[0].pageX;
event.pageY=event.originalEvent.touches[0].pageY;
}
//End ADD
event.preventDefault();
var data = event.data,
etc... etc...

Hope this code can be of some use for other people.

Riccardo "Rial" Re

azoff closed this in ff58566 Apr 12, 2012

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