Skip to content

Commit

Permalink
Fixed issue #6
Browse files Browse the repository at this point in the history
  • Loading branch information
kiran committed Feb 11, 2015
1 parent b6120fa commit 837466b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 34 deletions.
38 changes: 23 additions & 15 deletions dist/react-slick.js
Original file line number Diff line number Diff line change
Expand Up @@ -7585,6 +7585,12 @@ var Slider =
},
swipeStart: function (e) {
var touches, posX, posY;

if ((this.props.swipe === false) || ('ontouchend' in document && this.props.swipe === false)) {
return;
} else if (this.props.draggable === false && e.type.indexOf('mouse') !== -1) {
return;
}
posX = (e.touches !== undefined) ? e.touches[0].pageX : e.clientX;
posY = (e.touches !== undefined) ? e.touches[0].pageY : e.clientY;
this.setState({
Expand Down Expand Up @@ -7620,25 +7626,27 @@ var Slider =
e.preventDefault();
},
swipeEnd: function (e) {
var touchObject = this.state.touchObject;
var minSwipe = this.state.listWidth/this.props.touchThreshold;
var swipeDirection = this.swipeDirection(touchObject);
this.setState({
dragging: false,
touchObject: {}
});
if (touchObject.swipeLength > minSwipe) {
if (swipeDirection === 'left') {
this.slideHandler(this.state.currentSlide + this.props.slidesToScroll);
} else if (swipeDirection === 'right') {
this.slideHandler(this.state.currentSlide - this.props.slidesToScroll);
if (this.state.dragging) {
var touchObject = this.state.touchObject;
var minSwipe = this.state.listWidth/this.props.touchThreshold;
var swipeDirection = this.swipeDirection(touchObject);
this.setState({
dragging: false,
touchObject: {}
});
if (touchObject.swipeLength > minSwipe) {
if (swipeDirection === 'left') {
this.slideHandler(this.state.currentSlide + this.props.slidesToScroll);
} else if (swipeDirection === 'right') {
this.slideHandler(this.state.currentSlide - this.props.slidesToScroll);
} else {
this.slideHandler(this.state.currentSlide, null, true);
}
} else {
this.slideHandler(this.state.currentSlide, null, true);
}
} else {
this.slideHandler(this.state.currentSlide, null, true);
e.preventDefault();
}
e.preventDefault();
},
};

Expand Down
4 changes: 2 additions & 2 deletions dist/react-slick.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/demos.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var SingleItem = React.createClass({
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1
slidesToScroll: 1,
};
return (
<div>
Expand Down
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,6 @@ gulp.task('dist-min', function (cb) {
});
});

gulp.task('dist', runSequence('dist-clean', 'dist-unmin', 'dist-min'));
gulp.task('dist', function (cb) {
runSequence('dist-clean', 'dist-unmin', 'dist-min', cb)
});
38 changes: 23 additions & 15 deletions lib/mixins/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ var EventHandlers = {
},
swipeStart: function (e) {
var touches, posX, posY;

if ((this.props.swipe === false) || ('ontouchend' in document && this.props.swipe === false)) {
return;
} else if (this.props.draggable === false && e.type.indexOf('mouse') !== -1) {
return;
}
posX = (e.touches !== undefined) ? e.touches[0].pageX : e.clientX;
posY = (e.touches !== undefined) ? e.touches[0].pageY : e.clientY;
this.setState({
Expand Down Expand Up @@ -71,25 +77,27 @@ var EventHandlers = {
e.preventDefault();
},
swipeEnd: function (e) {
var touchObject = this.state.touchObject;
var minSwipe = this.state.listWidth/this.props.touchThreshold;
var swipeDirection = this.swipeDirection(touchObject);
this.setState({
dragging: false,
touchObject: {}
});
if (touchObject.swipeLength > minSwipe) {
if (swipeDirection === 'left') {
this.slideHandler(this.state.currentSlide + this.props.slidesToScroll);
} else if (swipeDirection === 'right') {
this.slideHandler(this.state.currentSlide - this.props.slidesToScroll);
if (this.state.dragging) {
var touchObject = this.state.touchObject;
var minSwipe = this.state.listWidth/this.props.touchThreshold;
var swipeDirection = this.swipeDirection(touchObject);
this.setState({
dragging: false,
touchObject: {}
});
if (touchObject.swipeLength > minSwipe) {
if (swipeDirection === 'left') {
this.slideHandler(this.state.currentSlide + this.props.slidesToScroll);
} else if (swipeDirection === 'right') {
this.slideHandler(this.state.currentSlide - this.props.slidesToScroll);
} else {
this.slideHandler(this.state.currentSlide, null, true);
}
} else {
this.slideHandler(this.state.currentSlide, null, true);
}
} else {
this.slideHandler(this.state.currentSlide, null, true);
e.preventDefault();
}
e.preventDefault();
},
};

Expand Down

0 comments on commit 837466b

Please sign in to comment.