question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question about items-per-page

See original GitHub issue

Hi Michael!

Still loving the plugin! Right now our issue is that when changing pages it seems like the items are being loaded in/out of the dom; this seems to be causing some delay/jumping of the content when changing pages (its a list of ul li’s with one 5 li’s, one li being an svg image).

However, once we have gone through all the pagination pages, changing pages runs smooth as butter.

Would you happen to have an idea why this happens and how to fix it? 😃

=======

Angular version: 6.0.3

ngx-pagination version: 3.1.1

Any relevant code: in the app.html:

<!--previous -->
<a class="circle circle-left"  (click)="leftArrowJump() ;!p.isFirstPage() ? p.previous() : p.setCurrent(p.getLastPage())"><i class="material-icons arrow">keyboard_arrow_left</i></a>


<!--airline cards -->
<div class="airline-content grid-x grid-margin-x large-up-5 medium-up-3 small-up-1 align-center" id="stuck-prev">
                        <app-airline-card 
                         *ngFor="let airline of shownAirlines | paginate: { itemsPerPage: 20, currentPage: page }" 
                         [airline]="airline">
                         </app-airline-card>
</div>

<!--next -->
 <a class="circle circle-right" (click)="rightArrowJump() ;!p.isLastPage() ? p.next() : p.setCurrent(1)"><i class="material-icons arrow">keyboard_arrow_right</i></a>

<!--pages (dots)-->
    <pagination-template #p="paginationApi" (pageChange)="page = $event">
        <div class="dots-container">
            <div class="dot-div" *ngFor="let page of p.pages">
                <ol id="page-dots"  (click)="p.setCurrent(page.value)">
                    <li [ngClass]="{'active': p.getCurrent() === page.value}">•</li>
                </ol>
            </div>
        </div>
    </pagination-template>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
michaelbromleycommented, Aug 16, 2018

This is just the way that ngFor works. As I mentioned above, you can alter this by using a trackBy function:

<li *ngFor="let item of collection | paginate: { itemsPerPage: 10, currentPage: p }; trackBy: trackByIndex">{{ item }}</li>
trackByIndex(index: number) {
    return index;
}

See this modified demo - you can compare the DOM elements between pages and you’ll see that the objects are now identical.

1reaction
michaelbromleycommented, Aug 16, 2018

Great! Glad that fixed it for you 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

The itemsPerPage id argument does not match a registered ...
I just noticed that I'm using angularjs version 2 above,thus i need to add the pagination id at after itemsPerPage as
Read more >
why views items per page set to specific values
To be brutally simple: Because someone thought it to be good UX, maintainers agreed, and no one convinced them other way since then....
Read more >
Pagination (Number of items per page) problem - WordPress.org
There is a problem in pagination. Number of items per page (in screen options) not working and I can only see 5 items...
Read more >
SAP Cloud Platform Authorization API items per page ...
We need to know what the maximum number of items per page is displayed in the payload of the resulting HTTP Call to...
Read more >
Addepar OA (Frontend + Backend) - LeetCode Discuss
There is a coding question and 3 multiple choice question. ... Also given sortParamenter , sortOrder , pageNumber , itemsPerPage . You have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found