feat: support ion-infinite-scroll in a `flex-direction: column-reverse` scroll element

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
frontend

調査の方向性

Start with core/src/components/infinite-scroll/infinite-scroll.tsx, especially the distance calculation at lines 121–129 and the scrollTop writes in connectedCallback and complete(). Reproduce the report with a column-reverse scroll element and check both position values against the stated threshold behavior. Done means the event fires once within the threshold at the trigger in either direction, and the initial and completion scroll positions remain in range.

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

説明

package: core type: feature request
Ionic Framework Version

v9.x (9.0.7)

Current Behavior

A chat-style page lays the scroll element out bottom-up with ion-content::part(scroll) { display: flex; flex-direction: column-reverse; } so that the newest row sits at the bottom and the scroller starts there. In that layout the browser's scrollTop is 0 at the bottom and goes negative towards the top ([-320, 0] in the reproduction).

ion-infinite-scroll computes its distance as if scrollTop were non-negative (core/src/components/infinite-scroll/infinite-scroll.tsx L121–129):

const distanceFromInfinite =
  this.position === 'bottom'
    ? scrollHeight - infiniteHeight - scrollTop - threshold - height
    : scrollTop - infiniteHeight - threshold;

With the trigger placed at the oldest end of the list (the last DOM child, painted at the top) and threshold="100px":

position what happens
top ionInfinite fires on the very first scroll step, 315 px away from the oldest end, and again on every later step (7 of 7 steps fired)
bottom never fires, including at scrollTop = -320, i.e. with the trigger fully on screen at the oldest end

Scroller in the reproduction: scrollHeight 1164, clientHeight 844, so the whole scrollable range is 320 px.

connectedCallback (L96–101) and complete() (L184–200) also write scrollEl.scrollTop = scrollHeight - clientHeight / scrollHeight - prev for position="top", which are positions outside the [-320, 0] range of a column-reverse scroller.

Expected Behavior

The trigger fires once when the user is within threshold of the trigger element, whichever direction the scroll element grows in.

Steps to Reproduce
  1. <ion-content> with the style above, 60 rows of 48 px, and <ion-infinite-scroll position="top" threshold="100px"> as the last child (so it paints at the top).
  2. Listen to ionInfinite, call complete() in the handler, and set scrollTop to -5, -20, -60, … on the scroll element returned by getScrollElement().
  3. Observe one ionInfinite per step. Switch to position="bottom" and scroll all the way up: no event.
Ionic Info

@ionic/core 9.0.7, Chromium 142 (Playwright headless).

主要言語
TypeScript
スター
52.8k
フォーク
13.3k
平均マージ
3日 1時間
マージ済み PR(30日)
86

環境構築

はじめの一歩

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

ionic-team/ionic-framework のほかの issue

ionic-team/ionic-framework の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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