Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrollable on Touch #711

Open
starflower opened this issue Mar 23, 2012 · 11 comments
Open

Scrollable on Touch #711

starflower opened this issue Mar 23, 2012 · 11 comments

Comments

@starflower
Copy link

If you have a scrollable area and you're on touch, vertical scrolling is pain in the ass. And there seems no way on how to detect vertical scrolling?

@mgalliers
Copy link

I have exactly the same issue and can't find a fix for it either? Anyone else, please!?

@starflower
Copy link
Author

Somehow there must be a way to detect a vertical swipe and prevent the trigger for scrollable… Anyone?

@mgalliers
Copy link

I found this.. Not ideal as it requires another plugin but does seem to work: http://awardwinningfjords.com/2010/09/22/handling-touch-events-in-jquery-tools-scrollable.html

@starflower
Copy link
Author

not really (maybe just me though)
But it seems that scrollable doesn’t handle touch events correctly…

@mgalliers
Copy link

well it worked for me; for slider to only work on a horizontal swipe and not vertical. You obviously need to set touch: false for this add-on to do it's stuff..

@starflower
Copy link
Author

Yeah, now it also works for me :)

@marco-martins
Copy link

Jquery tools should be add one option for this.

@shrunyan
Copy link

Also having this issue.

[edit] @Madiba link solved for my implementation, agreed it's not ideal.

@Shavindra
Copy link

I am having the same issue... I have fiddle here

fiddle: http://jsfiddle.net/mmp2m/7/

demo: http://jsfiddle.net/mmp2m/7/show

@Shavindra
Copy link

Related to my earlier comment... this is fixed ref: http://stackoverflow.com/questions/11940351/jquery-tools-touch-horizontal-only-disable-vertical-touch

@lxxps
Copy link

lxxps commented Jan 29, 2014

The touch event is not handle correctly, also it provides a bad side-effect that user cannot scroll the page on horizontal scrollable.

First step: on touchstart, use changedTouches list (list of points of contact that have trigger the event) to get the first touch and not the touches list (list of all points of contact, even ones that have not moved). Do not register the touch if there is already a touch registered (unless you want to deal with multiple touches) .

Second step: on touchmove, detect if the registered touch has moved using its identifier changedTouches.identifiedTouch( touch.identifier ). If the touch has moved, determine if the move is more vertical or horizontal and look if we want to scroll in this direction. A long vertical movement cannot be a straight line but we do not want to consider it as a horizontal one. By example: if a move goes from 100x,20y to 110x,200y, it has to be considered as a vertical move (200-20=180), even if there is a horizontal one (100-110=-10).

Third step: listen to touchend, touchcancel or touchleave events to reset the touch data.

I will attemp a pull request in this way ASAP.

Loops

lxxps added a commit to lxxps/jquerytools that referenced this issue Jan 29, 2014
Use changedTouches instead of touches.
Determine if moves are vertical or horizontal.
Ignore horizontal moves on vertical scrollable, respectively vertical moves on horizontal scrollable (this allow the user to scroll the page on horizontal scrollable).
Do not scroll on tiny moves.

@see jquerytools#711
lxxps added a commit to lxxps/jquerytools that referenced this issue Jan 29, 2014
Use changedTouches instead of touches.
Determine if moves are vertical or horizontal.
Ignore horizontal moves on vertical scrollable, respectively vertical moves on horizontal scrollable (this allow the user to scroll the page on horizontal scrollable).
Do not scroll on tiny moves.

Tested successfully on Android default browser, Chrome mobile and Safari mobile. Firefox should be ok.

@see jquerytools#711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants