Skip to content

fix: add inverted drag direction option for Y and height draginputs - #164

Open
Zohaib5677 wants to merge 1 commit into
methodofaction:masterfrom
Zohaib5677:fix/draginput-inverted-y-height
Open

Zohaib5677 wants to merge 1 commit into
methodofaction:masterfrom
Zohaib5677:fix/draginput-inverted-y-height

Conversation

@Zohaib5677

Copy link
Copy Markdown

PR DRAFT — methodofaction/Method-Draw

Target: methodofaction/Method-Draw, branch fix/draginput-inverted-y-height → master
Commit: a18ce0d

Title

fix: add inverted drag direction option for Y and height draginputs

Body

Summary

Adds an inverted option to $.fn.dragInput that flips drag, mouse-wheel, and arrow-key direction, and applies it to all Y-position and height fields.

Problem

Dragging a Y or Height draginput vertically moved the shape opposite to the cursor: dragging down decreased Y/height, so the shape moved up while the cursor moved down. The same inversion affected the mouse wheel and arrow keys.

Root Cause

move() in src/js/lib/jquery-draginput.js hard-coded deltaY = (e.pageY - lastY) * -1 ("drag up = increase") for every field. That scrubber convention is wrong for Y-position and height fields because SVG's Y axis grows downward. The wheel and ArrowUp/ArrowDown handlers shared the hard-coded sign.

Solution

  • New inverted config option on $.fn.dragInput (name taken from the issue's proposal): drag delta sign becomes (e.pageY - lastY) * (inverted ? 1 : -1); arrow keys and wheel step flip accordingly. Also removed a duplicated "ArrowDown" key (behavior-preserving — the second definition was already winning).
  • Applied inverted: true to all 16 Y/height draginput initializations in src/js/Panel.js (the live init path via MD.Panel()). X/width fields intentionally unchanged.
  • The stale duplicate initializations in src/js/method-draw.js (not loaded by index.html or the gulp build) were deliberately left untouched.

Testing

  • New QUnit suite test/draginput_test.html (registered in test/all_tests.html), run headlessly against the repo's real jQuery: 4/8 before the fix (the inverted tests failing exactly as the bug predicts), 8/8 after, confirming default-direction fields are unchanged.
  • git diff --check clean.
  • The repo's existing QUnit suite requires a browser (unavailable here); several of its pages reference stale ../editor/ paths (pre-existing, unrelated).

Risk and Compatibility

Low. Opt-in flag; behavior of all non-inverted fields is unchanged (verified by test). The direction change for Y/height fields is intentional and user-visible, per the issue's proposal.

Related Issue

Fixes #163

Dragging a Y or height draginput vertically moved the shape opposite to
the cursor: dragging down decreased Y/height, so the shape moved up
while the cursor moved down. SVG's Y axis grows downward, so the value
change must follow the cursor direction for these fields.

Adds an `inverted` option to $.fn.dragInput (as proposed in methodofaction#163) that
flips the drag, mouse-wheel and arrow-key direction, and applies it to
all Y-position and height draginputs initialized in MD.Panel
(canvas_height, rect_height, ellipse_cy/ry, image_height, circle_cy,
selected_y, path_node_y, line_y1/y2, path_y, rect_y, g_y, text_y,
image_y). Non-inverted fields keep the existing behavior.

Also adds test/draginput_test.html (QUnit) covering default vs inverted
drag direction and arrow keys, and registers it in test/all_tests.html.

Fixes methodofaction#163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Draginput control upside down for Y and Height properties

1 participant