Skip to content

Feature request: allow pinch to zoom in/out #73

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

Closed
ruijdacd opened this issue Nov 25, 2020 · 3 comments
Closed

Feature request: allow pinch to zoom in/out #73

ruijdacd opened this issue Nov 25, 2020 · 3 comments

Comments

@ruijdacd
Copy link
Contributor

ruijdacd commented Nov 25, 2020

We should allow the user to be able to perform a pinch to zoom action on the slide.

In order to do this we could detect the amount of touches on the mousedown/touchstart and mousemove/touchmove and if that value is equal to 2 (indicating that the user is using 2 pointing devices, fingers in most cases), we can return early from the function and keep the browser behaviour.

If this doesn't clash with anything you are working on, or with future plans with the library, I would be happy to raise a PR for this

@ruijdacd
Copy link
Contributor Author

I just figured out what was causing the pinch to zoom to be missing. I thought it was being prevented on the drag events, but apparently it's the touch-action CSS property that's disabling that behaviour.

I'll make that an option on my components, to conditionally enable/disable that behaviour.

Closing this issue, unless we want to make that an option that developers can disable based on use case

@pySilver
Copy link

@ruijdacd have you managed to implement pinch-zoom inside a slide?

@cabello
Copy link

cabello commented Aug 17, 2023

Just noticed this while using keen-slider on mobile. Found a related issue: #237

It includes a reference to a 7 month PR.

What I ended up doing is, remove the import import 'keen-slider/keen-slider.min.css', copying the content of the file to my project:
https://github.com/rcbyr/keen-slider/blob/1c046b25981c8662085bd1d708af65996316c58c/src/keen-slider.scss

Added pinch-zoom to touch-action.

Zoom is no longer ignored.

The PR however has Javascript code that disables the sliding while zooming:

      if (
        window.TouchEvent &&
        e.raw instanceof TouchEvent &&
        e.raw.touches.length >= 2
      )
        return dragStop(e)

Which translates to, if you are doing a touch event with more than 1 finger, don't let it drag the slide.

Which seems essential for a great User Experience.

I think the CSS only approach, no update to library is a step in the right direction, hence sharing the approach here.

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

No branches or pull requests

3 participants