When to use on-click or on-tap w/ Polymer?

只愿长相守 提交于 2019-12-03 23:33:40

问题


I've researched a lot but still haven't found a good answer. When should I use on-click and when on-tap, specifically w/ Polymer?

This guide focuses on programmatic event listeners, so isn't helpful in that regard:

https://www.polymer-project.org/docs/polymer/touch.html


回答1:


Use on-tap all the time, because the semantics of on-tap are better aligned with mobile devices than on-click.

For example, on-click does not fire if another finger is touching the screen, or if the element directly under the finger does not have a mouse handler. There are also some complications with getting on-click to work while you are scrolling. Use on-tap unless there is a compelling reason not to.




回答2:


It seems that it's changing depending on Polymer version.

Because, different Polymer versions suggest different things:

  • In Polymer 2 documentation, there's a warning (suggestion) for using click event.

  • In Polymer 3 documentation, the warning is not available anymore.



来源:https://stackoverflow.com/questions/26386369/when-to-use-on-click-or-on-tap-w-polymer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!