bypass for browser that calculate layer*
Bypasses the kinda slow getBoundingClientRect for browsers that actually support CSS transforms for cursors Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
parent
9a08408456
commit
361efc76f2
1 changed files with 8 additions and 4 deletions
|
@ -59,8 +59,14 @@ mouse.registerContext(
|
|||
"world",
|
||||
(evn, ctx) => {
|
||||
// Fix because in chrome layerX and layerY simply doesnt work
|
||||
/** @type {HTMLDivElement} */
|
||||
const target = evn.target;
|
||||
ctx.coords.prev.x = ctx.coords.pos.x;
|
||||
ctx.coords.prev.y = ctx.coords.pos.y;
|
||||
|
||||
if (evn.layerX !== evn.clientX || evn.layerY !== evn.clientY) {
|
||||
ctx.coords.pos.x = evn.layerX;
|
||||
ctx.coords.pos.y = evn.layerY;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get element bounding rect
|
||||
const bb = imageCollection.element.getBoundingClientRect();
|
||||
|
@ -78,8 +84,6 @@ mouse.registerContext(
|
|||
const layerY = ((y - bb.top) / bb.height) * h;
|
||||
|
||||
//
|
||||
ctx.coords.prev.x = ctx.coords.pos.x;
|
||||
ctx.coords.prev.y = ctx.coords.pos.y;
|
||||
ctx.coords.pos.x = Math.round(layerX);
|
||||
ctx.coords.pos.y = Math.round(layerY);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue