简体   繁体   中英

How to implement long-press event using Polymer1.0?

It seems like long-press event is not part of the Polymer's specifications.

How would you implement that ?

I thought about using a behavior and using down and up event with some debounce tricks to manage such a new event but that means I have to make a custom element to use this behavior and can't for example use it directly on any elements I want like :

<div on-long-press="_cheese">...</div>

which is not convenient.

Would you have other solutions ?

You don't have to make a custom element for this. This is what polymer behaviors are for. They provide a way for different polymer elements to share common behaviors.

As for the actual javascript for implementing the long-press you can get ideas from this question .

You can use a Vaadin gesture for this.

https://github.com/vaadin/vaadin-context-menu/blob/master/vaadin-long-touch.html

<paper-button on-vaadin-long-touch="function"></paper-button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM