Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 660
vdegenne Avatar asked Oct 20 '22 08:10

vdegenne


1 Answers

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.

like image 63
es_code Avatar answered Oct 27 '22 00:10

es_code