-
-
Notifications
You must be signed in to change notification settings - Fork 62
Carousel machine with factory exports #62
base: master
Are you sure you want to change the base?
Carousel machine with factory exports #62
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/mattpocock/xstate-catalogue/4iZ8TszotYxSqTHArxNTWJw5yhmc |
Jeez, @andrewmcoupe - this is killer. |
Co-authored-by: Matt Pocock <mattpocockvoice@gmail.com>
I like this a lot! I'm a fan of the ole carousel! I do have a question though; carousels typically move in two directions, left and right. When I play with the machine and I Would it be better to split |
You can provide an index with the
|
Good catch! How would you determine the index to pass in the event? I see no logic for decreasing the index at the moment, only increasing or specifying it exactly. Am I being dumb here? I don't see how I would use this and go back to the previous slide unless I could do something like:
Then there is missing logic for when the index is Again, sorry if I am missing the obvious here! |
That is how I would imagine a previous slide button working, yes 👍 But you're right about the missing logic. I'll add that in, good spot 👁️ I've also added in
|
@andrewmcoupe Nice work! This looks like a super nice way to handle carousel slides! Long gone are the days of jQuery libraries 😂 |
The same changes as the Carousel PR but includes the ability to export a factory function as well as a standard state machine object.
This is a machine to manage the state and slide transitions for a carousel. This could be a carousel of any sort eg. image, content etc.
Happy to see alternative approaches to this kind of machine. I was thinking that an activity would be the best approach but events can't be sent inside an activity so I went for the approach advised by David here.