v0.21

d-virtual-list

CSSのcontent-visibilityと最下部近接検知を利用し、画面外要素のレイアウトおよび描画処理をスキップする軽量DOM仮想化コンポーネントです。

1<d-virtual-list item-size="64px" buffer="800px 0px 800px 0px" threshold="600">
2 @foreach ($items as $item)
3 <div class="p-3 bg-container mb-2 rounded">{{ $item->title }}</div>
4 @endforeach
5</d-virtual-list>

属性とプロパティ

属性 プロパティ 型 デフォルト値 フォーム 説明
item-size itemSize string "52px" いいえ contain-intrinsic-size用の項目推定高さフォールバック
buffer buffer string "600px 0px 600px 0px" いいえ 画面外項目の先行レンダリングを行うIntersectionObserverのマージン
threshold threshold number 500 いいえ reachbottomイベントを発火する最下部からのピクセル距離
cooldown cooldown number 250 いいえ reachbottomイベント連続発火のクールダウンミリ秒
scroll-parent scrollParent string "" いいえ 任意のスクロールコンテナを指定するCSSセレクタ

プログラム用api

1const list = select('d-virtual-list');
2
3list.itemSize = '72px';
4list.threshold = 400;
5
6// 最下部への近接判定を手動実行
7list.checkBottom();

イベント

イベント 詳細 バブリング 説明
reachbottom { distance, threshold } はい リストの最下部付近までスクロールしたときに送出

動作仕様