Coder Social home page Coder Social logo

Comments (6)

ivodolenc avatar ivodolenc commented on May 12, 2024

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.

ivodolenc avatar ivodolenc commented on May 12, 2024

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.

esadrian avatar esadrian commented on May 12, 2024

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.

ivodolenc avatar ivodolenc commented on May 12, 2024

Please read the docs and ask for support on official forums. Closing this because there is no issues with the module.

from nuxt-gsap.

ivodolenc avatar ivodolenc commented on May 12, 2024

See comment

from nuxt-gsap.

woutercouvaras avatar woutercouvaras commented on May 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.