Skip to content

Commit

Permalink
adjust mouseUp handler to account for click buttons or dropdowns with…
Browse files Browse the repository at this point in the history
…in the slide (#486)
  • Loading branch information
Sarah Meyer authored Jan 21, 2019
1 parent cc26ac9 commit 1196835
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ export default class Carousel extends React.Component {
onMouseOut: () => this.handleMouseOut(),

onMouseDown: e => {
if (e.preventDefault) {
e.preventDefault();
}

this.touchObject = {
startX: e.clientX,
startY: e.clientY
Expand All @@ -275,6 +271,7 @@ export default class Carousel extends React.Component {
dragging: true
});
},

onMouseMove: e => {
if (!this.state.dragging) {
return;
Expand Down Expand Up @@ -325,13 +322,19 @@ export default class Carousel extends React.Component {
: 0
});
},

onMouseUp: e => {
if (!this.state.dragging || !this.touchObject.length) {
if (
this.touchObject.length === 0 ||
this.touchObject.length === undefined
) {
this.setState({ dragging: false });
return;
}

this.handleSwipe(e);
},

onMouseLeave: e => {
if (!this.state.dragging) {
return;
Expand Down

0 comments on commit 1196835

Please sign in to comment.