Nuxt 3 with ScrollTrigger does not work #46
Replies: 3 comments 1 reply
-
Hi, Here is a simple example of <template>
<div class="content">
<div class="box"></div>
</div>
</template>
<script setup lang="ts">
const { $gsap, $ScrollTrigger } = useNuxtApp()
const animateOnScroll = () => {
$gsap.to('.box', {
x: 1000,
ease: 'Power1.easeInOut',
scrollTrigger: {
trigger: '.content',
pin: true,
end: 'bottom',
scrub: true
}
})
}
onMounted(() => {
animateOnScroll()
})
</script>
<style>
.page-index {
color: #fff;
background-color: #151515;
min-height: 100vh;
}
.content {
width: 100vw;
min-height: 300vh;
}
.box {
width: 100px;
height: 100px;
background-color: #fff;
}
</style> |
Beta Was this translation helpful? Give feedback.
-
Hmmm it works, but there seems to be a Since GSAP does not explicitly export its Types, it can be very confusing and time-consuming to know from which modules or packages we can import specific types in case we need some kind of custom solution like this module. I have come across several reports on their forum and repository regarding Types export. This will be fixed in the next release, thanks for reporting. |
Beta Was this translation helpful? Give feedback.
-
Fixed in It should now work normally: $ScrollTrigger.getById('firstTween')?.kill()
$ScrollTrigger.getById('secondTween')?.kill() Feel free to try it out. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Could you pls provide a small example of effect with scroll trigger (fade in effect for example / with Nuxt 3)? I cannot make this work...
Many thanks.
nuxt.config.js :
modules: [ "@hypernym/nuxt-gsap", ], gsap: { extraPlugins: { scrollTrigger: true, }, },
Component :
No effect is working and error is shown : "Property 'getById' does not exist on type '_ScrollTrigger'. Did you mean to access the static member '_ScrollTrigger.getById' instead?Vetur(2576)"
Thanks
Beta Was this translation helpful? Give feedback.
All reactions