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

Should touchstart on drag be preventDefault’d? #1373

Closed
mbostock opened this issue Jul 7, 2013 · 8 comments
Closed

Should touchstart on drag be preventDefault’d? #1373

mbostock opened this issue Jul 7, 2013 · 8 comments
Milestone

Comments

@mbostock
Copy link
Member

mbostock commented Jul 7, 2013

See #1341.

@mbostock
Copy link
Member Author

mbostock commented Jul 7, 2013

Related: should the suppressed click be stopPropagation’d as well? Currently we just preventDefault.

@tpreusse
Copy link
Contributor

tpreusse commented Jul 7, 2013

just realized that we'd probably would want touchmove to be preventDefault’d (also used to be that way), since a preventDefault on touchstart also cancels the click event (on touch platforms).

@mbostock
Copy link
Member Author

Well, just looking now, and it definitely appears that we must suppress touchstart’s default behavior on iOS, or dragging is basically useless because it will trigger scrolling (panning or pinch-zooming). And since we have to disable touchstart at the start of the gesture, there’s no way to not re-enable the click if that touch gesture doesn’t result in any movement.

@mbostock
Copy link
Member Author

/cc @jasondavies @jfirebaugh

@tpreusse
Copy link
Contributor

did you consider suppressing touchmove instead? Seems to work quite well on iOS: http://be-asp.budget.opendata.ch/ (maybe worth testing in a isolated example but I don't have time to create one atm.)

@mbostock
Copy link
Member Author

I tried suppressing touchmove and it didn’t seem to have any effect (using iOS Simulator).

@tpreusse
Copy link
Contributor

touchmove suppressing works for me in iOS simulator 6.0 and iPad with iOS 6:
http://bl.ocks.org/tpreusse/5971476

also added an alert on click which works for me with touchmove preventDefault'd but not touchstart preventDefault'd.

@mbostock
Copy link
Member Author

Thanks for that! I figured out what was going on and have fixed it in ba1a411, which now prevents default on touchmove rather than touchstart. It does seem, though, that any preventDefault on touchmove also prevents the subsequent click from firing (not just the browser’s default behavior), but I think that’s probably okay.

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

No branches or pull requests

2 participants