Skip to content

Commit 502a2e7

Browse files
committed
🩹 Remove element panel flicker when transforming text displays
1 parent 0ab4199 commit 502a2e7

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

src/components/textDisplayElementPanel.svelte

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@
4242
4343
let codeJarElement: HTMLPreElement | undefined
4444
45-
let lineWidthSlot: HTMLDivElement
46-
let backgroundColorSlot: HTMLDivElement
47-
let shadowSlot: HTMLDivElement
48-
let alignmentSlot: HTMLDivElement
49-
let seeThroughSlot: HTMLDivElement
50-
let copyTextSlot: HTMLDivElement
51-
5245
let unsubFromText: (() => void) | undefined
5346
5447
const unsubFromEvent = EVENTS.UPDATE_SELECTION.subscribe(() => {
@@ -79,13 +72,26 @@
7972
})
8073
})
8174
75+
const mountLineWidth = (node: HTMLDivElement) => {
76+
node.appendChild(TEXT_DISPLAY_WIDTH_SLIDER.node)
77+
}
78+
const mountShadow = (node: HTMLDivElement) => {
79+
node.appendChild(TEXT_DISPLAY_SHADOW_TOGGLE.node)
80+
}
81+
const mountAlignment = (node: HTMLDivElement) => {
82+
node.appendChild(TEXT_DISPLAY_ALIGNMENT_SELECT.node)
83+
}
84+
const mountSeeThrough = (node: HTMLDivElement) => {
85+
node.appendChild(TEXT_DISPLAY_SEE_THROUGH_TOGGLE.node)
86+
}
87+
const mountBackgroundColor = (node: HTMLDivElement) => {
88+
node.appendChild(TEXT_DISPLAY_BACKGROUND_COLOR_PICKER.node)
89+
}
90+
const mountCopyText = (node: HTMLDivElement) => {
91+
node.appendChild(TEXT_DISPLAY_COPY_TEXT_ACTION.node)
92+
}
93+
8294
requestAnimationFrame(() => {
83-
lineWidthSlot.appendChild(TEXT_DISPLAY_WIDTH_SLIDER.node)
84-
backgroundColorSlot.appendChild(TEXT_DISPLAY_BACKGROUND_COLOR_PICKER.node)
85-
shadowSlot.appendChild(TEXT_DISPLAY_SHADOW_TOGGLE.node)
86-
alignmentSlot.appendChild(TEXT_DISPLAY_ALIGNMENT_SELECT.node)
87-
seeThroughSlot.appendChild(TEXT_DISPLAY_SEE_THROUGH_TOGGLE.node)
88-
copyTextSlot.appendChild(TEXT_DISPLAY_COPY_TEXT_ACTION.node)
8995
forceNoWrap()
9096
})
9197
@@ -122,12 +128,12 @@
122128
class="toolbar text-display-toolbar"
123129
style={!!selected ? '' : 'visibility:hidden; height: 0px;'}
124130
>
125-
<div class="content" bind:this={lineWidthSlot} />
126-
<div class="content" bind:this={backgroundColorSlot} />
127-
<div class="content" bind:this={shadowSlot} />
128-
<div class="content" bind:this={alignmentSlot} />
129-
<div class="content" bind:this={seeThroughSlot} />
130-
<div class="content" bind:this={copyTextSlot} />
131+
<div class="content" use:mountLineWidth />
132+
<div class="content" use:mountShadow />
133+
<div class="content" use:mountAlignment />
134+
<div class="content" use:mountSeeThrough />
135+
<div class="content" use:mountBackgroundColor />
136+
<div class="content" use:mountCopyText />
131137
</div>
132138

133139
<div

0 commit comments

Comments
 (0)