Skip to content

Commit 253ac4a

Browse files
committed
fix(pat-scroll): Fix issue where no scroll target can be found. Use document.body instead.
1 parent 11f3387 commit 253ac4a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/pat/scroll/scroll.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ class Pattern extends BasePattern {
5252
await utils.timeout(this.options.delay);
5353
}
5454

55-
const target = this.get_target();
56-
const scroll_container = dom.find_scroll_container(
57-
target.parentElement,
58-
this.options.direction === "top" ? "y" : "x",
59-
window
60-
);
55+
const target = this.get_target() || document.body;
56+
const scroll_container =
57+
target === document.body
58+
? document.body
59+
: dom.find_scroll_container(
60+
target.parentElement,
61+
this.options.direction === "top" ? "y" : "x",
62+
window
63+
);
6164

6265
// Set/remove classes on beginning and end of scroll
6366
this.el.classList.add("pat-scroll-animated");

0 commit comments

Comments
 (0)