AppFlowy-IO / appflowy-editor

A highly customizable rich-text editor for Flutter. The AppFlowy Editor project for AppFlowy and beyond.
https://pub.dev/packages/appflowy_editor
Other
473 stars 201 forks source link

feat: implement custom pan gesture to avoid delay offset update #909

Closed LucasXu0 closed 1 month ago

LucasXu0 commented 1 month ago

By default, the panStart callback from PanGestureRecognizer won't be triggered immediately after dragging starts. It will be delayed, causing the start offset point to not match the real offset point on the screen. For example, when you start dragging from offset(0,0) horizontally, the panStart callback may trigger at offset(2, 0), which causes the start selection calculation to be incorrect.

The solution is to implement a custom PanGesture which triggers the panStart call immediately without any delay.

preview

https://github.com/user-attachments/assets/c9344c58-c17f-4f91-be24-267760025ea9

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 23.33333% with 23 lines in your changes missing coverage. Please review.

Project coverage is 71.94%. Comparing base (3bbdccd) to head (9b3729b). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/src/service/selection/selection_gesture.dart 25.92% 20 Missing :warning:
...t/service/selection/desktop_selection_service.dart 0.00% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #909 +/- ## ========================================== - Coverage 72.04% 71.94% -0.10% ========================================== Files 318 318 Lines 14962 14980 +18 ========================================== - Hits 10780 10778 -2 - Misses 4182 4202 +20 ``` | [Flag](https://app.codecov.io/gh/AppFlowy-IO/appflowy-editor/pull/909/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AppFlowy-IO) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/AppFlowy-IO/appflowy-editor/pull/909/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AppFlowy-IO) | `71.94% <23.33%> (-0.10%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AppFlowy-IO#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.