Skip to content

Commit 063c770

Browse files
committed
Fix - for WebKit browsers correctly position HTML5 canvas
One should use getComputedStyle to find first parent with non-static position
1 parent de7cb2a commit 063c770

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/JSRootPainter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,8 +1444,8 @@
14441444
// our position inside canvas, but to set 'absolute' position we should use
14451445
// canvas element offset relative to first parent with position
14461446
var offx = 0, offy = 0;
1447-
while ((prnt !== null) && !offx && !offy) {
1448-
if (prnt.style.top || prnt.style.left) break;
1447+
while (prnt && !offx && !offy) {
1448+
if (getComputedStyle(prnt).position !== 'static') break;
14491449
offx += prnt.offsetLeft;
14501450
offy += prnt.offsetTop;
14511451
prnt = prnt.parentNode;

0 commit comments

Comments
 (0)