An instance of an imported library (ScrollMagic) in the script tag of one page in Sapper, the instance keeps existing when navigating to other pages.
I tried destroying it within ondestroy
, but I can't reference the variable referencing the instance (created wihtin oncreate
).
How can I either scope the script tag to individual pages, or destroy the instance when leaving the page?