Skip to content

Commit

Permalink
Merge pull request #186 from playing/master
Browse files Browse the repository at this point in the history
fix float calculation  error
  • Loading branch information
d-inoue authored Jul 17, 2016
2 parents e66ef8f + 186aff3 commit 75f0de2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ module.exports = _react2.default.createClass({
// Note: if touch very very quickly and continuous,
// the variation of `index` more than 1.
// parseInt() ensures it's always an integer
index = parseInt(index + diff / step);
index = parseInt(index + Math.round(diff / step));

if (this.props.loop) {
if (index <= -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ module.exports = React.createClass({
let { offset, index } = this.state
let previousOffset = horizontal ? offset.x : offset.y
let newOffset = horizontal ? contentOffset.x : contentOffset.y

if (previousOffset === newOffset && (index === 0 || index === children.length - 1)) {
this.setState({
isScrolling: false
Expand All @@ -322,7 +322,7 @@ module.exports = React.createClass({
// Note: if touch very very quickly and continuous,
// the variation of `index` more than 1.
// parseInt() ensures it's always an integer
index = parseInt(index + diff / step)
index = parseInt(index + Math.round(diff / step))

if(this.props.loop) {
if(index <= -1) {
Expand Down

0 comments on commit 75f0de2

Please sign in to comment.