Skip to content

Commit

Permalink
Multiple swipers on the same view
Browse files Browse the repository at this point in the history
Its not possible now to have multiple swipers on the same view.
I cant re render the component and expecting the content to change.
We have a issue where we have a slider that is dependant on an dropdown value.
So when this value changes, the slider content changes.

But since the component is already mounted, there is not an entrance to newing up an new Swiper.

This is my suggetstion, works for us.
  • Loading branch information
vongohren committed Feb 9, 2016
1 parent 2fec763 commit 51207ff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion react-swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@
callback : React.PropTypes.func,
transitionEnd : React.PropTypes.func,
containerStyles : React.PropTypes.object,
wrapperStyles : React.PropTypes.object
wrapperStyles : React.PropTypes.object,
reinitSwipeOnUpdate : React.PropTypes.bool
},

componentDidMount: function () {
this.swipe = Swipe(ReactDOM.findDOMNode(this), objectAssign({}, this.props));
},

componentDidUpdate: function () {
if (this.props.reinitSwipeOnUpdate) {
this.swipe.kill();
this.swipe = Swipe(ReactDOM.findDOMNode(this), objectAssign({}, this.props));
}
if (this.props.slideToIndex || this.props.slideToIndex === 0) {
this.swipe.slide(this.props.slideToIndex);
}
Expand Down

0 comments on commit 51207ff

Please sign in to comment.