An example from Firefox OS

Hi,

I promised an example of Firefox OS, where click events are not used.
Let me first start by saying that this has been written by another team.
My job is to make this accessible with as little disruption as possible.

In the homescreen app[1] we set up event listeners. If we detect touch
event support we use touch events, if not we use mouse events[2], for
desktop device emulators. All sorts of magic goes in to figuring out if
we started a pan or not, if we didn't and we encounter a touchend
event[3], we try to find the icon that has been tapped, and activate it,
or do something else with it if the home screen is in "editing mode"[4].

We can't add a click listener to the mix, because then icons would get
activated twice by the two types of events. Also, since we lose control
over the distinction between a pan and a tap. In other words a pan might
be interpreted by the platform as a click.

Again, I'm not saying that there aren't other ways to harmonize this and
rework how things are done. But the developers of the home screen chose
to have finer grained control over the input, and simply adding a click
listener would introduce other issues.

1. https://github.com/mozilla-b2g/gaia/blob/master/apps/homescreen
2.
https://github.com/mozilla-b2g/gaia/blob/master/apps/homescreen/js/grid.js#L43
3.
https://github.com/mozilla-b2g/gaia/blob/master/apps/homescreen/js/grid.js#L341
4.
https://github.com/mozilla-b2g/gaia/blob/master/apps/homescreen/js/page.js#L709

Received on Wednesday, 15 May 2013 22:50:43 UTC