callstack / callstack/react-native-pager-view

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

オープン
#965 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
3.4k
フォーク
476
平均マージ
10日 21時間
マージ済み PR(30日)
2

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、報告されている Expo v52、React Native 0.76.6、pager-view 6.6.0 の構成を使い、ページを動的に先頭へ追加したときの iOS の挙動を再現します。#923 で導入された変更を調べてバージョン 6.5.1 と比較し、その後、先頭にページを追加した後も、表示中のページ、activePage、onPageScroll の位置が一致したままであることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
ios, react-native, typescript
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。