feat(document): internal scroll and stop auto-growing on edit #75

Merged
AhmedHanafy725 merged 1 commit from development_document_scroll_no_autoresize into development 2026-04-23 14:20:26 +00:00
Member

Summary

Document elements now respect the size the user chose and expose a vertical scroll for overflowing content.

Closes #73

Changes

  • crates/hero_whiteboard_ui/static/web/js/whiteboard/objects.js
    • Auto-grow removed. renderDocumentContent no longer mutates bg.height() to fit content. User size is authoritative; editMarkdownText, rerenderDocument, and remote sync re-renders all stop enlarging the element.
    • Scroll state on the group. createDocument initializes _scrollY / _contentHeight and attaches _docMaxScroll / _docSetScrollY / _docClampScroll. _docSetScrollY clamps, repositions every md-line-* child by its stamped _baseY - _scrollY, updates the scrollbar thumb, and batchDraws.
    • Wheel interception. Group-level wheel handler consumes deltaY when the document overflows (and cancels bubbling so the stage pan/zoom does not fire). Passes through when content fits.
    • Konva scrollbar. renderDocumentContent rebuilds a .scrollbar-track + draggable .scrollbar-thumb on the right edge whenever content overflows. dragBoundFunc constrains the thumb to the track; dragmove converts position back to _scrollY. Hides when content fits.
    • Resize re-clamp. applyTransform for documents drops the now no-op skipAutoGrow flag and calls _docClampScroll after re-render so enlarging pulls scroll back to 0 and shrinking reveals hidden content.

Architecture

Konva-only — no HTML overlay. Existing clipFunc on the document group already clips rounded corners; the scroll offset moves only md-line-* children (scrollbar chrome stays pinned). Scroll offset is transient per-client view state and is not serialized.

Test Results

  • cargo check --workspace: pass
  • cargo clippy --workspace -- -D warnings: pass
  • cargo fmt --check: pass

Manual QA required: add a long document, scroll via wheel and thumb drag, edit to confirm no auto-grow, resize via transformer and confirm scroll re-clamps.

## Summary Document elements now respect the size the user chose and expose a vertical scroll for overflowing content. ## Related Issue Closes https://forge.ourworld.tf/lhumina_code/hero_whiteboard/issues/73 ## Changes - `crates/hero_whiteboard_ui/static/web/js/whiteboard/objects.js` - **Auto-grow removed.** `renderDocumentContent` no longer mutates `bg.height()` to fit content. User size is authoritative; `editMarkdownText`, `rerenderDocument`, and remote sync re-renders all stop enlarging the element. - **Scroll state on the group.** `createDocument` initializes `_scrollY` / `_contentHeight` and attaches `_docMaxScroll` / `_docSetScrollY` / `_docClampScroll`. `_docSetScrollY` clamps, repositions every `md-line-*` child by its stamped `_baseY - _scrollY`, updates the scrollbar thumb, and batchDraws. - **Wheel interception.** Group-level `wheel` handler consumes `deltaY` when the document overflows (and cancels bubbling so the stage pan/zoom does not fire). Passes through when content fits. - **Konva scrollbar.** `renderDocumentContent` rebuilds a `.scrollbar-track` + draggable `.scrollbar-thumb` on the right edge whenever content overflows. `dragBoundFunc` constrains the thumb to the track; `dragmove` converts position back to `_scrollY`. Hides when content fits. - **Resize re-clamp.** `applyTransform` for documents drops the now no-op `skipAutoGrow` flag and calls `_docClampScroll` after re-render so enlarging pulls scroll back to 0 and shrinking reveals hidden content. ## Architecture Konva-only — no HTML overlay. Existing `clipFunc` on the document group already clips rounded corners; the scroll offset moves only `md-line-*` children (scrollbar chrome stays pinned). Scroll offset is transient per-client view state and is not serialized. ## Test Results - `cargo check --workspace`: pass - `cargo clippy --workspace -- -D warnings`: pass - `cargo fmt --check`: pass Manual QA required: add a long document, scroll via wheel and thumb drag, edit to confirm no auto-grow, resize via transformer and confirm scroll re-clamps.
feat(document): internal scroll and stop auto-growing on edit
All checks were successful
CI / build (pull_request) Successful in 2m11s
cf8bf4d9f8
Document elements now respect the size the user chose and expose a
vertical scroll for overflowing content, via three changes in
renderDocumentContent and createDocument:

- Auto-grow removed. renderDocumentContent no longer mutates bg.height
  to fit content. User size (from the default or from the transformer
  resize) is authoritative; editMarkdownText, rerenderDocument, and
  remote sync re-renders all stop enlarging the element.

- Scroll state on the group. createDocument initialises _scrollY and
  _contentHeight and attaches _docMaxScroll / _docSetScrollY /
  _docClampScroll. SetScrollY clamps, repositions every md-line-*
  child by its stamped _baseY minus _scrollY, updates the scrollbar
  thumb, and batchDraws.

- Wheel interception. A wheel handler on the group consumes deltaY
  when the document overflows (and cancels bubbling so the stage pan
  does not fire); passes through otherwise.

- Scrollbar. renderDocumentContent now rebuilds a track + draggable
  thumb on the right edge when content overflows, with a dragBoundFunc
  constraining the thumb to the track. On dragmove the thumb position
  is converted back into _scrollY. Hides when content fits.

- Resize re-clamp. applyTransform for documents drops the now
  no-op skipAutoGrow flag and calls _docClampScroll after re-render
  so enlarging pulls scroll back to 0 and shrinking reveals hidden
  content.

#73
AhmedHanafy725 merged commit 552c830faf into development 2026-04-23 14:20:26 +00:00
AhmedHanafy725 deleted branch development_document_scroll_no_autoresize 2026-04-23 14:20:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_whiteboard!75
No description provided.