Comments (9)
I've solved for just dragging the carousel by doing the following:
-
store the startPosition in state:
this.state = { startPosition: '0' };
-
Pass startPosition to OwlCarousel as prop
startPosition={this.state.startPosition}
-
Pass this as well as a prop:
onDragged={(object) => this.updateCarouselPosition(object)}
-
Function:
updateCarouselPosition(object){ if(object.item.index != this.state.startPosition){ this.setState({ startPosition: object.item.index }); } }
from react-owl-carousel.
How to fix step by step -:
-
Pass
ref={(el) => { this.slider = el; }}
to OwlCarousel as prop -
Inside function componentDidUpdate set
componentDidUpdate() { this.slider.owlCarousel.trigger('refresh.owl.carousel'); }
3.Good luck.
from react-owl-carousel.
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.
Can no one solve this problem?
from react-owl-carousel.
Having same issue.
from react-owl-carousel.
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.
I've solved for just dragging the carousel by doing the following:
- store the startPosition in state:
this.state = { startPosition: '0' };
- Pass startPosition to OwlCarousel as prop
startPosition={this.state.startPosition}
- Pass this as well as a prop:
onDragged={(object) => this.updateCarouselPosition(object)}
- 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.
anyone know how to get this working for Angular?
from react-owl-carousel.
I've solved for just dragging the carousel by doing the following:
- store the startPosition in state:
this.state = { startPosition: '0' };
- Pass startPosition to OwlCarousel as prop
startPosition={this.state.startPosition}
- Pass this as well as a prop:
onDragged={(object) => this.updateCarouselPosition(object)}
- 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)
- How to filter? HOT 1
- Not able to update state variable on onChanged callback , gives error 'unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering' HOT 1
- Add Typescript support
- index.js:1 Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code.
- UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. | Please update the following components: ReactOwlCarousel HOT 9
- window is not defined HOT 1
- SlideTransition prop doesn't exist in react
- Bank white page issue HOT 2
- autoHeightClass doesnt work
- react-owl-carousel mobile issue - one slide getting place at the top of the another slide at arr HOT 1
- i can't use methods HOT 1
- carousel installed but not working
- nav button is not working for scrolling card
- navContainer not working
- jQuery cannot see $
- dotData not working
- Blank OwlCarousel : items moved from .owl-stage to .owl-carousel when resize the window mobile
- Warning: Invalid DOM property `class`. Did you mean `className` HOT 1
- UNSAFE_componentWillReceiveProps HOT 6
- Fails to install in React 17 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-owl-carousel.