问题
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 ?
回答1:
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.
回答2:
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>
来源:https://stackoverflow.com/questions/31005504/how-to-implement-long-press-event-using-polymer1-0