Skip to content

Commit

Permalink
Fixing cellSpacing width offset
Browse files Browse the repository at this point in the history
  • Loading branch information
kenwheeler committed Apr 22, 2015
1 parent 1eb582c commit 83f11f3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nuka-carousel",
"main": "index.js",
"version": "0.0.6",
"version": "0.0.7",
"homepage": "https://github.com/kenwheeler/nuka-carousel",
"authors": [
"Ken Wheeler <ken_wheeler@me.com>"
Expand Down
5 changes: 5 additions & 0 deletions lib/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,17 @@ var Carousel = _React2['default'].createClass({
var self = this,
slideWidth,
frame;

frame = _React2['default'].findDOMNode(this.refs.frame);

if (typeof this.props.slideWidth !== 'number') {
slideWidth = parseInt(this.props.slideWidth);
} else {
slideWidth = frame.offsetWidth / this.props.slidesToShow * this.props.slideWidth;
}

slideWidth -= this.props.cellSpacing * ((100 - 100 / this.props.slidesToShow) / 100);

this.setState({
frameWidth: frame.offsetWidth,
slideCount: this.props.children.length,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuka-carousel",
"version": "0.0.6",
"version": "0.0.7",
"description": "Pure React Carousel",
"main": "index.js",
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions src/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,17 @@ const Carousel = React.createClass({

setDimensions() {
var self = this, slideWidth, frame;

frame = React.findDOMNode(this.refs.frame);

if (typeof this.props.slideWidth !== 'number') {
slideWidth = parseInt(this.props.slideWidth);
} else {
slideWidth = (frame.offsetWidth / this.props.slidesToShow) * this.props.slideWidth;
}

slideWidth -= this.props.cellSpacing * ((100 - (100 / this.props.slidesToShow)) / 100);

this.setState({
frameWidth: frame.offsetWidth,
slideCount: this.props.children.length,
Expand Down

0 comments on commit 83f11f3

Please sign in to comment.