mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-28 14:58:16 +00:00
Fix for touch devices - only works if page is has no scrolling. I've tested it no iPad with iOS 6.01.
This commit is contained in:
parent
b84b22f484
commit
4b56e3f8ae
1 changed files with 4 additions and 14 deletions
|
|
@ -189,30 +189,20 @@
|
|||
}
|
||||
|
||||
return {
|
||||
x: event.clientX + scrollLeft,
|
||||
y: event.clientY + scrollTop
|
||||
x: pointerX(event) + scrollLeft,
|
||||
y: pointerY(event) + scrollTop
|
||||
};
|
||||
}
|
||||
|
||||
var pointerX = function(event) {
|
||||
var docElement = fabric.document.documentElement,
|
||||
body = fabric.document.body || { scrollLeft: 0 };
|
||||
|
||||
// looks like in IE (<9) clientX at certain point (apparently when mouseup fires on VML element)
|
||||
// is represented as COM object, with all the consequences, like "unknown" type and error on [[Get]]
|
||||
// need to investigate later
|
||||
return event.pageX || ((typeof event.clientX !== 'unknown' ? event.clientX : 0) +
|
||||
(docElement.scrollLeft || body.scrollLeft) -
|
||||
(docElement.clientLeft || 0));
|
||||
return (typeof event.clientX !== 'unknown' ? event.clientX : 0);
|
||||
};
|
||||
|
||||
var pointerY = function(event) {
|
||||
var docElement = fabric.document.documentElement,
|
||||
body = fabric.document.body || { scrollTop: 0 };
|
||||
|
||||
return event.pageY || ((typeof event.clientY !== 'unknown' ? event.clientY : 0) +
|
||||
(docElement.scrollTop || body.scrollTop) -
|
||||
(docElement.clientTop || 0));
|
||||
return (typeof event.clientY !== 'unknown' ? event.clientY : 0);
|
||||
};
|
||||
|
||||
if (fabric.isTouchSupported) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue