Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(background): set default offset to 0 #1692

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kind-eels-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vue-flow/background": patch
---

Set default offset value to `0`
1 change: 0 additions & 1 deletion examples/vite/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

body {
color: #111;
padding: 5px;
}

#root {
Expand Down
12 changes: 5 additions & 7 deletions packages/background/src/Background.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ const {
bgColor,
patternColor: initialPatternColor,
color: _patternColor,
offset = 2,
offset = 0,
} = defineProps<BackgroundProps>()

const { id: vueFlowId, viewport } = useVueFlow()

const background = computed(() => {
const zoom = viewport.value.zoom
const [gapX, gapY] = Array.isArray(gap) ? gap : [gap, gap]
const scaledGap: [number, number] = [gapX * viewport.value.zoom || 1, gapY * viewport.value.zoom || 1]
const scaledSize = size * viewport.value.zoom
const scaledGap: [number, number] = [gapX * zoom || 1, gapY * zoom || 1]
const scaledSize = size * zoom
const [offsetX, offsetY]: [number, number] = Array.isArray(offset) ? offset : [offset, offset]

const scaledOffset: [number, number] = [
offsetX * viewport.value.zoom || 1 + scaledGap[0] / 2,
offsetY * viewport.value.zoom || 1 + scaledGap[1] / 2,
]
const scaledOffset: [number, number] = [offsetX * zoom || 1 + scaledGap[0] / 2, offsetY * zoom || 1 + scaledGap[1] / 2]

return {
scaledGap,
Expand Down
Loading