From dd6111435013d3ca6c47c5b833994f1eabfc746c Mon Sep 17 00:00:00 2001 From: Fun <360603837@qq.com> Date: Fri, 15 May 2020 14:54:32 +0800 Subject: [PATCH] =?UTF-8?q?#477=E3=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Draggable.js | 8 ++++---- lib/DraggableCore.js | 10 +++++----- lib/utils/positionFns.js | 9 ++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/Draggable.js b/lib/Draggable.js index 74e68539..a7c01bba 100644 --- a/lib/Draggable.js +++ b/lib/Draggable.js @@ -179,14 +179,14 @@ class Draggable extends React.Component { // Set x/y if a new position is provided in props that is different than the previous. if ( position && - (!prevPropsPosition || + (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y ) ) { log('Draggable: getDerivedStateFromProps %j', {position, prevPropsPosition}); return { - x: position.x, - y: position.y, + x: position.x, + y: position.y, prevPropsPosition: {...position} }; } @@ -373,7 +373,7 @@ class Draggable extends React.Component { // Reuse the child provided // This makes it flexible to use whatever element is wanted (div, ul, etc) return ( - + {React.cloneElement(React.Children.only(children), { className: className, style: {...children.props.style, ...style}, diff --git a/lib/DraggableCore.js b/lib/DraggableCore.js index 62da91f3..e1ee7b34 100644 --- a/lib/DraggableCore.js +++ b/lib/DraggableCore.js @@ -110,7 +110,7 @@ export default class DraggableCore extends React.Component's events export function createDraggableData(draggable: Draggable, coreData: DraggableData): DraggableData { - const scale = draggable.props.scale; return { node: coreData.node, - x: draggable.state.x + (coreData.deltaX / scale), - y: draggable.state.y + (coreData.deltaY / scale), - deltaX: (coreData.deltaX / scale), - deltaY: (coreData.deltaY / scale), + x: draggable.state.x + coreData.deltaX, + y: draggable.state.y + coreData.deltaY, + deltaX: coreData.deltaX, + deltaY: coreData.deltaY, lastX: draggable.state.x, lastY: draggable.state.y };