Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Commit

Permalink
Support multiple pinning controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
dotherightthing committed Jan 26, 2021
1 parent ecc6849 commit b0395fd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions js/_frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,17 @@ const wpdtrtAnchorlinksUi = {
// but this gives us control over the max-height

if (pinController.length) {
const pinAnchorLinksListObserver = new IntersectionObserver(wpdtrtAnchorlinksUi.pinAnchorLinksList,
{
root: null, // relative to document viewport
rootMargin: '0px', // margin around root, unitless values not allowed
threshold: 0.1 // visible amount of item shown in relation to root
});

pinAnchorLinksListObserver.observe(pinController.get(0));
pinController.each((i, item) => {
/* eslint-disable-next-line max-len */
const pinAnchorLinksListObserver = new IntersectionObserver(wpdtrtAnchorlinksUi.pinAnchorLinksList,
{
root: null, // relative to document viewport
rootMargin: '0px', // margin around root, unitless values not allowed
threshold: 0.1 // visible amount of item shown in relation to root
});

pinAnchorLinksListObserver.observe($(item).get(0));
});
}
}
}
Expand Down

0 comments on commit b0395fd

Please sign in to comment.