fix(core): wait until nodes are initialized
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,10 @@ export default (state: State, getters: ComputedGetters) => {
|
|||||||
|
|
||||||
const { getNodes } = $(getters)
|
const { getNodes } = $(getters)
|
||||||
|
|
||||||
|
const nodesInitialized = computed(() => nodes.filter((node) => node.initialized).length === nodes.length)
|
||||||
|
|
||||||
|
const isReady = computed(() => !!d3Zoom && !!d3Selection && !!dimensions.width && !!dimensions.height && nodesInitialized.value)
|
||||||
|
|
||||||
function zoom(scale: number, duration?: number) {
|
function zoom(scale: number, duration?: number) {
|
||||||
if (d3Selection && d3Zoom) {
|
if (d3Selection && d3Zoom) {
|
||||||
d3Zoom.scaleBy(transition(d3Selection, duration), scale)
|
d3Zoom.scaleBy(transition(d3Selection, duration), scale)
|
||||||
@@ -45,7 +49,7 @@ export default (state: State, getters: ComputedGetters) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return computed<ExtendedViewport>(() => {
|
return computed<ExtendedViewport>(() => {
|
||||||
if (d3Zoom && d3Selection && dimensions.width && dimensions.height) {
|
if (isReady.value) {
|
||||||
return {
|
return {
|
||||||
initialized: true,
|
initialized: true,
|
||||||
zoomIn: (options) => {
|
zoomIn: (options) => {
|
||||||
|
|||||||
@@ -7,18 +7,16 @@ const { id, viewport, emits, d3Zoom, d3Selection, dimensions, ...rest } = useVue
|
|||||||
until(() => d3Zoom.value && d3Selection.value && dimensions.value.width > 0 && dimensions.value.height > 0)
|
until(() => d3Zoom.value && d3Selection.value && dimensions.value.width > 0 && dimensions.value.height > 0)
|
||||||
.toBeTruthy()
|
.toBeTruthy()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setTimeout(() => {
|
// emit pane ready event
|
||||||
// emit pane ready event
|
emits.paneReady({
|
||||||
emits.paneReady({
|
id,
|
||||||
id,
|
viewport,
|
||||||
viewport,
|
emits,
|
||||||
emits,
|
d3Zoom,
|
||||||
d3Zoom,
|
d3Selection,
|
||||||
d3Selection,
|
dimensions,
|
||||||
dimensions,
|
...rest,
|
||||||
...rest,
|
})
|
||||||
})
|
|
||||||
}, 1)
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user