chore(core): cleanup

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-04-11 20:28:02 +02:00
committed by Braks
parent 27d62b29b7
commit 7a55cb992d
+3 -8
View File
@@ -18,7 +18,6 @@ interface UseDragParams {
} }
function useDrag(params: UseDragParams) { function useDrag(params: UseDragParams) {
const { const {
vueFlowRef, vueFlowRef,
snapToGrid, snapToGrid,
@@ -60,7 +59,7 @@ function useDrag(params: UseDragParams) {
const getPointerPosition = useGetPointerPosition() const getPointerPosition = useGetPointerPosition()
const updateNodes = ({ x, y }: XYPosition, onBeforeUpdate: (position: XYPosition) => XYPosition = (xyPos) => xyPos) => { const updateNodes = ({ x, y }: XYPosition) => {
lastPos = { x, y } lastPos = { x, y }
let hasChange = false let hasChange = false
@@ -73,7 +72,7 @@ function useDrag(params: UseDragParams) {
nextPosition.y = snapGrid[1] * Math.round(nextPosition.y / snapGrid[1]) nextPosition.y = snapGrid[1] * Math.round(nextPosition.y / snapGrid[1])
} }
let { computedPosition } = calcNextPosition( const { computedPosition } = calcNextPosition(
n, n,
nextPosition, nextPosition,
emits.error, emits.error,
@@ -81,8 +80,6 @@ function useDrag(params: UseDragParams) {
n.parentNode ? findNode(n.parentNode) : undefined, n.parentNode ? findNode(n.parentNode) : undefined,
) )
computedPosition = onBeforeUpdate(computedPosition)
// we want to make sure that we only fire a change event when there is a change // we want to make sure that we only fire a change event when there is a change
hasChange = hasChange || n.position.x !== computedPosition.x || n.position.y !== computedPosition.y hasChange = hasChange || n.position.x !== computedPosition.x || n.position.y !== computedPosition.y
@@ -128,10 +125,8 @@ function useDrag(params: UseDragParams) {
Math.round(transform.x) !== Math.round(previousTransform.x) || Math.round(transform.x) !== Math.round(previousTransform.x) ||
Math.round(transform.y) !== Math.round(previousTransform.y) Math.round(transform.y) !== Math.round(previousTransform.y)
) { ) {
previousTransform = transform
updateNodes(nextPos) updateNodes(nextPos)
previousTransform = transform
lastPos = nextPos lastPos = nextPos
} }
}) })