Answer the question
In order to leave comments, you need to log in
How to work with third-party modules, how to stop the script after switching to another route?
Hello. Tell me how to organize work with third-party libraries? How to download them correctly, how to destroy them? For example, I took https://github.com/juliangarnier/anime
I imported the library and initialized it in mounted. Everything works, the script starts working when I switch over the route on which it is connected. But after I leave this page, it still works. How to stop it?
<script>
import anime from 'animejs'
export default {
mounted () {
anime({
targets: 'div',
translateX: [
{ value: 100, duration: 1200 },
{ value: 0, duration: 800 }
],
rotate: '1turn',
backgroundColor: '#FFF',
duration: 2000,
loop: true
})
}
}
</script>
beforeDestroy () {
anime.destroy()
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question