Skip to content

Commit 01f707f

Browse files
committed
Fix
1 parent b708827 commit 01f707f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

examples/pagerCount.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ReactDOM.render(
3636
/>
3737

3838
<p> pagerCount less than 3 </p>
39-
<Pagination total={100} pagerCount={0} />
39+
<Pagination total={100} pagerCount={1} />
4040

4141
<p> Has `showLessItems` and `pagerCount` </p>
4242
<Pagination total={500} pagerCount={8} showLessItems />

src/Pager.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const Pager = (props) => {
3232
if (props.first) {
3333
pageType = 'jump-first';
3434
}
35-
35+
3636
const itemNode = props.itemRender(props.page, pageType, <a>{props.page}</a>);
37-
37+
3838
return (
3939
itemNode === null ? null :
4040
<li

src/Pagination.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ class Pagination extends React.Component {
152152

153153
getJumpPrevPage = () => {
154154
const { showLessItems } = this.props;
155-
const hasPagerCount = this.hasPagerCount()
155+
const hasPagerCount = this.hasPagerCount();
156156
return Math.max(1, this.state.current - (showLessItems && !hasPagerCount ? 3 : 5));
157157
}
158158

159159
getJumpNextPage = () => {
160160
const { showLessItems } = this.props;
161-
const hasPagerCount = this.hasPagerCount()
161+
const hasPagerCount = this.hasPagerCount();
162162
return Math.min(
163163
calculatePage(undefined, this.state, this.props),
164164
this.state.current + (showLessItems && !hasPagerCount ? 3 : 5)
@@ -352,9 +352,11 @@ class Pagination extends React.Component {
352352
// `pagerCount` priority is greater than `showLessItems`.
353353
const hasPagerCount = this.hasPagerCount();
354354
const boundary = pagerCount === 0 ? 0 : 1;
355-
const boundaryRemainder = hasPagerCount ? (pagerCount % 2 !== 0 ? 0 : boundary) : 0;
355+
const pagerCountBoundary = pagerCount % 2 !== 0 ? 0 : boundary;
356+
const boundaryRemainder = hasPagerCount ? pagerCountBoundary : 0;
356357
const halfPagerCount = Math.max(0, Math.floor((pagerCount - 1) / 2));
357-
const pageBufferSize = hasPagerCount ? halfPagerCount : (showLessItems ? 1 : halfPagerCount);
358+
const halfHasLessItemsCount = showLessItems ? 1 : halfPagerCount;
359+
const pageBufferSize = hasPagerCount ? halfPagerCount : halfHasLessItemsCount;
358360

359361
const goButton = (props.showQuickJumper && props.showQuickJumper.goButton);
360362
const { current, pageSize } = this.state;

0 commit comments

Comments
 (0)