GithubHelp home page GithubHelp logo

Comments (9)

iamtomhanks avatar iamtomhanks commented on June 11, 2024 9

I've solved for just dragging the carousel by doing the following:

  1. store the startPosition in state:
    this.state = { startPosition: '0' };

  2. Pass startPosition to OwlCarousel as prop
    startPosition={this.state.startPosition}

  3. Pass this as well as a prop:
    onDragged={(object) => this.updateCarouselPosition(object)}

  4. Function:

updateCarouselPosition(object){ if(object.item.index != this.state.startPosition){ this.setState({ startPosition: object.item.index }); } }

from react-owl-carousel.

akon3000 avatar akon3000 commented on June 11, 2024 1

How to fix step by step -:

  1. Pass ref={(el) => { this.slider = el; }} to OwlCarousel as prop

  2. Inside function componentDidUpdate set
    componentDidUpdate() { this.slider.owlCarousel.trigger('refresh.owl.carousel'); }

3.Good luck.

from react-owl-carousel.

moxon6 avatar moxon6 commented on June 11, 2024 1
  const startPosition = useRef(0);
  return (
    <OwlCarousel
      startPosition={startPosition.current}
      onDragged={({ item, page }) => {
        startPosition.current = item.index - page.size;
      }}
    >
        ...
    </OwlCarousel>
    )
  • This seems to work for the infinite loop slideshow.
  • Using a ref instead of state since we don't actually want a rerender on the value update, but we do want to keep track of the value for the next render

from react-owl-carousel.

 avatar commented on June 11, 2024

Can no one solve this problem?

from react-owl-carousel.

iamtomhanks avatar iamtomhanks commented on June 11, 2024

Having same issue.

from react-owl-carousel.

mxdi9i7 avatar mxdi9i7 commented on June 11, 2024

Problem fixed with iamtomhanks's solution. You do need to manually keep count of the startPosition to avoid resetting the index everytime onChange is triggered on owlCarousel.

from react-owl-carousel.

truongnm97 avatar truongnm97 commented on June 11, 2024

I've solved for just dragging the carousel by doing the following:

  1. store the startPosition in state:
    this.state = { startPosition: '0' };
  2. Pass startPosition to OwlCarousel as prop
    startPosition={this.state.startPosition}
  3. Pass this as well as a prop:
    onDragged={(object) => this.updateCarouselPosition(object)}
  4. Function:

updateCarouselPosition(object){ if(object.item.index != this.state.startPosition){ this.setState({ startPosition: object.item.index }); } }

nice, but your solution doesn't work with infinite loop slideshow

from react-owl-carousel.

Henry-Bot-Hive avatar Henry-Bot-Hive commented on June 11, 2024

anyone know how to get this working for Angular?

from react-owl-carousel.

mariomurrent-softwaresolutions avatar mariomurrent-softwaresolutions commented on June 11, 2024

I've solved for just dragging the carousel by doing the following:

  1. store the startPosition in state:
    this.state = { startPosition: '0' };
  2. Pass startPosition to OwlCarousel as prop
    startPosition={this.state.startPosition}
  3. Pass this as well as a prop:
    onDragged={(object) => this.updateCarouselPosition(object)}
  4. Function:

updateCarouselPosition(object){ if(object.item.index != this.state.startPosition){ this.setState({ startPosition: object.item.index }); } }

But this causes some flickering

from react-owl-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.