Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laurisstepanovs/51a4f6d2bd9fa5deb5975a1f72d9a537 to your computer and use it in GitHub Desktop.
Save laurisstepanovs/51a4f6d2bd9fa5deb5975a1f72d9a537 to your computer and use it in GitHub Desktop.
_StickyComponent-createInstances-fixed.ts
public static createInstances(selector: string) {
DataUtil.getAllInstancesByKey("sticky").forEach((stickyInst) => {
window.removeEventListener("scroll", stickyInst.scroll);
});
const elements = document.body.querySelectorAll(selector);
elements.forEach((element) => {
const item = element as HTMLElement;
let sticky = StickyComponent.getInstance(item);
if (!sticky) {
sticky = new StickyComponent(item, defaultStickyOptions);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment