Closed Bug 827863 Opened 11 years ago Closed 6 years ago

Fix touch events example code regarding pageX/pageY offset postion

Categories

(Developer Documentation Graveyard :: API: DOM, defect)

ARM
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: romaxa, Unassigned)

References

()

Details

I've noticed that touch test example
https://developer.mozilla.org/samples/domref/touchevents.html
which is referred by page https://developer.mozilla.org/en-US/docs/DOM/Touch_events

does not work correctly on Mobile Firefox, not sure if same issue on B2G.

problem is that canvas painting line position has 8px (body default) offset off the finger screen position
if I increase that distance a bit more, http://romaxa.info/tests/touch_wrong.html - then problem even more visible.

I tested it on google chrome, safari it works the same way... 
so it seems documentation need to be updated and test fixed using canvas element position offset subtraction from touch.pageX/pageY.
http://romaxa.info/tests/touch.html - like it is done here.
tracking-fennec: --- → ?
Matt what is the right behavior here
Flags: needinfo?(mbrubeck)
It sounds like Firefox, Chrome, and Safari all work the same way, so I would consider this a bug in the example code.
Flags: needinfo?(mbrubeck)
interesting question is why clientX/Y provide similar behavior? ideally it should give coordinates in space of canvas area... but it does not... is it some generic bug?
hmm mouse events works exactly same way...
clientX/Y and pageX/Y are the same if page isn't scrolled.
The simplest fix for the example code might be to position the <canvas> at the top left corner of the page (e.g. remove any padding or margins on the <body> or <canvas>).  Or we can use the more robust fix linked in comment 0.
tracking-fennec: ? → ---
Component: DOM → Other
Product: Core → Mozilla Developer Network
Summary: Fix DOC or touch events regarding pageX/pageY offset postion → Fix touch events example code regarding pageX/pageY offset postion
Assignee: nobody → bruant.d
Component: General → DOM
Product: Mozilla Developer Network → Developer Documentation
Whiteboard: [triaged]
Assignee: bruant.d → nobody
Whiteboard: [triaged]
The https://developer.mozilla.org/en-US/docs/Web/API/Touch_events page does not reference the broken sample under https://developer.mozilla.org/samples/domref/touchevents.html anymore.

All these static examples under https://developer.mozilla.org/samples/ will be removed in bug 1076893.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
See Also: → 1076893
You need to log in before you can comment on or make changes to this bug.