callstack / callstack/react-native-pager-view

(iOS) Dynamic pages causes page switch when adding pages at the start

Offen
#965 1 Kommentar 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
3.4k
Forks
476
Ø Merge
10 T. 21 Std.
Gemergte PRs (30 T.)
2

Beschreibung

## Environment

Expo v52
React Native 0.76.6
Expo Router v4
iPhone 16 Pro Simulator

## Description

### Summary

I'm using this pager view to show images (similar to iOS photos app), and since there's a lot of images to be loaded, it's images are loaded as requested, similar to FlatList `onStartReached` and `onEndReached`.

### Current behaviour

Adding pages to the end of the data array works very well, but when adding to the start, the current page changes to the new page added based on the page index it was before.

### Expected behaviour

I can see this might be an intended behaviour based on what is being built, but having at least a prop like `preservePage` to update the current page while preserving the page in view (maybe based on page key or id) would be perfect for dynamically loading pages.

I also tested on Android, and it works as expect most of the times, maintaining the correct current page view. Some times it does not update the `activePage` correctly, but the current page view stay as is.

## Findings

On version `6.5.1` of this library, the current page view is preserved as expected, and after digging deeper, I found out that #923 (introduced on `6.6.0`) is the "culprit" for the issue. Although this makes the current page view still visible, the actual `activePage` is not updated accordingly, which also impacts on the position given by `onPageScroll`. It only correctly updates the `activePage` when completing a swipe to the left/right, then `onPageSelected` is called with the correct position.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, das iOS-Verhalten mit dynamisch vorangestellten Seiten unter Verwendung des gemeldeten Setups mit Expo v52, React Native 0.76.6 und pager-view 6.6.0 nachzustellen. Untersuche die in #923 eingeführte Änderung und vergleiche sie mit Version 6.5.1. Überprüfe anschließend, dass die sichtbare Seite, activePage und die onPageScroll-Position ausgerichtet bleiben, nachdem am Anfang Seiten hinzugefügt wurden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
ios, react-native, typescript
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.