Skip to content

Commit

Permalink
Text Editor: Fix proxy scrollbar blur causing hard corners, fix proxy…
Browse files Browse the repository at this point in the history
… scrollbar not updating on zoom
  • Loading branch information
ChiriVulpes committed Oct 29, 2024
1 parent 774b5c7 commit 1e695b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/ui/component/core/TextEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Popover from "ui/component/core/Popover"
import RadioButton from "ui/component/core/RadioButton"
import Slot from "ui/component/core/Slot"
import type { Quilt } from "ui/utility/TextManipulator"
import Viewport from "ui/utility/Viewport"
import ViewTransition from "ui/view/component/ViewTransition"
import Arrays from "utility/Arrays"
import Define from "utility/Define"
Expand Down Expand Up @@ -1240,17 +1241,21 @@ const TextEditor = Component.Builder((component): TextEditor => {
})
.appendTo(actualEditor)

const contentWidth = State.Generator(() => `${editor.document?.element.scrollWidth ?? 0}px`)
.observe(component, state, Viewport.size)

const scrollbarProxy: Component = Component()
.style("text-editor-document-scrollbar-proxy")
.style.bind(isFullscreen, "text-editor-document-scrollbar-proxy--fullscreen")
.style.bindVariable("content-width",
state.map(component, () => `${editor.document?.element.scrollWidth ?? 0}px`))
.style.bind(contentWidth.map(component, () => (editor.document?.element.scrollWidth ?? 0) > (editor.document?.rect.value.width ?? 0)), "text-editor-document-scrollbar-proxy--visible")
.style.bindVariable("content-width", contentWidth)
.event.subscribe("scroll", () =>
editor.document?.element.scrollTo({ left: scrollbarProxy.element.scrollLeft, behavior: "instant" }))
.appendTo(actualEditor)

documentSlot.style.bindVariable("content-width",
state.map(component, () => `${documentSlot.element.scrollWidth ?? 0}px`))
const fullscreenContentWidth = State.Generator(() => `${documentSlot.element.scrollWidth ?? 0}px`)
.observe(component, state, Viewport.size)
documentSlot.style.bindVariable("content-width", fullscreenContentWidth)

state.use(editor, state => {
const name = editor.document?.name.value
Expand Down
4 changes: 3 additions & 1 deletion style/component/text-editor.chiri
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@
%sticky
%bottom-0
%overflow-auto-x
%backdrop-blur
%border-bottom-radius-1
scrollbar-colour: $colour-5 transparent
@before:
Expand All @@ -305,6 +304,9 @@
&--fullscreen:
%hidden

&--visible:
%backdrop-blur

&--required:

.text-editor:
Expand Down

0 comments on commit 1e695b7

Please sign in to comment.