Skip to content

Added autoplay and interval props#37

Open
GabrielCartier wants to merge 1 commit into
gutiguy:masterfrom
GabrielCartier:feature/autoplay
Open

Added autoplay and interval props#37
GabrielCartier wants to merge 1 commit into
gutiguy:masterfrom
GabrielCartier:feature/autoplay

Conversation

@GabrielCartier

Copy link
Copy Markdown

Heavily based on @Satyam-code143 version, also added a way to clear the timeout to avoid leaks.

Comment on lines +98 to +105
componentDidMount() {
const { autoplay, interval } = this.props;
if (autoplay) {
this.state.intervalId = setInterval(() => {
this.moveSlide(1);
}, interval);
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In my opinion it might be better to make autplay/interval prop changes affect the interval even after the component was mounted.

Comment on lines +123 to +125
if(this.state.intervalId) {
clearInterval(this.state.intervalId);
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
if(this.state.intervalId) {
clearInterval(this.state.intervalId);
}
if (this.state.intervalId) {
clearInterval(this.state.intervalId);
}

Comment thread src/dev/Playground.tsx
Comment on lines +13 to +14
autoplay: true,
interval: 2,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe we can just use interval here and default it to null or 0, this would simplify the API and prevent users from accidentally setting inconsistent prop values.

Comment thread package.json
{
"name": "react-spring-3d-carousel",
"version": "1.2.1",
"version": "1.3.1",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
"version": "1.3.1",
"version": "1.3.0",

@gutiguy

gutiguy commented Jul 1, 2022

Copy link
Copy Markdown
Owner

Looks pretty good overall, left some minor comments and would be happy to merge once they're addressed. Great work! 🎉

@GabrielCartier

Copy link
Copy Markdown
Author

Don't really have much time to spend on this, I had done this PR when I needed the lib for a specific project.

Will try to see if I can do the suggested changes, else, if anyone want to pick it up, feel free to :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants