kop / yii2-scroll-pager

Infinite AJAX scrolling for Yii2 ListView widget
https://kop.github.io/yii2-scroll-pager/
MIT License
180 stars 63 forks source link

Yii2 Scroll Pager with overflow scroll #64

Open temirfe opened 8 years ago

temirfe commented 8 years ago

i have the same question as in here "when you set the scroll for a div, instead of the whole screen, ajax is not loading any additional items when you scroll down." I tried to use overflowContainer but with no luck.

nicdnepr commented 7 years ago

@temirfe did you solve this?

omer-sds commented 7 years ago

can you please share your code and output html

omer-sds commented 7 years ago

is used the following setting to initialize with ListView and it works fine, one thing, if you want infinite scroll throughout then use $listDataProvider->pagination->pageSize for the triggerOffset property

<?=
                ListView::widget ( [
                    'dataProvider' => $listDataProvider ,
                    'options' => [
                        'tag' => 'div' ,
                        'class' => 'list-wrapper' ,
                        'id' => 'list-wrapper' ,
                    ] ,
                    'itemOptions' => ['class' => 'col-sm-6 col-md-3' ] ,
                    'layout' => "{items}{pager}" ,
                    'pager' => [
                        'class' => \kop\y2sp\ScrollPager::className () ,
                        'container' => '#list-wrapper' ,
                        'item' => '.col-sm-6.col-md-3' ,
                        'paginationSelector' => '#list-wrapper>.pagination' ,
                        'next' => '.next a' ,
                        'historyPrev' => 'li.prev>a' ,
                        'noneLeftText' => 'No more Listings to display.' ,
                        'noneLeftTemplate' => '<div class="no-more col-sm-12"><span>{text}</span></div>' ,
                        'triggerText' => 'Load More Listings' ,
                        'triggerOffset' => $listDataProvider->pagination->pageSize,
                        'triggerTemplate' => '<div class="load-more"><a href="javascript:void(0)"><i class="zmdi zmdi-refresh-alt"></i> {text}</a></div>' ,
                    ] ,
nicdnepr commented 7 years ago

I use Gridview with default layout, with pager with param overflowContainer => '#w3'

<div id="w3" class="grid-view">
<table class="table table-striped table-bordered"></table>
<ul class="pagination hidden"></ul></div>

#w3 {
    height: 600px;
    overflow-y: scroll;
}

and pager not catch div overflow scroll, only catch global window scroll

akshaymisal27 commented 3 years ago

@nicdnepr Did you find any solution for this?

temirfe commented 3 years ago

I'm sorry but it seems like Yii2 is slowly dying, consider switching to Laravel or smth. I'm thinking of switching to one of this alternatives: react or vue for frontend, node(expressjs) or python(django) for backend.

ktropp commented 1 year ago

I solved this by editing jquery-ias.js:624, $.ias function to this, dunno if this breaks ajax load not in overflow container:

  $.ias = function(option) {
    var $window = $(window);

    if($(option.container).length){
      $window = $(option.container);
    }

    return $window.ias.apply($window, arguments);
  };