Skip to content

Add two-finger pan to move the text in all directions - #234

Open
dronov-dmitry wants to merge 1 commit into
maxistar:masterfrom
dronov-dmitry:two-finger-pan
Open

Add two-finger pan to move the text in all directions#234
dronov-dmitry wants to merge 1 commit into
maxistar:masterfrom
dronov-dmitry:two-finger-pan

Conversation

@dronov-dmitry

@dronov-dmitry dronov-dmitry commented Aug 17, 2026

Copy link
Copy Markdown

Summary

Adds a two-finger pan gesture: while two fingers are pressed on the text, dragging moves the text in any direction (left/right/up/down).

How it works

  • New TwoFingerPanTouchListener attached to the editor EditText in EditorActivity.
  • When a second pointer goes down, the listener takes over the gesture and scrolls the content to follow the fingers (focal point of the two pointers).
  • Works in both layouts:
    • default (ScrollView) — vertical scroll via the ScrollView, horizontal via the EditText;
    • "simple scrolling" — both axes via the EditText.
  • Scrolling is clamped to the content bounds (panContent/clampScroll) so the text cannot be panned past its edges.
  • Single-finger behavior (cursor placement, selection, drag scrolling) is untouched.

Note: horizontal panning only applies when text is wider than the screen, i.e. when auto-wrap is turned off.

Verification

  • ./gradlew compileDebugJavaWithJavac — OK
  • ./gradlew testDebugUnitTest — OK
  • ./gradlew lint — no errors

Video

https://youtube.com/shorts/mreTjptc4fY

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.

1 participant