Skip to content

Commit 75f0de2

Browse files
author
d-inoue
authored
Merge pull request #186 from playing/master
fix float calculation error
2 parents e66ef8f + 186aff3 commit 75f0de2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ module.exports = _react2.default.createClass({
338338
// Note: if touch very very quickly and continuous,
339339
// the variation of `index` more than 1.
340340
// parseInt() ensures it's always an integer
341-
index = parseInt(index + diff / step);
341+
index = parseInt(index + Math.round(diff / step));
342342

343343
if (this.props.loop) {
344344
if (index <= -1) {

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ module.exports = React.createClass({
296296
let { offset, index } = this.state
297297
let previousOffset = horizontal ? offset.x : offset.y
298298
let newOffset = horizontal ? contentOffset.x : contentOffset.y
299-
299+
300300
if (previousOffset === newOffset && (index === 0 || index === children.length - 1)) {
301301
this.setState({
302302
isScrolling: false
@@ -322,7 +322,7 @@ module.exports = React.createClass({
322322
// Note: if touch very very quickly and continuous,
323323
// the variation of `index` more than 1.
324324
// parseInt() ensures it's always an integer
325-
index = parseInt(index + diff / step)
325+
index = parseInt(index + Math.round(diff / step))
326326

327327
if(this.props.loop) {
328328
if(index <= -1) {

0 commit comments

Comments
 (0)