fix: scroll bounce
This commit is contained in:
1 parent
ec0cfb76fd
commit
f7c0e1ed1e
4 files changed
+120
-98
No files matched your search
@@ -45,16 +45,18 @@
|
||||
tabindex="-1"
|
||||
aria-label={t().spell.suggestions}
|
||||
>
|
||||
{#if suggestions.length}
|
||||
{#each suggestions as s}
|
||||
<button class="sm-item sm-suggest" role="menuitem" onclick={() => onReplace(s)}>{s}</button>
|
||||
{/each}
|
||||
{:else}
|
||||
<span class="sm-empty">{t().spell.noSuggestions}</span>
|
||||
{/if}
|
||||
<span class="sm-sep"></span>
|
||||
<button class="sm-item" role="menuitem" onclick={onAdd}>{t().spell.addToDictionary}</button>
|
||||
<button class="sm-item" role="menuitem" onclick={onIgnore}>{t().spell.ignoreAll}</button>
|
||||
<div class="menu-scroll">
|
||||
{#if suggestions.length}
|
||||
{#each suggestions as s}
|
||||
<button class="sm-item sm-suggest" role="menuitem" onclick={() => onReplace(s)}>{s}</button>
|
||||
{/each}
|
||||
{:else}
|
||||
<span class="sm-empty">{t().spell.noSuggestions}</span>
|
||||
{/if}
|
||||
<span class="sm-sep"></span>
|
||||
<button class="sm-item" role="menuitem" onclick={onAdd}>{t().spell.addToDictionary}</button>
|
||||
<button class="sm-item" role="menuitem" onclick={onIgnore}>{t().spell.ignoreAll}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@@ -63,7 +65,7 @@
|
||||
z-index: 200;
|
||||
min-width: 11rem;
|
||||
max-height: 18rem;
|
||||
overflow-y: auto;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 4px;
|
||||
|
||||
@@ -212,36 +212,38 @@
|
||||
</button>
|
||||
{#if stylesOpen}
|
||||
<div class="ol-dropdown style-dropdown" role="menu">
|
||||
<div class="ol-section-label">{t().toolbar.styles.title}</div>
|
||||
{#each galleryStyles as s}
|
||||
{@const preview = resolveStyle(sheet, s.name)}
|
||||
<button
|
||||
class="ol-option style-option"
|
||||
class:active={currentStyle === s.name}
|
||||
onclick={() => applyStyle(s.name)}
|
||||
role="menuitemradio"
|
||||
aria-checked={currentStyle === s.name}
|
||||
style="font-size: {previewSize(s.name)}; font-weight: {preview.text.bold ? 600 : 400}; font-style: {preview.text.italic ? 'italic' : 'normal'}"
|
||||
>
|
||||
{styleLabel(s.name)}
|
||||
</button>
|
||||
{/each}
|
||||
{#if charStyles.length}
|
||||
<div class="ol-section-label char-label">{t().styles.characterStyles}</div>
|
||||
{#each charStyles as c}
|
||||
{@const preview = resolveStyle(sheet, c.name, 'character')}
|
||||
<div class="menu-scroll">
|
||||
<div class="ol-section-label">{t().toolbar.styles.title}</div>
|
||||
{#each galleryStyles as s}
|
||||
{@const preview = resolveStyle(sheet, s.name)}
|
||||
<button
|
||||
class="ol-option style-option"
|
||||
class:active={currentCharStyle === c.name}
|
||||
onclick={() => applyCharStyle(c.name)}
|
||||
class:active={currentStyle === s.name}
|
||||
onclick={() => applyStyle(s.name)}
|
||||
role="menuitemradio"
|
||||
aria-checked={currentCharStyle === c.name}
|
||||
style="font-weight: {preview.text.bold ? 600 : 400}; font-style: {preview.text.italic ? 'italic' : 'normal'}; font-family: {preview.text.fontFamily ?? 'inherit'}"
|
||||
aria-checked={currentStyle === s.name}
|
||||
style="font-size: {previewSize(s.name)}; font-weight: {preview.text.bold ? 600 : 400}; font-style: {preview.text.italic ? 'italic' : 'normal'}"
|
||||
>
|
||||
{c.name}
|
||||
{styleLabel(s.name)}
|
||||
</button>
|
||||
{/each}
|
||||
{/if}
|
||||
{#if charStyles.length}
|
||||
<div class="ol-section-label char-label">{t().styles.characterStyles}</div>
|
||||
{#each charStyles as c}
|
||||
{@const preview = resolveStyle(sheet, c.name, 'character')}
|
||||
<button
|
||||
class="ol-option style-option"
|
||||
class:active={currentCharStyle === c.name}
|
||||
onclick={() => applyCharStyle(c.name)}
|
||||
role="menuitemradio"
|
||||
aria-checked={currentCharStyle === c.name}
|
||||
style="font-weight: {preview.text.bold ? 600 : 400}; font-style: {preview.text.italic ? 'italic' : 'normal'}; font-family: {preview.text.fontFamily ?? 'inherit'}"
|
||||
>
|
||||
{c.name}
|
||||
</button>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
<button class="ol-option manage" onclick={() => { stylesOpen = false; managerOpen = true; }}>
|
||||
<!-- Sliders, as on the Tools button: this opens a settings surface -->
|
||||
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||
@@ -475,10 +477,11 @@
|
||||
}
|
||||
|
||||
/* The gallery lists every registered style, so it scrolls inside itself like the
|
||||
font picker instead of growing past the viewport. */
|
||||
font picker instead of growing past the viewport. The panel itself never
|
||||
scrolls, so an overscroll bounce can't drag its background off the frame. */
|
||||
.style-dropdown {
|
||||
max-height: 360px;
|
||||
overflow-y: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.char-label {
|
||||
@@ -486,13 +489,12 @@
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
/* Pinned to the scrolling gallery's bottom edge (bottom cancels the dropdown's
|
||||
padding) so it is reachable without scrolling to the last style. */
|
||||
/* Sits below the scrolling gallery (margins cancel the dropdown's padding) so it
|
||||
is reachable without scrolling to the last style. */
|
||||
.manage {
|
||||
position: sticky;
|
||||
bottom: -2px;
|
||||
margin-top: 2px;
|
||||
padding: 0.45rem 0.6rem calc(0.45rem + 2px);
|
||||
flex-shrink: 0;
|
||||
margin: 2px -2px -2px;
|
||||
padding: 0.45rem 0.6rem;
|
||||
gap: 0.45rem;
|
||||
background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
|
||||
border-top: 1px solid var(--color-border);
|
||||
|
||||
@@ -955,9 +955,21 @@
|
||||
</button>
|
||||
{#if fontOpen}
|
||||
<div class="font-dropdown">
|
||||
{#if recentFonts.length > 0}
|
||||
<div class="font-section-label">{t().toolbarExpanded.recent}</div>
|
||||
{#each recentFonts as font}
|
||||
<div class="menu-scroll">
|
||||
{#if recentFonts.length > 0}
|
||||
<div class="font-section-label">{t().toolbarExpanded.recent}</div>
|
||||
{#each recentFonts as font}
|
||||
<button
|
||||
class="font-option"
|
||||
class:active={currentFont === font}
|
||||
style="font-family: {font}"
|
||||
onclick={() => pickFont(font)}
|
||||
>{font}</button>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<div class="font-section-label">{t().toolbarExpanded.webSafe}</div>
|
||||
{#each WEB_SAFE_FONTS as font}
|
||||
<button
|
||||
class="font-option"
|
||||
class:active={currentFont === font}
|
||||
@@ -965,35 +977,25 @@
|
||||
onclick={() => pickFont(font)}
|
||||
>{font}</button>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<div class="font-section-label">{t().toolbarExpanded.webSafe}</div>
|
||||
{#each WEB_SAFE_FONTS as font}
|
||||
<button
|
||||
class="font-option"
|
||||
class:active={currentFont === font}
|
||||
style="font-family: {font}"
|
||||
onclick={() => pickFont(font)}
|
||||
>{font}</button>
|
||||
{/each}
|
||||
{#if extraFontsList.length > 0}
|
||||
<div class="font-section-label">{t().toolbarExpanded.allFonts}</div>
|
||||
{#each extraFontsList as font}
|
||||
<button
|
||||
class="font-option"
|
||||
class:active={currentFont === font}
|
||||
style="font-family: {font}"
|
||||
onclick={() => pickFont(font)}
|
||||
>{font}</button>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if extraFontsList.length > 0}
|
||||
<div class="font-section-label">{t().toolbarExpanded.allFonts}</div>
|
||||
{#each extraFontsList as font}
|
||||
<button
|
||||
class="font-option"
|
||||
class:active={currentFont === font}
|
||||
style="font-family: {font}"
|
||||
onclick={() => pickFont(font)}
|
||||
>{font}</button>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if localFontAccessSupported && !allInstalledFonts}
|
||||
<button class="font-show-all" onclick={showAllInstalledFonts}>
|
||||
{t().toolbarExpanded.loadAllFonts}
|
||||
</button>
|
||||
{/if}
|
||||
{#if localFontAccessSupported && !allInstalledFonts}
|
||||
<button class="font-show-all" onclick={showAllInstalledFonts}>
|
||||
{t().toolbarExpanded.loadAllFonts}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1018,14 +1020,16 @@
|
||||
</div>
|
||||
{#if sizeOpen}
|
||||
<div class="size-dropdown">
|
||||
<div class="lh-section-label">{t().toolbarExpanded.fontSize}</div>
|
||||
{#each FONT_SIZES as size}
|
||||
<button
|
||||
class="size-option"
|
||||
class:active={currentFontSize === `${size}pt`}
|
||||
onclick={() => pickSize(size)}
|
||||
>{size}</button>
|
||||
{/each}
|
||||
<div class="menu-scroll">
|
||||
<div class="lh-section-label">{t().toolbarExpanded.fontSize}</div>
|
||||
{#each FONT_SIZES as size}
|
||||
<button
|
||||
class="size-option"
|
||||
class:active={currentFontSize === `${size}pt`}
|
||||
onclick={() => pickSize(size)}
|
||||
>{size}</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1187,13 +1191,15 @@
|
||||
</div>
|
||||
{#if spaceBeforeOpen}
|
||||
<div class="sp-dropdown">
|
||||
{#each SPACING_PRESETS as v}
|
||||
<button
|
||||
class="sp-option"
|
||||
class:active={currentSpaceBefore === v}
|
||||
onclick={() => pickSpacePreset('before', v)}
|
||||
>{spacingLabel(v)}</button>
|
||||
{/each}
|
||||
<div class="menu-scroll">
|
||||
{#each SPACING_PRESETS as v}
|
||||
<button
|
||||
class="sp-option"
|
||||
class:active={currentSpaceBefore === v}
|
||||
onclick={() => pickSpacePreset('before', v)}
|
||||
>{spacingLabel(v)}</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1220,13 +1226,15 @@
|
||||
</div>
|
||||
{#if spaceAfterOpen}
|
||||
<div class="sp-dropdown">
|
||||
{#each SPACING_PRESETS as v}
|
||||
<button
|
||||
class="sp-option"
|
||||
class:active={currentSpaceAfter === v}
|
||||
onclick={() => pickSpacePreset('after', v)}
|
||||
>{spacingLabel(v)}</button>
|
||||
{/each}
|
||||
<div class="menu-scroll">
|
||||
{#each SPACING_PRESETS as v}
|
||||
<button
|
||||
class="sp-option"
|
||||
class:active={currentSpaceAfter === v}
|
||||
onclick={() => pickSpacePreset('after', v)}
|
||||
>{spacingLabel(v)}</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1719,7 +1727,7 @@
|
||||
left: 0;
|
||||
min-width: 100%;
|
||||
max-height: 360px;
|
||||
overflow-y: auto;
|
||||
overflow: hidden;
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
@@ -1863,7 +1871,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 260px;
|
||||
overflow-y: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.size-option {
|
||||
@@ -2259,7 +2267,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sp-option {
|
||||
|
||||
@@ -239,6 +239,16 @@
|
||||
animation: menu-in 0.14s ease;
|
||||
}
|
||||
|
||||
/* Scrolling body of a popup menu. Only this inner box scrolls; the panel keeps
|
||||
the background and frame, so the elastic overscroll bounce can't drag the
|
||||
background off the border and show the page through the gap. */
|
||||
.menu-scroll {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.toolbar-region button:active:not(:disabled) { transform: none; }
|
||||
.theme-dropdown, .ol-dropdown, .align-dropdown, .font-dropdown, .size-dropdown,
|
||||
|
||||
Reference in new issue
Block a user