Skip to content

Commit 5edc761

Browse files
author
wfbn8821
committed
fix scroll when remove last card and scroll resize issue
1 parent abf8223 commit 5edc761

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-card-scroll",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "A React component to navigate horizontally between cards of same width",
55
"main": "lib/index.js",
66
"scripts": {

src/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ let CardScroll = React.createClass({
7171
let first = true
7272
return (
7373
<div>
74-
{this.canScrollLeft()?
74+
{this.showArrows() && this.canScrollLeft()?
7575
<div className={s.leftArrow}
7676
onClick={this.scrollCardsWrap({toLeft: true})}>
7777
<div className={s.arrow}></div>
7878
</div>
7979
:null}
80-
{this.canScrollRight()?
80+
{this.showArrows() && this.canScrollRight()?
8181
<div className={s.rightArrow}
8282
onClick={this.scrollCardsWrap()}>
8383
<div className={s.arrow}></div>
@@ -153,11 +153,15 @@ let CardScroll = React.createClass({
153153
},
154154

155155
canScrollRight(){
156-
return this.props.showArrows && this.lastVisibleCardIndex()+1 < React.Children.count(this.props.children)
156+
return this.lastVisibleCardIndex()+1 < React.Children.count(this.props.children)
157157
},
158158

159159
canScrollLeft(){
160-
return this.props.showArrows && this.state.currentCard>0
160+
return this.state.currentCard>0
161+
},
162+
163+
showArrows(){
164+
return this.props.showArrows
161165
},
162166

163167
/**

0 commit comments

Comments
 (0)