-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make the carousel map play automatically? #48
Comments
Sorry, the code format seems to have some problems. |
@jiameng123 const carousel = scene.newItem(".carousel", { selector: true });
// scene.getItem(".carousel")
carousel.set({
"0": {
transform: {
translateX: prevPos + "px"
}
},
"1": {
transform: {
translateX: `${current * -parseFloat(width)}` + "px"
}
}
}); |
No, I want to know how to make the carousel map play automatically. I can't control this property via autoplay because I didn't set the keyframes property when I first loaded it. |
@jiameng123 Oh, maybe you use |
Yes, I am using react-scenejs. Because in the component, I didn't set the keyframs, all I can't use the Now my solution is to call Scene.ref.current.play() in setInterval to control autoplay. I can't think of other ways. |
@jiameng123 Unfortunately, the role of autoplay now cannot do that. Is there any way you want to use it? I'll take a look at improving it. |
In
The above code is invalid, same is true for keyFrames, which cannot be modified by state. in React, this is invalid. I just call scene.play() by calling the scene's ref in the timer. I don't know if I said it clearly. If necessary, I can reproduce these situations in the codepen. |
@jiameng123 Oh, i see. Keyframes is not going to be easy. But I can do |
I have a suggestion, can I replace autoplay with the paly attribute |
@jiameng123 |
Ok, thank you very much, no matter what, thanks to Scene.js At the same time, I hope to add some simple demos to the react-scenejs, such as the carousel map or the progress bar. This will attract some beginners or more people to use react-scenejs. Finally, thanks again. |
@jiameng123
render() {
const { ready, keyframes} = this.state;
return (<Scene keyframes={keyframes} ready={ready} autoplay >...</Scene>)
}
anywhere() {
this.setState({
ready: true,
keyframes: { ... },
});
} |
Thank you very much, this feature has helped me a lot. |
I created a carousel component through the scenery package of scenejs. It works fine when I click on the next or previous one, but I don't know how to make it play automatically, because I didn't set jsx during initialization. The keyframes property is used instead of code:
` React.useEffect(() => {
const scene = (SceneRef as any).current;
so what do I need to do? Thank you
The text was updated successfully, but these errors were encountered: