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

Add support for double tap and drag for zooming #34

Open
cdrini opened this issue Oct 23, 2022 · 3 comments
Open

Add support for double tap and drag for zooming #34

cdrini opened this issue Oct 23, 2022 · 3 comments

Comments

@cdrini
Copy link

cdrini commented Oct 23, 2022

This has become a very common interaction in mobile devices: Google maps, Apple.

The way it works:

  • double tapping zooms in
  • double tapping, and dragging upwards on the second tap zooms in proportional to distance from start tap
    • dragging downwards zooms out

It would be great if this was included in the library and easy to add!

@biodiv
Copy link
Owner

biodiv commented Oct 24, 2022

Thanks for bringing attention to this. I tried what you described in Apple maps and it worked as you described.

I will implement support for multiple taps. eg

const tap = new Tap(domElement, {
  taps: 2
});

The latter of what you described is a Tap followed by a Pan. A Tap requires the finger to be lifted from the surface. We could create something like a TapPan gesture, which then also would support tappanleft, tappanright tappanup and tappandown events.

@cdrini
Copy link
Author

cdrini commented Oct 25, 2022

That seems good to me! I think a tappan would be enough for me, and then I could use the x/y coordinates to determine the amount of zoom. But tappan{left,right,up,down} would also work!

Thank you for the prompt reply!

@biodiv
Copy link
Owner

biodiv commented Nov 9, 2022

Meanwhile, you could try something like the following approach:

var TAP_ACTIVE = false;

function onTap(event){
    TAP_ACTIVE = true;
    setTimeout(function(){
        TAP_ACTIVE = false;
    }, 500);
}

pointerListener.on("tap", onTap);

function onPan(event){
    if (TAP_ACTIVE == true){
        if (event.detail.live.direction == "up") {
            // do something
        }
    }
}

pointerListener.on("pan", onPan);

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

2 participants