Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include.postload.js

Issue 6014926904623104: Issue 2209 - Ignore scrolls offset when highlighting fixed positioned elements (Closed)
Patch Set: Created March 28, 2015, 4:32 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -204,6 +204,9 @@
var zIndex = "auto";
var position = "absolute";
+ var offsetX = window.scrollX;
+ var offsetY = window.scrollY;
+
for (var e = elt; e; e = e.parentElement)
{
var style = getComputedStyle(e);
@@ -216,7 +219,10 @@
// If the element or one of its ancestors uses fixed postioning, the overlay
// has to use fixed postioning too. Otherwise it might not match the element.
if (style.position == "fixed")
+ {
position = "fixed";
+ offsetX = offsetY = 0;
+ }
// Determine the effective z-index, which is the highest z-index used
// by the element and its offset ancestors, and increase it by one.
@@ -238,8 +244,8 @@
var rect = elt.getBoundingClientRect();
overlay.style.width = rect.width + "px";
overlay.style.height = rect.height + "px";
- overlay.style.left = (rect.left + window.scrollX) + "px";
- overlay.style.top = (rect.top + window.scrollY) + "px";
+ overlay.style.left = (rect.left + offsetX) + "px";
+ overlay.style.top = (rect.top + offsetY) + "px";
overlay.style.position = position;
overlay.style.zIndex = zIndex;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld