如何使用Polymer1.0实现长按事件?

编程入门 行业动态 更新时间:2024-10-20 16:32:07
本文介绍了如何使用Polymer1.0实现长按事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您如何实现这一点?

我想到了一些行为,并使用下来和 up 事件与一些去抖动来管理这样一个新事件的技巧,但这意味着我必须使一个自定义元素来使用这个行为,例如直接使用它,就像我想要的任何元素一样:

< div on-long-press =_ cheese> ...< / div>

这不方便。

你有其他解决方案吗?

解决方案

您不必为此创建自定义元素。这是聚合物行为所适用的。它们为不同的聚合物元素提供了一种共享共同行为的方法。

对于实现长按的实际javascript,您可以从这个疑问。

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.

更多推荐

如何使用Polymer1.0实现长按事件?

本文发布于:2023-08-02 11:32:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1277462.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   事件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!