Comments (6)
Hi, please create a minimal reproduction because it's difficult to understand what's the problem (just kidding it takes to much time to debug it π)
Many questions require ready-made solutions, copy paste answers or real support like "How to...". If the package is useful to you, before you ask for help, at least it's nice to leave the star π Just saying
this.animateOnScroll.scrollTrigger.kill()
Also, I see you are adding the GSAP .kill()
method to the vue
method and that's one of the reasons why this won't work.
P.S: The inject("ScrollTrigger", ScrollTrigger); they talk about is not needed now that it exist this module, right?
I don't understand this part. If you using nuxt-gsap-module
just follow docs.
After activation, plugins are automatically registered and available globally, so you wonβt have to worry about it (applies to all plugins).
From example above, you need:
// GSAP core
const gsap = this.$gsap
// GSAP timeline
const tl = this.$gsap.timeline
// ScrollTrigger
const ScrollTrigger = this.$ScrollTrigger
Anyway, like I said create a minimal repo so I can easily check what itβs all about.
from nuxt-gsap.
Simple example with .getById()
and .kill()
methods:
<template>
<div>
<nuxt-link to="/about">About</nuxt-link>
<section style="height: 150vh"></section>
<h1 class="title">Nuxt GSAP Module</h1>
<section style="height: 150vh"></section>
</div>
</template>
<script>
export default {
methods: {
customScrollTrigger() {
this.$gsap.to('.title', {
scrollTrigger: {
id: 'title01', // Add unique Id
trigger: '.title',
start: 'center bottom',
end: 'center top',
scrub: true,
markers: true
},
x: 500
})
}
},
mounted() {
this.customScrollTrigger()
},
beforeDestroy() {
// Returns the ScrollTrigger with unique Id
// and kills it before route change
this.$ScrollTrigger.getById('title01').kill()
}
}
</script>
from nuxt-gsap.
Hi! I managed to get the beforeDestroy() hook right, thanks a lot for your response, couldn't find the right answer anywhere.
Is there a way to select every scrollTrigger and animation to kill it?
Something like scrollTrigger.getAll().forEach((t) => t.kill());
that I found earlier.
Second, If you see this example bellow, when you get back to the main page, the first trigger is few pixels bellow its possition. Is this normal? Do I have to add a .refresh
or something?
https://codesandbox.io/s/example-for-navigation-dxglh?file=/pages/index.vue
from nuxt-gsap.
Please read the docs and ask for support on official forums. Closing this because there is no issues with the module.
from nuxt-gsap.
See comment
from nuxt-gsap.
For others that encounter a seemingly similar problem, here's an additional thing to check for (which has cost me HOURS).
I was using $fetch to fetch data and even though I was killing scroll trigger instances, things would only work on the intial page load and not again after that, no matter what I tried.
Try using asyncData, instead of fetch, as it solved what loooked like a weird navigation/state/mem leak related issue for me.
from nuxt-gsap.
Related Issues (20)
- How to initialize new plugin objects HOT 2
- Compatible with NuxtJS 3? HOT 17
- Apply initial load fromTo values vs using css HOT 3
- Configuring nuxt.config.js to recognize this.$ExamplePlugin HOT 2
- How to proxy locomotive with Scroll Trigger HOT 1
- Using ScrollTrigger in templates with v-gsap HOT 4
- this.split is not a function HOT 6
- Support for GSAP 3.10. HOT 3
- Can't get access to ScrollSmoother club plugin HOT 5
- How would I do it with compositon api? HOT 1
- ScrollTrigger not working HOT 1
- Typescript Issue $gsap not found HOT 4
- Update to GSAP 3.11 HOT 1
- Scroll Trigger works only before refresh page HOT 5
- Flip plugin undefined HOT 3
- GSAP - Types error
- gsap extraPlugins configuration throws error HOT 1
- $gsap is of type unknown? HOT 8
- $ScrollSmoother.kill() doesn't exist HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuxt-gsap.