Emoji: stretching from one side does not resize (only shrink works on side handles) #119
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_whiteboard#119
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Drag a side handle of an emoji selection to enlarge it (e.g. drag the right edge outward) — nothing happens, the emoji stays the same size. Dragging a side handle inward to shrink works. Corner drags work in both directions.
Steps to reproduce
Expected
Emoji grows (with aspect ratio preserved).
Actual
Emoji size doesn't change.
Root cause
crates/hero_whiteboard_ui/static/web/js/whiteboard/objects.js::applyTransformfortype === 'emoji'usesMath.min(scaleX, scaleY)to pick a uniform scale (so the glyph isn't squashed):When the user drags one side handle, the perpendicular axis stays at scale 1. So:
scaleX = 0.5, scaleY = 1) →min(0.5, 1) = 0.5✓ (emoji shrinks)scaleX = 2.0, scaleY = 1) →min(2.0, 1) = 1.0✗ (no change)The
minpicks the wrong axis when one side is at 1 and the other has been pulled > 1.Fix
Pick whichever axis moved further from 1 — i.e. the axis the user actually dragged:
Both side and corner drags now resize correctly in both directions, while still applying a single uniform scale so the emoji glyph isn't squashed.
Implementation Spec for Issue #119
Objective
Side-handle resize of an emoji must work in both directions (stretch and shrink), with aspect ratio preserved. Today only shrinking works on side handles; stretching does nothing because the math picks the unmoved axis.
Root cause recap
objects.js::applyTransformfortype === 'emoji'doesvar s = Math.min(scaleX, scaleY). When a single side handle is dragged, the perpendicular axis stays at scale 1, so:min(<1, 1) = <1✓min(>1, 1) = 1✗Fix
Pick whichever axis moved further from 1 — that is the axis the user actually dragged. This preserves the "single uniform scale" intent (no squashing) while always reflecting the user's drag.
Files to Modify
crates/hero_whiteboard_ui/static/web/js/whiteboard/objects.js— replace theMath.minline in thetype === 'emoji'branch with a dominant-axis pick.Implementation Plan
Step 1: Pick the dominant scale axis
File:
crates/hero_whiteboard_ui/static/web/js/whiteboard/objects.jsReplace:
with:
Dependencies: none.
Acceptance Criteria
cargo fmt,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --libclean.Notes
scaleX = 1.5, scaleY = 1.2) will resize using the larger movement (1.5). That matches the user's gesture intent and keeps aspect ratio preserved.Test Results
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test --workspace --lib— 0 failednode --check objects.js— cleanImplementation Summary
objects.js::applyTransformfortype === 'emoji'was usingMath.min(scaleX, scaleY)to pick a uniform scale factor. With single-side handle drags the perpendicular axis stays at 1, so a stretch (scaleX = 2, scaleY = 1) collapsed tomin = 1— no resize. Shrinks (scaleX = 0.5, scaleY = 1) worked becausemin = 0.5.crates/hero_whiteboard_ui/static/web/js/whiteboard/objects.jsReplaced the
Math.minline with a dominant-axis pick:Whichever axis moved further from 1 wins — that's the axis the user actually dragged. The 8-pixel font-size floor and the bg width/height refresh from the rendered glyph stay unchanged.
Files Changed
crates/hero_whiteboard_ui/static/web/js/whiteboard/objects.js—+5 / -3Test Results
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test --workspace --lib— 0 failednode --check objects.js— cleanManual smoke
Notes
scaleX = 1.5, scaleY = 1.2) picks the larger movement (1.5). That matches user intent and keeps aspect ratio uniform.