Auto advance instead of more controlled tours?
I'm looking at setting up more controlled tours and it seems to be prone to coding error simply because code is involved.
I think we could use DOM mutation events and CSS selectors to determine when to advance.
Most of my controlled tour ideas are something like "click this element, then click this button" each of which mutate the DOM and expose a new Element.
Could we handle this by having the next step automatically advanced once its selector becomes available?
Maybe something like waitFor or autoActivate props on the step?
One issue is which steps gets these props. N or N+1 ?
If it's N then we have to peek at the selector on the next step and then advance once the DOM is mutated and the selector becomes available.
This also avoids a ton of duplicated complexity with adding event listeners by yourself and other complexity when setting up the tour.
That's something I really don't want to add to this package and exactly why I added the controlled mode.
This will increases complexity and generate tons of issues that I don't have time to deal with. I've spent over 300 hours getting V2 ready and I need to focus on other projects now.
Thanks
Fair enough. I think I can do it in like 50 to 100 lines code and keep it super simple. If you like it I can clean it up and send a pr or something
You can post the code here, it might help some other users. [s]
@burtonator curious if you've been able to add that functionality?
@kwynns I sort of implemented something from scratch and I can post the link to it but it would need to be lifted out ...
@burtonator that would be extremely helpful. Would appreciate a head start if only by looking at how you accomplished that.
Code should be here.
It's probably split up across 2-3 files though.
https://github.com/burtonator/polar-bookshelf/blob/bce5f13fd2f0aac3a7ef312b9e0dbb461c290f1a/web/js/apps/repository/RepositoryTour.tsx
@kwynns You just need a MutationObserver on the callback that will wait for the target to appear and then increment the stepIndex.