Skip to content

Commit

Permalink
Fix placeCritical re #183
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-r committed May 23, 2018
1 parent dde2103 commit de3fc82
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,19 @@ export default class Carousel extends Component {

_placeCritical = (page) => {
const { isLooped } = this.props;
if (isLooped) {
const { childrenLength, size: { width } } = this.state;
if (childrenLength === 1) {
this._scrollTo({ offset: 0, animated: false });
} else if (page === 0) {
this._scrollTo({ offset: childrenLength * width, animated: false });
const { childrenLength, size: { width } } = this.state;
let offset = 0;
// if page number is bigger then length - something is incorrect
if (page < childrenLength) {
if (page === 0 && isLooped) {
// in "looped" scenario first page shold be placed after the last one
offset = childrenLength * width;
} else {
this._scrollTo({ offset: page * width, animated: false });
offset = page * width;
}
}

this._scrollTo({ offset, animated: false });
}

_normalizePageNumber = (page) => {
Expand Down

2 comments on commit de3fc82

@008v
Copy link

@008v 008v commented on de3fc82 Apr 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue was solved, but it created another issue. see #287

@008v
Copy link

@008v 008v commented on de3fc82 Apr 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete the following code to resolve:

         else {
	        this._scrollTo({ offset: page * width, animated: false });
	        offset = page * width;
	  }

Please sign in to comment.