Skip to content

Commit

Permalink
Merge pull request #30 from kristerkari/bugfix/dont-call-onindexchang…
Browse files Browse the repository at this point in the history
…ed-when-the-index-hasnt-changed

Don't call onIndexChanged when the index has not changed
  • Loading branch information
kristerkari authored Apr 9, 2019
2 parents b3b4ff2 + 52fa9e1 commit 9113051
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 9113051

Please sign in to comment.