From 11968351f8ec6374411e43d391a816e86ce9ebf8 Mon Sep 17 00:00:00 2001 From: Sarah Meyer Date: Mon, 21 Jan 2019 09:53:17 -0700 Subject: [PATCH] adjust mouseUp handler to account for click buttons or dropdowns within the slide (#486) --- src/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index ae242831..72632038 100644 --- a/src/index.js +++ b/src/index.js @@ -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 @@ -275,6 +271,7 @@ export default class Carousel extends React.Component { dragging: true }); }, + onMouseMove: e => { if (!this.state.dragging) { return; @@ -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;