GithubHelp home page GithubHelp logo

Comments (9)

ancashoria avatar ancashoria commented on June 10, 2024 2

Thanks, it must have been something with my home made isMobile hook.
I have migrated to breakpoints and everything works smooth.

Thank you so much and congrats on the 8.0 release

from embla-carousel.

davidjerleke avatar davidjerleke commented on June 10, 2024 1

I cant view that sandbox (404)

@smc13 sorry about that. I had to make the sandbox public. Try now!

from embla-carousel.

davidjerleke avatar davidjerleke commented on June 10, 2024

@smc13 seems like you're doing stuff in the wrong order. You have to change the CSS first, before calling reInit() so correct calculations can be made for the changed axis. Here's a working CodeSandbox.

Best,
David

from embla-carousel.

smc13 avatar smc13 commented on June 10, 2024

@davidjerleke I cant view that sandbox (404) but that does make sense. I'll need to restructure my vue app logic to delay passing the updated options to the plugin since currently vue will do both in the same frame.

Thanks,
Sam

from embla-carousel.

smc13 avatar smc13 commented on June 10, 2024

I've found in Vue I can update the watchers in the plugin to add { flush: 'post' } which causes the watchers to fire after any DOM updates in the parent component.

Not sure if it'll cause any timing issues though (eg: if slides and options are updated at the time time, possibly causing the watchers reInit and emblas native slide watcher to trigger at the same time)

from embla-carousel.

ancashoria avatar ancashoria commented on June 10, 2024

@davidjerleke I'm trying to achieve the same thing in React. Shouldn't embla handle the reactivity by default?

  const axis = isMobile ? "x" : "y";
const [emblaMainRef, emblaMainApi] = useEmblaCarousel({
    axis,
  });

My isMobile hook returns the correct value asyncronously and useEmblaCarousel doesn't update when the axis changes

from embla-carousel.

davidjerleke avatar davidjerleke commented on June 10, 2024

@ancashoria did you pay attention to this? Answer to your question: Yes options are reactive.

from embla-carousel.

ancashoria avatar ancashoria commented on June 10, 2024

I have and even tried to delay the reinit and when axis changes:

useEffect(() => {
    setTimeout(() => {
      emblaMainApi?.reInit({ axis });
      emblaThumbsApi?.reInit({ axis });
    }, 1000);
  }, [axis]);

from embla-carousel.

davidjerleke avatar davidjerleke commented on June 10, 2024

@ancashoria yes, but how about your CSS? Did you change it to align the slides vertically when the axis is y?

from embla-carousel.

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.