Ideogram4 Prompt Builder: make bbox editor usable on mobile. Fixes issue #660 - #661
Open
RoyHammerlin wants to merge 2 commits into
Open
Ideogram4 Prompt Builder: make bbox editor usable on mobile. Fixes issue #660#661RoyHammerlin wants to merge 2 commits into
RoyHammerlin wants to merge 2 commits into
Conversation
What Makes the bounding-box editor in the Ideogram 4 Prompt Builder fully usable on a mobile/touch browser, and gives newly created regions a sensible minimum size. Why The canvas interaction (draw / move / resize), the layers-menu row reorder, and the colour-swatch reorder were all wired to mouse events (mousedown → document mousemove/mouseup). Touch browsers synthesise mousedown/mouseup/ dblclick from a tap, so selecting a region and double-tapping to edit worked, but they do not emit a continuous mousemove stream during a finger drag — so dragging, resizing, and drag-to-draw silently did nothing on mobile. There was also no touch-action rule, so touches were consumed as page scroll / pinch-zoom. Changes (all in web/js/ideogram4_prompt_builder.js) Canvas drag, layer-row reorder, and swatch reorder now use Pointer Events (pointerdown/pointermove/pointerup) with setPointerCapture, covering mouse, touch and pen through one path. touch-action: none on the canvas and on the draggable rows/swatches. Touch/pen double-tap on a region opens the inline editor; double-tap on empty space creates a new default-size region. Mouse keeps using the native dblclick handler. Long-press on the canvas opens the layers menu (the touch equivalent of right-click). New "+ Box" toolbar button — adds a region in the centre to drag/resize. Also covers the case where a full-canvas background region leaves no empty space to draw on. Newly drawn regions are grown to a minimum grabbable size; tap-sized "draws" are discarded rather than left as pixel-thin slivers. Sizes are constants at the top of the file. Compatibility Desktop/mouse behaviour is intentionally unchanged: the mouse drives the same pointer code paths, the hover highlight stays mouse-only, and the native double-click and right-click handlers are preserved. Testing Tested on desktop with a mouse and in a mobile browser with touch: select, move, resize, draw, double-tap-to-edit, long-press menu, reorder, and the new "+ Box" button all behave as expected. (Context: this follows up the mobile issue I reported and the earlier attempt in dc2cc18 — that commit didn't convert the canvas interaction to pointer events, which is the part that actually unblocks touch.)
Lowered speed threshold for double-tap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the bounding-box editor in the Ideogram 4 Prompt Builder fully usable on a mobile/touch browser, and gives newly created regions a sensible minimum size.
Why
The canvas interaction (draw / move / resize), the layers-menu row reorder, and the colour-swatch reorder were all wired to mouse events (mousedown → document mousemove/mouseup). Touch browsers synthesise mousedown/mouseup/ dblclick from a tap, so selecting a region and double-tapping to edit worked, but they do not emit a continuous mousemove stream during a finger drag — so dragging, resizing, and drag-to-draw silently did nothing on mobile. There was also no touch-action rule, so touches were consumed as page scroll / pinch-zoom.
Changes (all in web/js/ideogram4_prompt_builder.js)
Compatibility
Desktop/mouse behaviour is intentionally unchanged: the mouse drives the same pointer code paths, the hover highlight stays mouse-only, and the native double-click and right-click handlers are preserved.
Testing
Tested on desktop with a mouse and in a mobile browser with touch: select, move, resize, draw, double-tap-to-edit, long-press menu, reorder, and the new "+ Box" button all behave as expected.
(Context: this follows up the mobile issue I reported and the earlier attempt in dc2cc18 — that commit didn't convert the canvas interaction to pointer events, which is the part that actually unblocks touch.)