Git Product home page Git Product logo

Comments (6)

1deadpixl avatar 1deadpixl commented on July 17, 2024 6

I found that this problem persists in my Nuxt project, and the only way to solve it was to comment out the entire beforeDestroy() hook in the package's src/flickity.vue component.

Had the same problem using Nuxt and this is a good fix, except…

Not sure if that will cause other issues down the road but it's working as of right now.

…you still need to destroy the Flickity instance(s) after being done with them.

My case was that I wanted to scroll to the top of the page during the leave transition and all my Flickitys were gone before the scroll even started, leaving the page looking gnarly. After disabling the beforeDestroy hook in vue-flickity, I load up the data object of my GSAP tween with all my Flickity references and destroy() them after the leaving animation completes.

All this is necessary because the leave, beforeDestroy and destroy hooks run immediately on a route change and all references get destroyed before the animation finishes so we have to keep them around somewhere.

Update
To disable the hook persistently without worrying about changes from package updates or npm clean installs, the beforeDestroy method can be set to undefined when defining the plugin.

/* plugins/flickity.js */

import Vue from "vue";
import Flickity from "vue-flickity";
import "flickity-imagesloaded";
import "flickity-fade";

Flickity.beforeDestroy = undefined;
Vue.component("flickity", Flickity);

from vue-flickity.

EnMod avatar EnMod commented on July 17, 2024 1

I found that this problem persists in my Nuxt project, and the only way to solve it was to comment out the entire beforeDestroy() hook in the package's src/flickity.vue component. Not sure if that will cause other issues down the road but it's working as of right now.

from vue-flickity.

 avatar commented on July 17, 2024

Hard to say on this without debugging the UI, but it might be the .destroy() method removing flickity and its core styling while the component is unmounted and animated away. You could try modifying the wrapper so flickity is not destroyed before the transition finishes or you could hardcode some of the necessary styles in your codebase so they remain after flickity is unmounted or you could use <keep-alive> above the component so the beforeDestroy() hook is never triggered.

from vue-flickity.

chasegiunta avatar chasegiunta commented on July 17, 2024

@b8ne I know it's been a while, but were you ever able to find a workaround for this? Also running into this issue.

from vue-flickity.

elHornair avatar elHornair commented on July 17, 2024

I had the same problem and was able to avoid it by using keep-alive as suggested by @mystrdat. Check the docs for details. Note that keep-alive needs to be around your component but inside the transition.
/cc @chasegiunta @b8ne

from vue-flickity.

chrisjansky avatar chrisjansky commented on July 17, 2024

Has anyone managed to solve it when importing vue-flickity only inside a Nuxt single page, like this:

export default {
  components: {
    Flickity: () => import("vue-flickity")
  }
}

Thanks for any pointers.

from vue-flickity.

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.