From a2961a1f7710c125a0143383061f2bcbc135dba6 Mon Sep 17 00:00:00 2001 From: IjzerenHein Date: Fri, 30 Oct 2015 09:00:19 +0100 Subject: [PATCH] Added support for DOM elements that are positioned using css-transforms. --- src/js/OTHelpers.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/OTHelpers.coffee b/src/js/OTHelpers.coffee index 1099e664..d36dd491 100644 --- a/src/js/OTHelpers.coffee +++ b/src/js/OTHelpers.coffee @@ -12,13 +12,15 @@ getPosition = (divName) -> pubDiv = document.getElementById(divName) if !pubDiv then return {} computedStyle = if window.getComputedStyle then getComputedStyle(pubDiv, null) else {} + transform = new WebKitCSSMatrix(window.getComputedStyle(pubDiv).transform) width = pubDiv.offsetWidth height = pubDiv.offsetHeight - curtop = pubDiv.offsetTop - curleft = pubDiv.offsetLeft + curtop = pubDiv.offsetTop + transform.m41; + curleft = pubDiv.offsetLeft + transform.m42; while(pubDiv = pubDiv.offsetParent) - curleft += pubDiv.offsetLeft - curtop += pubDiv.offsetTop + transform = new WebKitCSSMatrix(window.getComputedStyle(pubDiv).transform) + curleft += pubDiv.offsetLeft + transform.m41 + curtop += pubDiv.offsetTop + transform.m42 marginTop = parseInt(computedStyle.marginTop) || 0 marginBottom = parseInt(computedStyle.marginBottom) || 0 marginLeft = parseInt(computedStyle.marginLeft) || 0