Skip to content

Commit 502cffb

Browse files
committed
improve the status of pagination button
1 parent 689b60f commit 502cffb

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/pagination/PageButton.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ class PageButton extends React.Component{
1313
}
1414

1515
render(){
16-
var classes = this.props.active?classSet("active"):null;
16+
var classes = classSet({
17+
'active': this.props.active,
18+
'disabled': this.props.disable
19+
});
1720
return (
1821
<li className={classes}><a href="#" onClick={this.pageBtnClick.bind(this)}>{this.props.children}</a></li>
1922
)
2023
}
2124
}
2225
PageButton.propTypes = {
2326
changePage: React.PropTypes.func,
24-
active: React.PropTypes.bool
27+
active: React.PropTypes.bool,
28+
disable: React.PropTypes.bool
2529
};
2630

2731
export default PageButton;

src/pagination/PaginationList.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,17 @@ class PaginationList extends React.Component {
109109
var pages = this.getPages();
110110
return pages.map(function (page) {
111111
var isActive = page === this.state.currentPage;
112+
var disabled = false;
113+
if(this.state.currentPage == 1 &&
114+
(page === Const.FIRST_PAGE || page === Const.PRE_PAGE)){
115+
disabled = true;
116+
}
117+
if(this.state.currentPage == this.totalPages &&
118+
(page === Const.NEXT_PAGE || page === Const.LAST_PAGE)){
119+
disabled = true;
120+
}
112121
return (
113-
<PageButton changePage={this.changePage.bind(this)} active={isActive} key={page}>{page}</PageButton>
122+
<PageButton changePage={this.changePage.bind(this)} active={isActive} disable={disabled} key={page}>{page}</PageButton>
114123
)
115124
}, this);
116125
}

0 commit comments

Comments
 (0)