When the user scrolls through the app, the leadingLayers and trailingLayers update as the Swipe widget's position changes to achieve the infinite scroll effect.
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
// To achieve this infinite scroll effect we need to swap the layers:// The layer starts at the bottom, the divider goes up.// Then the next layer starts to show up, so we put back the divider at the bottom and swap the layers.if (position < 0 && swipe.trailingLayers.length) {
swipe.leadingLayers.addMany(swipe.trailingLayers);
swipe.trailingLayers.removeAll();
} elseif (position >= 0 && swipe.leadingLayers.length) {
swipe.trailingLayers.addMany(swipe.leadingLayers);
swipe.leadingLayers.removeAll();
}