forked from profectus/Profectus
Update node bounds whenever a node is registered or unregistered
This commit is contained in:
parent
11662e248f
commit
6784fbaf51
1 changed files with 2 additions and 3 deletions
|
@ -56,13 +56,12 @@ provide(RegisterNodeInjectionKey, (id, element) => {
|
||||||
const observer = new MutationObserver(() => updateNode(id));
|
const observer = new MutationObserver(() => updateNode(id));
|
||||||
observer.observe(element, observerOptions);
|
observer.observe(element, observerOptions);
|
||||||
nodes.value[id] = { element, observer, rect: element.getBoundingClientRect() };
|
nodes.value[id] = { element, observer, rect: element.getBoundingClientRect() };
|
||||||
emit("updateNodes", nodes.value);
|
updateBounds();
|
||||||
nextTick(() => updateNode(id));
|
|
||||||
});
|
});
|
||||||
provide(UnregisterNodeInjectionKey, id => {
|
provide(UnregisterNodeInjectionKey, id => {
|
||||||
nodes.value[id]?.observer.disconnect();
|
nodes.value[id]?.observer.disconnect();
|
||||||
nodes.value[id] = undefined;
|
nodes.value[id] = undefined;
|
||||||
emit("updateNodes", nodes.value);
|
updateBounds();
|
||||||
});
|
});
|
||||||
provide(NodesInjectionKey, nodes);
|
provide(NodesInjectionKey, nodes);
|
||||||
provide(BoundsInjectionKey, boundingRect);
|
provide(BoundsInjectionKey, boundingRect);
|
||||||
|
|
Loading…
Reference in a new issue