eclipsesource / eclipsesource/tabris-js
Revise recommendation for using "tap" event with custom buttons
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Description
### Problem description
The `"tap"` event is currently recommended for usage with custom buttons (see `imageview-as-a-button` snippet).
`"tap"` is currently only triggered when the finger briefly touches the widget without dragging. Slightly dragging while touching the widget results into the `"tap"` event not being fired. [1] ([related issue](https://github.com/eclipsesource/tabris-js/issues/1467))
`"tap"` also would not fire if the finger touches the widget, drags outside it, then returns inside it and releases (default button behaviour on iOS). [2]
### Expected behavior
`"touchEnd"` may be a better alternative to `"tap"` for pressing interaction with custom buttons. It triggers for (2) and it does not have the issue from (1).
Alternatively, a new event may be introduced, which implements the `"touchEnd"` behaviour on iOS and the `"tap"` behaviour on Android to achieve the behaviour common for the given platform.
### Code snippet
```javascript
const {Composite, TextView, ui} = require('tabris');
let touched = 0;
new Composite({
background: 'red',
width: 200, height: 200,
centerX: 0, centerY: 0,
highlightOnTouch: true
}).on('touchEnd', () => {
touched++;
touchedLabel.text = 'touched ' + touched + ' times';
}).appendTo(ui.contentView);
let touchedLabel = new TextView({
top: 'prev() 10', centerX: 0
}).appendTo(ui.contentView);
```
Contributor guide
Assessment
This issue has not been assessed yet.