fix(core): add timeout when updating positions after extent changes
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -139,21 +139,16 @@ watch(
|
|||||||
{ flush: 'pre', immediate: true },
|
{ flush: 'pre', immediate: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
watch(
|
watch([() => node.extent, () => nodeExtent], ([nodeExtent, globalExtent], [oldNodeExtent, oldGlobalExtent]) => {
|
||||||
[() => node.extent, () => nodeExtent],
|
// update position if extent has actually changed
|
||||||
([nodeExtent, globalExtent], [oldNodeExtent, oldGlobalExtent]) => {
|
if (nodeExtent !== oldNodeExtent || globalExtent !== oldGlobalExtent) {
|
||||||
// update position if extent has actually changed
|
// todo: can we solve this without a timeout? Otherwise the extent is not properly calculated
|
||||||
if (nodeExtent !== oldNodeExtent || globalExtent !== oldGlobalExtent) {
|
setTimeout(updatePosition)
|
||||||
updatePosition()
|
}
|
||||||
}
|
})
|
||||||
},
|
|
||||||
{ flush: 'pre' },
|
|
||||||
)
|
|
||||||
|
|
||||||
// todo: do we need to wait for initialized? Or can we clamp the position immediately?
|
// clamp initial position to nodes' extent
|
||||||
until(() => node.initialized)
|
updatePosition()
|
||||||
.toBe(true)
|
|
||||||
.then(updatePosition)
|
|
||||||
|
|
||||||
/** this re-calculates the current position, necessary for clamping by a node's extent */
|
/** this re-calculates the current position, necessary for clamping by a node's extent */
|
||||||
function updatePosition() {
|
function updatePosition() {
|
||||||
|
|||||||
Reference in New Issue
Block a user