biodiv / contactjs

Pointer gestures for your webapp
MIT License
77 stars 6 forks source link

Support for press? #4

Closed niklasgrewe closed 2 years ago

niklasgrewe commented 2 years ago

Hi thank you for an alternative library for HammerJS. 👍 Could you also support press actions?

biodiv commented 2 years ago

I will implement press actions. I would define a press action as follows:

Is this your understanding of a press aswell ?

niklasgrewe commented 2 years ago

Yes, absolutely, could you also include e.preventDefault()? For example, when I add a press action to a <a href="/test" /> I get a link preview by default in Safari (iOS). It would be great if we can prevent this as well

biodiv commented 2 years ago

Maybe the link preview is the contextmenu event. Although e.preventDefault should be configurable in contactjs in the future, you can try the following. The contextmenu might be triggered by the TouchEvents, not PointerEvents. If this is the case, you could add the css

.nocontextmenu {
    touch-action: none;
}

to your links. contactjs uses PointerEvents, so it still works if touch actions are disabled.

edit: to also disable the text-selection bubble in iOS15, I had to add the following css:

.nocontextmenu {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
}
biodiv commented 2 years ago

I added support for press in the latest build (/build folder of this repository ). The required time is currently set to 600ms. For testing, you can adjust this setting in contact.js line 1306: ''' this.initialMinMaxParameters["duration"] = [600, null]; ''' It would be highly appreciated if you tested if 600ms is in your opinion appropriate for a press. I tried it side-by-side to iOS15 and it seemed to be about right to me.

biodiv commented 2 years ago

implemented in v1.3.1