Git Product home page Git Product logo

Comments (8)

davekiss avatar davekiss commented on July 17, 2024 5

This library fixed the issue for me: https://github.com/David-Desmaisons/Vue.ImagesLoaded

from vue-flickity.

rugor avatar rugor commented on July 17, 2024 5

@pjhartin

import the package:

import imagesLoaded from 'vue-images-loaded'

add the directive:

directives: { imagesLoaded }

then on your flickity component:

<flickity ref="flickity" :options="flickityOptions" v-images-loaded="imgsLoaded">
    <img :src="image.image" alt="" v-for="(image, index) in images" :key="index">
</flickity>

v-images-loaded triggers the method imgsLoaded

which can turn the opacity from 0 to 1 for each image ... at once or all together depending on how you configure the directive.

from vue-flickity.

drewjbartlett avatar drewjbartlett commented on July 17, 2024

I'm not sure this is the right place to ask this. But would you mind sharing some code and I'll have a look to see if I can be of any help? :)

from vue-flickity.

rugor avatar rugor commented on July 17, 2024

Perhaps, but a common use case for Flickity is with images and I can't find an example of that here -- so it may be appropriate.

The issue is described in this example http://flickity.metafizzy.co/options.html#imagesloaded and here: http://codepen.io/desandro/pen/MYQWEe

I have an array of images I want to share with the component but it doesn't render correctly sometimes because Flickity fires before the images are loaded. How have you been able render images successfully with this component? Or maybe I need to pull in imagesLoaded too

from vue-flickity.

elHornair avatar elHornair commented on July 17, 2024

@rugor I had the same issue, but luckily in my case all the images were the same size, so I gave fixed dimensions to their containers with CSS - That way, Flickity doesn't have to wait for the images to be fully loaded for correctly rendering the items

from vue-flickity.

philliphartin avatar philliphartin commented on July 17, 2024

@davekiss - When you say it fixed it, how did it fix it, what did you hook into when the image was processed?

from vue-flickity.

philliphartin avatar philliphartin commented on July 17, 2024

@rugor

Thanks mate for the clarification. I actually was wondering about the issue where images are dynamically added but it causes a problem where Flickity wouldn't resize properly: https://flickity.metafizzy.co/options.html#imagesloaded

I got it in the end by adding a reference to Flickity and calling the reloadCells function.

imgsLoaded(instance, image) {
      // Reload flickity cells due to height change post
      let flickityInstance = this.$refs.flickity;
      flickityInstance.reloadCells();
    }

from vue-flickity.

rugor avatar rugor commented on July 17, 2024

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.