Skip to content

Commit 31581df

Browse files
author
wfbn8821
committed
fix(transition): Fix bug on right slide with only 2 visible cards
Fixes #3
1 parent 248e09e commit 31581df

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

lib/assets/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
box-sizing: border-box; }
55
._1H7C65wd8WJqBtCRmAfokb .rcs-center, ._1H7C65wd8WJqBtCRmAfokb .rcs-left-stack, ._1H7C65wd8WJqBtCRmAfokb .rcs-right-stack {
66
position: absolute;
7-
transition: left 1s cubic-bezier(0, 0.7, 0.7, 1);
7+
transition: left 1s cubic-bezier(0, 0.7, 0.7, 1), z-index 1s cubic-bezier(0, 0.7, 0.7, 1);
88
box-sizing: border-box; }
99

1010
._22yQcZhJvmCSA52vE9VrUe {

lib/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ var CardScroll = _react2.default.createClass({
7878
if (childrenCount == 0) {
7979
return defaultWidths;
8080
}
81-
// anticipate the margin that we will add
8281
var container = this._container.getBoundingClientRect().width;
8382
// get first child as all children should be of equal width
8483
var card = _reactDom2.default.findDOMNode(this._child).getBoundingClientRect().width;
@@ -129,12 +128,12 @@ var CardScroll = _react2.default.createClass({
129128
stackSpace: _this2.props.stackSpace
130129
});
131130
var position = offset;
132-
var zIndex = 0;
131+
var zIndex = -currentCard + index;
133132
var className = "rcs-left-stack";
134133
if (offset == 0) {
135134
position = (index - currentCard) * _this2.widths.card;
136135
if (index == lastCard && currentCard != lastCard) {
137-
zIndex = -1;
136+
zIndex = 0;
138137
}
139138
className = "rcs-center";
140139
} else if (offset > 0) {

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.1.0",
3+
"version": "2.1.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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ let CardScroll = React.createClass({
102102
stackSpace: this.props.stackSpace
103103
})
104104
let position = offset
105-
let zIndex = 0
105+
let zIndex = -currentCard+index
106106
let className = "rcs-left-stack"
107107
if(offset==0){
108108
position = (index-currentCard)*this.widths.card
109109
if(index == lastCard && currentCard != lastCard){
110-
zIndex = -1
110+
zIndex = 0
111111
}
112112
className = "rcs-center"
113113
} else if(offset>0){
@@ -126,7 +126,7 @@ let CardScroll = React.createClass({
126126
</div>
127127
)
128128
},
129-
129+
130130
scrollCardsWrap(params){
131131
return () => this.scrollCards(params)
132132
},

src/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $outPadding: $padding - $outMargin;
99
box-sizing: border-box;
1010
:global(.rcs-center), :global(.rcs-left-stack), :global(.rcs-right-stack){
1111
position: absolute;
12-
transition: left 1s cubic-bezier(0,.7,.7,1);
12+
transition: left 1s cubic-bezier(0,.7,.7,1), z-index 1s cubic-bezier(0,.7,.7,1);
1313
box-sizing: border-box;
1414
}
1515
}

0 commit comments

Comments
 (0)