Skip to content

Commit

Permalink
Don't call onIndexChanged when the index has not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
kristerkari committed Apr 9, 2019
1 parent b3b4ff2 commit 52fa9e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Pinar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export class Pinar extends React.PureComponent<Props, State> {
const nextActivePageIndex = Math.floor(
activePageIndex + Math.round(diff / step)
);

if (nextActivePageIndex === activePageIndex) {
return;
}

const isIndexSmallerThanFirstPageIndex = nextActivePageIndex <= -1;
const isIndexBiggerThanLastPageIndex = nextActivePageIndex >= total;
const needsToUpdateOffset =
Expand Down

0 comments on commit 52fa9e1

Please sign in to comment.