refactor(core): return boolean from panBy

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-05-05 11:02:58 +02:00
committed by Braks
parent 926108f2b7
commit df542208d2
3 changed files with 13 additions and 18 deletions
+3 -11
View File
@@ -55,7 +55,6 @@ function useDrag(params: UseDragParams) {
let autoPanId = $ref(0)
let autoPanStarted = $ref(false)
let previousTransform = $ref<XYPosition>({ x: 0, y: 0 })
const getPointerPosition = useGetPointerPosition()
@@ -120,16 +119,9 @@ function useDrag(params: UseDragParams) {
y: (lastPos.y ?? 0) - yMovement / viewport.zoom,
}
panBy({ x: xMovement, y: yMovement }, (transform) => {
if (
Math.round(transform.x) !== Math.round(previousTransform.x) ||
Math.round(transform.y) !== Math.round(previousTransform.y)
) {
updateNodes(nextPos)
previousTransform = transform
lastPos = nextPos
}
})
if (panBy({ x: xMovement, y: yMovement })) {
updateNodes(nextPos)
}
}
autoPanId = requestAnimationFrame(autoPan)