Skip to content

Commit

Permalink
feat(Slider): support 0.x onBeforeChange
Browse files Browse the repository at this point in the history
  • Loading branch information
myronliu347 committed Apr 26, 2019
1 parent 1ee70af commit 34603cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/slider/slick/mixins/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ const helpers = {
delete this.animationEndCallback;
};

this.props.onBeforeChange(this.state.currentSlide, targetSlide);

this.setState(
{
animating: true,
Expand Down Expand Up @@ -286,6 +288,8 @@ const helpers = {
}
}

this.props.onBeforeChange(this.state.currentSlide, currentSlide);

// Slide Transition happens here.
// animated transition happens to target Slide and
// non - animated transition happens to current Slide
Expand Down
2 changes: 2 additions & 0 deletions src/slider/slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default class Slider extends Component {
* @param {Number} index 幻灯片的索引
*/
onChange: PropTypes.func,
onBeforeChange: PropTypes.func, // 兼容 0.x onBeforeChange
children: PropTypes.any,
/**
* 自定义传入的class
Expand Down Expand Up @@ -187,6 +188,7 @@ export default class Slider extends Component {
variableWidth: false,
waitForAnimate: true,
onChange: () => {},
onBeforeChange: () => {},
edgeEvent: null,
swipeEvent: null,
nextArrow: null, // nextArrow, prevArrow are react components
Expand Down

0 comments on commit 34603cc

Please sign in to comment.