Created
August 15, 2023 02:31
-
-
Save laurisstepanovs/51a4f6d2bd9fa5deb5975a1f72d9a537 to your computer and use it in GitHub Desktop.
_StickyComponent-createInstances-fixed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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