To me it looks like on(touch) returns coordinates outside the values returned by g.getWidth() and g.getHeight(). I would argue that clipping is the correct thing to do.
I would never expect ontouch to return an x or y outside of the size of the screen reported by g.getWidth() and g.getHeight().
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
To me it looks like on(touch) returns coordinates outside the values returned by g.getWidth() and g.getHeight(). I would argue that clipping is the correct thing to do.
I would never expect ontouch to return an x or y outside of the size of the screen reported by g.getWidth() and g.getHeight().