Commit 1119725
committed
[PR] Implement native inverted behaviors for ScrollView (microsoft#8440)
This PR modifies ScrollViewManager and VirtualizedList to work around
the limitations of the RN core approach to list inversion. Specifically,
the RN core approach to list inversion uses scroll axis transforms to
flip the list content. While this creates the visual appearance of an
inverted list, scrolling the list via keyboard or mouse wheel results in
inverted scroll direction.
To accomplish native inverted scroll behaviors, we focused on four
expected behaviors of inverted lists:
1. When content loads "above" the view port in an inverted list, the
visual content must remain anchored (as if the content renders below it
in a non-inverted list).
2. When scrolled to the "start" of an inverted list (in absolute terms,
the bottom of the scroll view), content appended to the start of the
list must scroll into view synchronously (i.e., no delay between content
rendering and view port changing).
3. When content renders on screen, it must render from bottom to top,
so render passes that take multiple frames do not appear to scroll to
the start of the list.
4. When imperatively scrolling to the "start" of the content, we must
always scroll to the latest content, even if the content rendered after
the scroll-to-start animation already began.
For 1., we leverage the XAML `CanBeScrollAnchor` property on each
top-level item in the list view. While this is an imperfect solution
(re-rendering of this content while in the view port can result in view
port shifts as new content renders above), it is a good trade-off of
performance and functionality.
For 2., we leverage the XAML `HorizontalAnchorRatio` and
`VerticalAnchorRatio` properties. XAML has a special case for inverted
lists when setting these property values to `1.0`. It instructs XAML to
synchronously scroll to and render new content when scrolled to the
bottom edge of the ScrollViewer.
For 3., we leverage Yoga's implementation of `flexDirection: column-reverse` and `flexDirection: row-reverse` to ensure content is rendered from bottom to top.
For 4., we implemented `ScrollViewViewChanger` to continuously check if
the target scroll offset has changed since starting an animated
scroll-to-end operation. If the target scroll offset no longer matches
the scrollable extent of the ScrollViewer, we update the target offset
by calling `ChangeView` again.
Fixes microsoft#40981 parent f862cca commit 1119725
File tree
18 files changed
+428
-25
lines changed- packages/@react-native-windows/virtualized-list/src
- vnext
- Microsoft.ReactNative
- Views
- Impl
- src/Libraries/Components/View
18 files changed
+428
-25
lines changedLines changed: 96 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
388 | 391 | | |
389 | 392 | | |
390 | 393 | | |
| |||
458 | 461 | | |
459 | 462 | | |
460 | 463 | | |
461 | | - | |
| 464 | + | |
462 | 465 | | |
463 | 466 | | |
464 | 467 | | |
| |||
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
611 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
612 | 634 | | |
613 | 635 | | |
614 | 636 | | |
| |||
888 | 910 | | |
889 | 911 | | |
890 | 912 | | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
891 | 919 | | |
892 | 920 | | |
893 | 921 | | |
| |||
1018 | 1046 | | |
1019 | 1047 | | |
1020 | 1048 | | |
1021 | | - | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1022 | 1057 | | |
1023 | 1058 | | |
1024 | 1059 | | |
| |||
1072 | 1107 | | |
1073 | 1108 | | |
1074 | 1109 | | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
1075 | 1115 | | |
1076 | 1116 | | |
1077 | 1117 | | |
| |||
1229 | 1269 | | |
1230 | 1270 | | |
1231 | 1271 | | |
1232 | | - | |
| 1272 | + | |
1233 | 1273 | | |
1234 | 1274 | | |
1235 | 1275 | | |
| |||
1413 | 1453 | | |
1414 | 1454 | | |
1415 | 1455 | | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
1416 | 1460 | | |
1417 | 1461 | | |
1418 | 1462 | | |
| |||
1497 | 1541 | | |
1498 | 1542 | | |
1499 | 1543 | | |
1500 | | - | |
| 1544 | + | |
1501 | 1545 | | |
1502 | 1546 | | |
1503 | 1547 | | |
| |||
1632 | 1676 | | |
1633 | 1677 | | |
1634 | 1678 | | |
1635 | | - | |
| 1679 | + | |
1636 | 1680 | | |
1637 | 1681 | | |
1638 | 1682 | | |
| |||
1734 | 1778 | | |
1735 | 1779 | | |
1736 | 1780 | | |
1737 | | - | |
| 1781 | + | |
1738 | 1782 | | |
1739 | 1783 | | |
1740 | 1784 | | |
| |||
1745 | 1789 | | |
1746 | 1790 | | |
1747 | 1791 | | |
1748 | | - | |
| 1792 | + | |
1749 | 1793 | | |
1750 | 1794 | | |
1751 | 1795 | | |
1752 | 1796 | | |
1753 | 1797 | | |
1754 | 1798 | | |
1755 | 1799 | | |
1756 | | - | |
| 1800 | + | |
1757 | 1801 | | |
1758 | 1802 | | |
1759 | 1803 | | |
| |||
1817 | 1861 | | |
1818 | 1862 | | |
1819 | 1863 | | |
| 1864 | + | |
1820 | 1865 | | |
1821 | 1866 | | |
1822 | 1867 | | |
1823 | 1868 | | |
1824 | 1869 | | |
1825 | 1870 | | |
1826 | 1871 | | |
1827 | | - | |
1828 | | - | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
1829 | 1884 | | |
1830 | 1885 | | |
1831 | 1886 | | |
1832 | 1887 | | |
1833 | 1888 | | |
1834 | 1889 | | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
1835 | 1902 | | |
1836 | 1903 | | |
1837 | | - | |
| 1904 | + | |
1838 | 1905 | | |
1839 | 1906 | | |
1840 | 1907 | | |
| |||
1855 | 1922 | | |
1856 | 1923 | | |
1857 | 1924 | | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
1858 | 1932 | | |
1859 | 1933 | | |
1860 | 1934 | | |
| |||
1872 | 1946 | | |
1873 | 1947 | | |
1874 | 1948 | | |
1875 | | - | |
| 1949 | + | |
1876 | 1950 | | |
1877 | 1951 | | |
1878 | 1952 | | |
| |||
2109 | 2183 | | |
2110 | 2184 | | |
2111 | 2185 | | |
2112 | | - | |
| 2186 | + | |
2113 | 2187 | | |
2114 | 2188 | | |
2115 | | - | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
2116 | 2196 | | |
2117 | 2197 | | |
2118 | 2198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| |||
665 | 666 | | |
666 | 667 | | |
667 | 668 | | |
| 669 | + | |
668 | 670 | | |
669 | 671 | | |
670 | 672 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| |||
545 | 548 | | |
546 | 549 | | |
547 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
548 | 554 | | |
549 | 555 | | |
550 | 556 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
0 commit comments