Skip to content

Commit a6d72f3

Browse files
committed
fix(pat scroll): Fix scroll to position.
The scrolling offset was incorrectly calculated since Patternslib 9.9.0-alpha.5. Fix the calculation for the scrolling position by using `offsetTop` and `offsetLeft` instead `getBoundingClientRect`.
1 parent b1b5c04 commit a6d72f3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/pat/scroll/scroll.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class Pattern extends BasePattern {
6868
this.options.direction === "top" ? "y" : "x",
6969
window
7070
);
71-
const rect = target.getBoundingClientRect();
7271

7372
const scroll_options = { behavior: "auto" }; // Set the behavior in CSS.
7473
if (this.options.selector === "top") {
@@ -86,9 +85,9 @@ class Pattern extends BasePattern {
8685
).scrollWidth;
8786
}
8887
} else if (this.options.direction === "top") {
89-
scroll_options.top = rect.top;
88+
scroll_options.top = target.offsetTop;
9089
} else if (this.options.direction === "left") {
91-
scroll_options.left = rect.left;
90+
scroll_options.left = target.offsetLeft;
9291
}
9392

9493
if (typeof scroll_options.top !== "undefined") {

0 commit comments

Comments
 (0)