Skip to content

Commit 79dadc5

Browse files
authored
Merge pull request #1160 from Patternslib/fix-inject-scroll
pat-inject scroll fix
2 parents 731ac48 + efde472 commit 79dadc5

File tree

2 files changed

+99
-96
lines changed

2 files changed

+99
-96
lines changed

src/pat/inject/inject.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,15 @@ const inject = {
487487
}
488488

489489
if (cfg.scroll && cfg.scroll !== "none") {
490+
// Get the scroll target for
491+
// 1) finding the scroll container
492+
// 2) getting the scroll offset (if not "top" or "target")
493+
const scroll_target = ["top", "target"].includes(cfg.scroll)
494+
? cfg.$target[0]
495+
: $(cfg.scroll, $injected)[0];
496+
490497
const scroll_container = dom.find_scroll_container(
491-
cfg.$target[0],
498+
scroll_target,
492499
null,
493500
window
494501
);
@@ -498,11 +505,6 @@ const inject = {
498505
let left = 0;
499506

500507
if (cfg.scroll !== "top") {
501-
const scroll_target =
502-
cfg.scroll === "target"
503-
? cfg.$target[0]
504-
: $injected.filter(cfg.scroll)[0];
505-
506508
// Get the reference element to which against we calculate
507509
// the relative position of the target.
508510
// In case of a scroll container of window, we do not have

0 commit comments

Comments
 (0)