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

fix: prevent zoom on mobile when handleTouch is set to false #293

Merged
merged 8 commits into from
Aug 2, 2019

Conversation

sherwinski
Copy link
Contributor

@sherwinski sherwinski commented Jul 28, 2019

It appears that touchstart events on mobile will also trigger a mouseenter event by default, which will still create a ZoomPane element even if handleTouch is set to false at instantiation. This PR will prevent that default behavior in scenarios where handleTouch is set to false.
Fixes #273

  • All existing unit tests are still passing (if applicable)
  • Add new passing unit tests to cover the code introduced by your PR
  • Add some steps so we can test your bug fix
  • The PR title is in the conventional commit format: e.g. fix(<area>): fixed bug #issue-number

Steps to Test
Behavior on base branch: https://codepen.io/billythekid/pen/WqZwmW
Behavior on this PR: https://codepen.io/sherwinski/pen/GbbGYP

  1. Open codepen link in Chrome browser
  2. Open devtools panel
  3. On the top toolbar, select "Toggle Device Toolbar" (cmd + shift + M) and using the drop down that usually reads "Responsive", select a touch device
  4. Under the "Sources" tab, find the section called "Event Listener Breakpoints"
  5. Checkoff the checkboxes for "mouse" and "touch"
  6. Using the mouse, click on the image in the codepen
  7. Step through each of the events trigger

In the base branch, a click will result in a "touchstart" and then a "mouseenter" event, whereas in the PR version only "touchstart" will execute.

@sherwinski
Copy link
Contributor Author

Hey @billythekid, care to take a look at this and see what you think? I'm hoping this will solve the touch bug we discussed a few weeks ago.

@billythekid
Copy link

Heya @sherwinski,

This appear to work well, on chrome devtools 'touch mode', firefox devtools 'touch mode' as well as chrome on iphone so I'm saying this is a good catch and a nice way to do it actually, just unbind the event.

Thanks for checking it out!

@sherwinski sherwinski merged commit d1ea511 into master Aug 2, 2019
@sherwinski sherwinski deleted the handleTouch-mobile-bug branch August 2, 2019 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

handleTouch: false bug on tap.
3 participants