pixi-viewport icon indicating copy to clipboard operation
pixi-viewport copied to clipboard

Trackpad scrolling

Open iyobo opened this issue 4 years ago • 15 comments

I feel like the UX of this library would lend itself quite well to a pinch-zoom (exists) and track-pad 2-finger panning (does not exist) navigation sceme.

Right now, the only way to pan is to click-drag. It would make for a truly complete navigation UX if Horizontal and vertical panning could also be possible from the trackpad.

Is this possible already? If not, how can it be achieved?

iyobo avatar Jun 30 '20 23:06 iyobo

There is a rudimentary implementation of 2-finger panning. Right now, it doesn't work if you also use the wheel() plugin. I have code in the (I think) gesture branch that is a WIP to enable simultaneous 2-finger panning and trackpad pinching. The reason I haven't rolled it out is that I also need to implement the iOS/mac gestureevents support for this functionality to work cross platform. I haven't had the time to do it, though.

My mac is also super old and not fun to code in, so that's what's really holding me back. I really need to upgrade it.

davidfig avatar Jul 02 '20 23:07 davidfig

Hi @davidfig, is there anything I can assist with on this issue?

I have too little knowledge to make a pull request, but I can definitely assist with testing. I have a mac with trackpad and magic mouse and a windows machine with trackpad. Just let me know.

Btw, thanks for this fantastic pixi extension. It is really easy to work with.

fakob avatar Sep 21 '20 16:09 fakob

@davidfig , did you upgrade your mac ? I really need this plugin to work on a mac with the trackpad , is there anyway I can assist in developing this feature ?

ilija-trbogazov avatar Jun 09 '21 14:06 ilija-trbogazov

Yes, i finally have a nice mac to develop on. Let me see if I can get this implemented and figure out how this makes sense.

davidfig avatar Jun 10 '21 00:06 davidfig

That is great to hear. Not sure if there would be any difference, but I can offer testing on a 2012, a 2017 Macbook and a Windows laptop.

fakob avatar Jun 10 '21 05:06 fakob

@davidfig Thank you for the great project!

But is there any news on this functionality? I'm really waiting for it for my project :)

Gochim avatar Jun 23 '21 08:06 Gochim

@davidfig Glad to hear that! It would be great to know if there is any progress on this issue, as this feature will help us a lot on the project

Stesha24 avatar Jul 05 '21 13:07 Stesha24

You know what? I apologize to everyone. I created a plugin for myself almost a year ago (August 2020), after opening this issue, but forgot to come back here to help others. No soup for me!

Anyway here's a gist: https://gist.github.com/iyobo/4d2ff6a370011675ebf1d561e830be1e. It's a plugin that handles pinch zoom AND 2-finger scrolling at the same time...along with some other stuff I was trying to add (zoom limit) but that one so far is eluding me. You can ignore that in the plugin and just enjoy the full pinch-navigation.

iyobo avatar Jul 10 '21 18:07 iyobo

@Gochim @Stesha24 @fakob @ilija-trbogazov ^^

@davidfig Any pointers on limiting zoom while 2-finger interacting based on that gist?

iyobo avatar Jul 10 '21 18:07 iyobo

@iyobo , the plugin does not behave the way I need it. I need to zooming to happen on a wheel scroll. And you are using the same event for pinching. ( wheel event ) @davidfig , is you implementation based on lower level events like "pointermove" to do zooming and panning ?

ilija-trbogazov avatar Jul 13 '21 08:07 ilija-trbogazov

Try v4.32.0. I added an additional option to wheel to enable trackpad pinch. This provides both trackpad pan and pinch:

viewport.drag().wheel({ trackpadPinch: true, wheelZoom: false })

Please let me know if this helps. I'm still not using the mac-specific Gesture API, but this seems to work on both my mac and windows (although windows chrome has a terrible two-finger pan b/c it locks the scroll direction).

davidfig avatar Jul 17 '21 16:07 davidfig

@davidfig , I tried v4.32.0 , mouse controls are ok , trackpad zooming ( pinch ) is ok , but I can't pan with the trackpad. ( Windows 10 ) It behaves like zoom , any idea why is that ? I used the exact code as you pointed in your last comment , tried both trackpadPinch to be true and false.

ilija-trbogazov avatar Jul 19 '21 07:07 ilija-trbogazov

What does your code look ilke? I just tried it at https://davidfig.github.io/pixi-viewport/ by adding the wheel code above and it seemed to work.

davidfig avatar Jul 20 '21 13:07 davidfig

@davidfig , I tested the code , seems to work , but not quite as I would like. I need the zoom to also be working on the mouse wheel. Without pressing any key modifiers.

ilija-trbogazov avatar Jul 23 '21 08:07 ilija-trbogazov

Hmm...for Windows you can only have zoom or pan with the wheel since there's no way to differentiate between a trackpad wheel and a mouse wheel. For macs, if you use Gesture API then I think there's a way to distinguish them. But the behavior would be inconsistent (I think).

davidfig avatar Jul 23 '21 13:07 davidfig