diff --git a/src/App.vue b/src/App.vue index f13a5f65..f0402ea2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@ diff --git a/src/additional-components/Background/index.tsx b/src/additional-components/Background/index.tsx index c1f7c9a2..6abff8f2 100644 --- a/src/additional-components/Background/index.tsx +++ b/src/additional-components/Background/index.tsx @@ -41,20 +41,22 @@ const Background = defineComponent({ }, setup(props) { const pinia = store(); - const [x, y, scale] = pinia.transform; + const transform = computed(() => pinia.transform); // when there are multiple flows on a page we need to make sure that every background gets its own pattern. - const patternId = computed(() => `pattern-${Math.floor(Math.random() * 100000)}`); + const patternId = `pattern-${Math.floor(Math.random() * 100000)}`; const bgClasses = ['react-flow__background']; - const scaledGap = props.gap || 15 * scale; - const xOffset = x % scaledGap; - const yOffset = y % scaledGap; + const scaledGap = computed(() => props.gap && props.gap * transform.value[2]); + const xOffset = computed(() => scaledGap.value && transform.value[0] % scaledGap.value); + const yOffset = computed(() => scaledGap.value && transform.value[1] % scaledGap.value); const isLines = props.variant === BackgroundVariant.Lines; const bgColor = props.color ? props.color : defaultColors[props.variant || BackgroundVariant.Dots]; - const path = isLines - ? createGridLinesPath(scaledGap, props.size || 0.4, bgColor) - : createGridDotsPath(props.size || 0.4 * scale, bgColor); + const path = computed(() => + isLines + ? scaledGap.value && props.size && createGridLinesPath(scaledGap.value, props.size, bgColor) + : createGridDotsPath(props.size || 0.4 * transform.value[2], bgColor) + ); return () => ( - - {path} + + {path.value} - + ); }