From 6c4cb813b0719d428fd7d88d2a5dfa57ae53ff45 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Mon, 10 Oct 2016 15:47:22 -0400 Subject: [PATCH 1/2] Use globally registered mouse events for the brush for a better UX --- src/cartesian/Brush.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/cartesian/Brush.js b/src/cartesian/Brush.js index 3ac9b49bb0..27cbdbe39f 100644 --- a/src/cartesian/Brush.js +++ b/src/cartesian/Brush.js @@ -65,6 +65,11 @@ class Brush extends Component { } } + componentDidMount() { + addEventListener('mousemove', this.handleMove); + addEventListener('mouseup', this.handleUp); + } + componentWillReceiveProps(nextProps) { const { data, width, x, travellerWidth, startIndex, endIndex } = this.props; @@ -102,10 +107,8 @@ class Brush extends Component { this.scale = null; this.scaleValues = null; - if (this.leaveTimer) { - clearTimeout(this.leaveTimer); - this.leaveTimer = null; - } + removeEventListener('mousemove', this.handleMove); + removeEventListener('mouseup', this.handleUp); } getIndexInRange(range, x) { @@ -157,11 +160,6 @@ class Brush extends Component { } handleMove = (e) => { - if (this.leaveTimer) { - clearTimeout(this.leaveTimer); - this.leaveTimer = null; - } - if (this.state.isTravellerMoving) { this.handleTravellerMove(e); } else if (this.state.isSlideMoving) { @@ -176,12 +174,6 @@ class Brush extends Component { }); }; - handleLeaveWrapper = () => { - if (this.state.isTravellerMoving || this.state.isSlideMoving) { - this.leaveTimer = setTimeout(this.handleUp, 1000); - } - }; - handleEnterSlideOrTraveller = () => { this.setState({ isTextActive: true, @@ -419,9 +411,6 @@ class Brush extends Component { return ( {this.renderBackground()} {this.renderSlide(startX, endX)} From 3b6ad4ec652a7d0a10026c8c4287c31e02ecd9d0 Mon Sep 17 00:00:00 2001 From: Bill Neff Date: Mon, 10 Oct 2016 21:44:15 -0400 Subject: [PATCH 2/2] tag v1.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f7a3edfba3..9508a97959 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "recharts", - "version": "1.1.2", + "version": "1.1.4", "description": "React charts", "main": "lib/index", "jsnext:main": "es6/index",