From b84888214b0ad46fb93051779b9efe06275640fe Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Wed, 29 Apr 2020 10:00:25 +0200 Subject: [PATCH] fix auto-animate bug on devices with < 2 devicePixelRatio --- js/controllers/autoanimate.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/controllers/autoanimate.js b/js/controllers/autoanimate.js index ca90819..8829bc6 100644 --- a/js/controllers/autoanimate.js +++ b/js/controllers/autoanimate.js @@ -343,7 +343,16 @@ export default class AutoAnimate { bounds = elementOptions.measure( element ); } else { - bounds = element.getBoundingClientRect(); + bounds = { + x: element.offsetLeft * scale, + y: element.offsetTop * scale, + width: element.offsetWidth * scale, + height: element.offsetHeight * scale + }; + + // More precise, but breaks when used in combination + // with zoom for scaling the deck ¯\_(ツ)_/¯ + // bounds = element.getBoundingClientRect(); } properties.x = bounds.x;