Yii2 Scroll Pager
Yii2 Scroll Pager (Y2SP) turns your regular paginated page into an infinite scrolling page using AJAX.
Y2SP works with a
Pagination object which specifies the totally number of pages and the current page number.
Pager is build with help of JQuery Infinite Ajax Scroll plugin.
Note: This extension mandatorily requires Yii Framework 2. The framework is under active development and the first stable release of Yii 2 is expected in early 2014.
The preferred way to install this extension is through Composer.
php composer.phar require kop/yii2-scroll-pager "dev-master"
require section of your
Just pass the ScrollPager class name to the ListView
echo ListView::widget([ 'dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'item'], 'itemView' => '_item_view', 'pager' => ['class' => \kop\y2sp\ScrollPager::className()] ]);
Enter the selector of the element containing your items that you want to paginate.
Enter the selector of the element that each item has. Make sure the elements are inside the container element.
Contains the message to be displayed when there are no more pages left to load.
Loader spinner. This HTML element will be displayed when the next page with items is loaded via AJAX.
Minimal time (in milliseconds) the loader should be displayed before rendering the items of the next page. Note: This setting will not actually delay the the loading of items itself.
Page number after which a 'Load more items' link is displayed. Users will manually trigger the loading of the next page by clicking this link.
Default: "Load more items"
Text of the manual trigger link.
On default IAS starts loading new items when you scroll to the latest .item element. The thresholdMargin will be added to the items' offset, giving you the ability to load new items earlier (please note that the margin should be a negative integer for this case).
Setting a thresholdMargin of -250 means that IAS will start loading 250 pixel before the last item has scrolled into view. A positive margin means that IAS will load new items N pixels after the last item.
Set this to false to disable the history module.
The IAS history module uses hashes (in the format "#/page/") to remember the last viewed page, so when a visitor hits the back button after visiting an item from that page, it will load all items up to that last page and scrolls it into view. The use of hashes can be problematic in some cases, in which case you can disable this feature.
By default, scroll events are listened from the
You can use this setting to specify a custom container, for example a div with overflow.
yii2-scroll-pager is released under the MIT License. See the bundled
LICENSE.md for details.