react-joyride icon indicating copy to clipboard operation
react-joyride copied to clipboard

Auto advance instead of more controlled tours?

Open InputNeuron opened this issue 7 years ago • 8 comments

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.

InputNeuron avatar Feb 24 '19 17:02 InputNeuron

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

gilbarbara avatar Feb 24 '19 18:02 gilbarbara

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

InputNeuron avatar Feb 24 '19 19:02 InputNeuron

You can post the code here, it might help some other users. [s]

gilbarbara avatar Feb 25 '19 23:02 gilbarbara

@burtonator curious if you've been able to add that functionality?

kwynns avatar Jun 04 '19 18:06 kwynns

@kwynns I sort of implemented something from scratch and I can post the link to it but it would need to be lifted out ...

InputNeuron avatar Jun 04 '19 18:06 InputNeuron

@burtonator that would be extremely helpful. Would appreciate a head start if only by looking at how you accomplished that.

kwynns avatar Jun 04 '19 19:06 kwynns

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

InputNeuron avatar Jun 06 '19 00:06 InputNeuron

@kwynns You just need a MutationObserver on the callback that will wait for the target to appear and then increment the stepIndex.

gilbarbara avatar Jun 06 '19 00:06 gilbarbara