From 5e11477172d0c380838be6449741fd178fc43aba Mon Sep 17 00:00:00 2001 From: Kamran Asif Date: Wed, 3 Aug 2016 16:52:15 -0400 Subject: [PATCH] Fixing column drag scroll with cell recycling (#40) * Fixing column drag scroll with cell recycling * Adding horizontal scroll callback * CR --- examples/ReorderExample.js | 1 + src/FixedDataTable.js | 5 +++++ src/FixedDataTableCellDefault.js | 3 ++- src/FixedDataTableCellGroup.js | 3 ++- src/FixedDataTableColumnReorderHandle.js | 8 ++++++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/ReorderExample.js b/examples/ReorderExample.js index 91c41e22..88c89447 100644 --- a/examples/ReorderExample.js +++ b/examples/ReorderExample.js @@ -96,6 +96,7 @@ class ReorderExample extends React.Component { {...this.props}> {this.state.columnOrder.map(function (columnKey, i) { return = 0)) { var key = 'cell_' + i; diff --git a/src/FixedDataTableColumnReorderHandle.js b/src/FixedDataTableColumnReorderHandle.js index 30d42f2a..1821fede 100644 --- a/src/FixedDataTableColumnReorderHandle.js +++ b/src/FixedDataTableColumnReorderHandle.js @@ -54,6 +54,8 @@ var FixedDataTableColumnReorderHandle = React.createClass({ componentWillUnmount() { if (this._mouseMoveTracker) { + cancelAnimationFrame(this.frameId); + this.frameId = null; this._mouseMoveTracker.releaseMouseMoves(); this._mouseMoveTracker = null; } @@ -101,7 +103,7 @@ var FixedDataTableColumnReorderHandle = React.createClass({ this._distance = 0; this._animating = true; - requestAnimationFrame(this._updateState); + this.frameId = requestAnimationFrame(this._updateState); }, _onMove(/*number*/ deltaX) { @@ -110,13 +112,15 @@ var FixedDataTableColumnReorderHandle = React.createClass({ _onColumnReorderEnd() { this._animating = false; + cancelAnimationFrame(this.frameId); + this.frameId = null; this._mouseMoveTracker.releaseMouseMoves(); this.props.onColumnReorderEnd(); }, _updateState() { if (this._animating) { - requestAnimationFrame(this._updateState) + this.frameId = requestAnimationFrame(this._updateState) } this.setState({ dragDistance: this._distance