Commit ed75963
Run flingAndSnap logic from ACTION_SCROLL events (#54226)
Summary:
Pull Request resolved: #54226
#54226
Joysticks, mouse wheels, and trackpads can issue an `ACTION_SCROLL` event when performing scroll. However, the `ACTION_SCROLL` generic motion event does not run the post touch runnable and paging/snap alignment is not honored when these events are received. To fix this, both ScrollView implementations should call `handlePostTouchScrolling` with a 0 velocity, ensuring that momentum events are sent, fabric scroll state is updated, and `flingAndSnap` is properly called to align to a page.
This change adds some checks to queue a runnable that calls `handlePostTouchScrolling` after no more `ACTION_SCROLL` events are received in the same 20ms delay it uses to determine a stable frame. The end result is that snap alignments are correctly honored
Changelog: [Android][Fixed] - Controller-driven scroll events now honor paging/snap alignment
Reviewed By: javache
Differential Revision: D85172309
fbshipit-source-id: 5818777b3c371b3da4aa925a8c840e0da89bf6a41 parent 6f84323 commit ed75963
File tree
2 files changed
+64
-0
lines changed- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll
2 files changed
+64
-0
lines changedLines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
807 | 839 | | |
808 | 840 | | |
809 | 841 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
661 | 693 | | |
662 | 694 | | |
663 | 695 | | |
| |||
0 commit comments