-
Hi! I have an issue with this.$gsap on Nuxt.
=> Uncaught TypeError: Cannot read properties of undefined (reading 'to') I tried this too (based on https://codepen.io/karlovidek/pen/yvxZjO):
And the this.$gsap on the OnRepeat function is undefined (=> Uncaught TypeError: Cannot read properties of undefined (reading 'set') Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, the module works fine, here is an example for mouse animation. When using events in vue/nuxt, the best practice is to add them in the Also keep in mind that you will need some kind of raf or gsap.ticker for better performance. <template>
<div>
<div ref="cursor">Cursor</div>
</div>
</template>
<script>
export default {
mounted() {
this.mouseMounted()
},
beforeDestroy() {
this.mouseDestroyed()
},
methods: {
cursorAnimation(e) {
this.$gsap.to(this.$refs.cursor, {
x: e.pageX,
y: e.pageY,
})
},
mouseMounted(e) {
document.addEventListener('mousemove', this.cursorAnimation)
},
mouseDestroyed(e) {
document.removeEventListener('mousemove', this.cursorAnimation)
},
},
}
</script> |
Beta Was this translation helpful? Give feedback.
Hi, the module works fine, here is an example for mouse animation.
When using events in vue/nuxt, the best practice is to add them in the
mounted
hook and remove them in thedestroy
hook to avoid possible issues later in the dev.Also keep in mind that you will need some kind of raf or gsap.ticker for better performance.