hammerjs / hammer.js

A javascript library for multi-touch gestures :// You can touch this
http://hammerjs.github.io
MIT License
24.11k stars 2.63k forks source link

Add support for trackpad gestures in safari 9 and force touch apis #844

Open quantuminformation opened 9 years ago

quantuminformation commented 9 years ago

Is it possible to detect pinch zoom on mac trackpad with hammer.js? How can I do this?

quantuminformation commented 9 years ago

I am wanting to detect any pinch zoom on any supported browser other than the default zoom.

arschmitz commented 9 years ago

No it is not possible to use the trackpad in this way. Also as mentioned in #843 you cannot reliably detect zoom.

runspired commented 9 years ago

@QuantumInformation to follow up on this though, what google maps does is detect scroll events and prevent their default behavior and use them to zoom. This is why you can't scroll around on a google map. See some of the talk in

https://github.com/hammerjs/hammer.js/issues/658

and

https://github.com/hammerjs/hammer.js/issues/602

arschmitz commented 9 years ago

@runspired @QuantumInformation wants to detect pinching not scrolling zoom motions on the trac pad and wants to also be able to detect zoom level. @runspired correct me if i'm wrong but i don't believe either of these are possible.

runspired commented 9 years ago

@arschmitz visit maps.google.com, pinch to zoom :) Notice only the map resizes, nothing else.

runspired commented 9 years ago

Maps also supports 3 finger drag on the map.

runspired commented 9 years ago

I'm pretty sure they do all three of these things by listening to scroll events, preventing the default behavior, then looking at the pointers involved.

runspired commented 9 years ago

This is currently out of scope of hammer, but it is something I'd like to see an OSS lib build to handle.

arschmitz commented 9 years ago

ah it acts as though ctrl key is pressed for pinching motions thats how they do it tricky...

arschmitz commented 9 years ago

@runspired what do you mean by 3 finger drag this does not work for me?

runspired commented 9 years ago

@arschmitz On Chrome I can use 3 fingers on the trackpad to move the map around on the screen.

arschmitz commented 9 years ago

@runspired on Yosemite Chrome for me anything 3 fingers triggers native OS actions

runspired commented 9 years ago

Interesting, I'm on Yosemite too.

runspired commented 9 years ago

Video'd it: https://twitter.com/Runspired/status/631849624928677888

You can start dragging with 3 fingers and drop to 2 or 1 and keep dragging so long as the remaining finger was the first finger put down.

arschmitz commented 9 years ago

@runspired crazy that does not work at all for me in fact if i start with one finger click to drag and add a second it continues to work but as soon as i put down a third it triggers the native switching screens or bringing up the mini screens thing lol removing the 3rd finger also does not restore dragging.

arschmitz commented 9 years ago

@runspired weird no matter what i do i cant reproduce that i even turned off all the OSX gestures this allows me to zoom in and out with 3 fingers but not to drag

runspired commented 9 years ago

Do you have to physically click or just tap to click on your keypad? I have to physically click.

arschmitz commented 9 years ago

physically

arschmitz commented 9 years ago

@runspired figured it out this is an OSX setting that you need to turn on nothing to do with chrome or google maps https://support.apple.com/en-us/HT204609

runspired commented 9 years ago

:'( I was really hopeful google had come up with a clever trick for doing it. Their scroll tricks are still pretty neat.

arschmitz commented 9 years ago

yeah ctrl for detecting pinch scrolling direction is neat i didnt know about it.

But i do know there is no access to the touch point info for doing any type of actual gesture detection on a tracpad sadly.

arschmitz commented 9 years ago

also just a for reference people HATE the way scroll is hijacked for zoom on google maps https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=google%20maps%20scrolling there are tons of threads about it across the internet and even a browser plugin to disabled it and restore normal scrolling. https://chrome.google.com/webstore/detail/scrollmaps/jifommjndpnefcfplgnbhabocomgdjjg?hl=en . People dislike this feature so much there is a popular mechanics article about it and how to use the plugin to remove it. http://www.popularmechanics.com/technology/apps/reviews/a10753/scrollmaps-is-the-google-maps-fix-you-need-16931788/ In all likely hood its best for user experience to not attempt this sort of thing.

arschmitz commented 9 years ago

Also worth noting if pinch zooming is disabled at the OS level it also breaks in google maps. As far as i can tell pinch zoom does not work at all in firefox on osx.

nicooprat commented 8 years ago

Looks like Safari 9.1 brings new events for trackpad on Mac:

iOS gesture events are now supported on Safari for OS X. Use OS X gesture events to detect pinching and rotation on the Magic trackpad. The gestureStart, gestureChange, and gestureEnd events are supported with event.rotation and event.scale properties. For more information on gesture events, see GestureEvent Class Reference.

Also, I found that Mapbox GL supports pinch-to-zoom on Mac too (examples). Their code is opensource: https://github.com/mapbox/mapbox-gl-js ; maybe something to find there ?

arschmitz commented 8 years ago

Interesting and worth looking into since we are a "gesture library"

runspired commented 8 years ago

worth looking into working with the forceTouch api's too at some point I think, or at least it will be if Google/Samsung release a competing feature which seems likely.

arschmitz commented 8 years ago

yeah +1

redbar0n commented 3 years ago

I know I’m 4 years late to the party, but what is the status on this?