20

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

David Notik
  • 2,026
  • 15
  • 21

3 Answers3

22

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.

Shailen Tuli
  • 13,815
  • 5
  • 40
  • 51
  • 2
    note in polymer 2.0, "The tap event is included in the gesture event mixin for backwards compatibility, but it's no longer required in modern mobile browsers", see [here](https://www.polymer-project.org/2.0/docs/devguide/gesture-events) – Markus Apr 04 '18 at 07:50
1

In Polymer 2 documentation and Polymer 3 documentation, using on-click event is suggested. on-tap is legacy.

burak
  • 3,839
  • 1
  • 15
  • 20
1

You should not use the legacy on-tap anymore since this is deprecated in Polymer 2 and 3. See https://polymer-library.polymer-project.org/3.0/docs/devguide/gesture-events

schlm3
  • 108
  • 7