tv2regionerne/statamic-endless
最新稳定版本:v1.4.0
Composer 安装命令:
composer require tv2regionerne/statamic-endless
包简介
README 文档
README
Statamic Endless allows you to create infinite scroll lists that automatically or manually load new entries when you get to the end.
How to Install
You can search for this addon in the Tools > Addons section of the Statamic control panel and click install, or run the following command from your project root:
composer require tv2regionerne/statamic-endless
How to Use
Make sure Livewire v3 is installed, then use the collection:endless tag:
{{ collection:endless as="posts" from="blog" paginate="5" }}
<div x-ref="append">
{{ posts }}
{{ partial:blog/post }}
{{ /posts }}
</div>
<button x-on:click="trigger" x-show="paginate.has_more_pages">Load More</button>
{{ /collection:endless }}
Example with intersectors:
{{ collection:endless as="posts" from="blog" paginate="5" }}
<div x-ref="append">
{{ posts }}
{{ partial:blog/post }}
{{ /posts }}
</div>
<div
x-data="{
intersecting: false,
init() {
$watch('intersecting', () => this.check());
},
check() {
if (this.intersecting && paginate.has_more_pages) {
trigger().then(() => this.check());
}
},
}"
x-show="!loading && paginate.has_more_pages"
x-intersect:enter="intersecting = true"
x-intersect:leave="intersecting = false">
</div>
{{ /collection:endless }}
You must enable pagination.
The content will be wrapped in a Livewire/Alpine component:
- You should add an
x-refof eitherappendorprependto the element that contains your list. - You can call
triggerto load more entries usingx-intersectorx-on. - You can check the loading state with
loading.
On secondary loads variables from outside tag scope will only be avaliable if you list them in the context parameter (pipe delimited). These variables must be serializable.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-04-25