Skip to content

Commit ad601f2

Browse files
committed
fixed bug in setting trackStyle while componentWillReceiveProps to avoid breaking animation
1 parent 63c9385 commit ad601f2

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/inner-slider.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,20 @@ export class InnerSlider extends React.Component {
107107
}
108108
componentWillReceiveProps = (nextProps) => {
109109
let spec = {listRef: this.list, trackRef: this.track, ...nextProps, ...this.state}
110-
let setTrackStyle
111-
if (this.state.animating) setTrackStyle = false
112-
else setTrackStyle = true
110+
let setTrackStyle = false
111+
for (let key of Object.keys(this.props)) {
112+
if (!nextProps.hasOwnProperty(key)) {
113+
setTrackStyle = true
114+
break
115+
}
116+
if (typeof nextProps[key] === 'object' || typeof nextProps[key] === 'function') {
117+
continue
118+
}
119+
if (nextProps[key] !== this.props[key]) {
120+
setTrackStyle = true
121+
break
122+
}
123+
}
113124
this.updateState(spec, setTrackStyle, () => {
114125
if (this.state.currentSlide >= React.Children.count(nextProps.children)) {
115126
this.changeSlide({

0 commit comments

Comments
 (0)