Skip to content

Commit baae37c

Browse files
committed
fix(pat-bumper): Do not calculate padding/margin on viewport.
On the viewport as scrolling container paddings and margins are not influencing the sticky element's position. This is contrary to other scrolling containers within the document. The position calculation is easier and only consists of the clientWidth/Height to respect scrollbar widths.
1 parent 061d452 commit baae37c

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/pat/bumper/bumper.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,11 @@ class Pattern extends BasePattern {
3333

3434
// Viewport dimensions
3535
this.dim_viewport = {
36-
top:
37-
0 +
38-
dom.get_css_value(document.body, "margin-top", true) +
39-
dom.get_css_value(document.body, "padding-top", true),
40-
left:
41-
0 +
42-
dom.get_css_value(document.body, "margin-left", true) +
43-
dom.get_css_value(document.body, "padding-left", true),
36+
top: 0,
37+
right: document.documentElement.clientWidth,
38+
bottom: document.documentElement.clientHeight,
39+
left: 0,
4440
};
45-
this.dim_viewport.right =
46-
document.documentElement.clientWidth -
47-
dom.get_css_value(document.body, "margin-right", true) -
48-
dom.get_css_value(document.body, "padding-right", true);
49-
this.dim_viewport.bottom =
50-
document.documentElement.clientHeight -
51-
dom.get_css_value(document.body, "margin-bottom", true) -
52-
dom.get_css_value(document.body, "padding-bottom", true);
5341

5442
this.dim_element = {
5543
top: dom.get_css_value(this.el, "top", true),

0 commit comments

Comments
 (0)