Closed moevbiz closed 5 years ago
Hi @moevbiz the variables sb
and infScroll
are local to the beforeEnter
method and therefor are undefined in beforeLeave
. Declare them somewhere outside so they are available in both methods. Something like this:
const myTransition = () => {
let sb;
let infScroll;
return {
beforeEnter(data) {
sb = new ScrollBooster(/*...*/);
infScroll = new InfiniteScroll(/*...*/);
},
beforeLeave() {
sb.destroy();
infScroll.destroy();
}
}
}
@moevbiz as transitions are simple objects, you can also store your instances as properties (e.g. this.sb
).
oh wow @nicolas-cusan thanks for pointing that out to me. 😵and thanks @thierrymichel for the hint.
I'm experiencing this issue when trying to destroy instances of other plugins inside
beforeLeave
, specifically scrollbooster and infinite scroll.Both of the plugins work fine when I initialize them inside
beforeEnter
orafterEnter
, but when trying to usesb.destroy()
orinfScroll.destroy()
when leaving the page withbeforeLeave
, I am getting an error warning in my console and the next page doesn't load. The same error also happens when simply trying toconsole.log(infScroll)
onbeforeLeave
.Is there something I'm missing? I've used
destroy()
on other sites with other plugins and it's working well… I'll try and recreate this on a demo page, but is there maybe something I can try beforehand?