Skip to content

Commit 1635a45

Browse files
committed
fix(BaseSwitch): also animate width to prevent layout shift
1 parent 6500b79 commit 1635a45

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

frontend/.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"BaseNavigation",
44
"BaseNavigationLeft",
55
"BaseSearchInput",
6+
"BaseSwitch",
67
"BcButton",
78
"BcDataWrapper",
89
"BcFormatAmount",

frontend/layers/base/app/components/BaseSwitch.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ const moveThumb = () => {
2727
if (!thumb) return
2828
2929
const { x: initialX } = thumb.getBoundingClientRect()
30-
const { x } = activeTrackItem.getBoundingClientRect()
30+
const {
31+
width,
32+
x,
33+
} = activeTrackItem.getBoundingClientRect()
3134
3235
// this should rather have been done via view transition api
3336
// but it currently lacks `firefox support`
3437
// and also there was a flickering issue
3538
const animation = thumb.animate([ {
3639
transform: `translateX(${x - initialX}px)`,
40+
width: `${width}px`,
3741
} ],
3842
{ duration: 180 },
3943
)
@@ -49,7 +53,9 @@ watch(modelValue, () => {
4953
</script>
5054

5155
<template>
52-
<fieldset class="isolate">
56+
<fieldset
57+
class="isolate"
58+
>
5359
<legend class="sr-only">
5460
{{ $t(screenreaderTitle as string) }}
5561
</legend>

0 commit comments

Comments
 (0)