nzTour icon indicating copy to clipboard operation
nzTour copied to clipboard

How do check if a tour is active?

Open jornncc opened this issue 8 years ago • 5 comments

The api doesn't explain how I should check if a tour is currently active. Trying to advance the tour automatically when the user interacts with the ui (via nzTour.gotoStep()) but if the tour is currently not active, then we get this error:

screen shot 2016-05-20 at 9 07 01 am

jornncc avatar May 20 '16 16:05 jornncc

I've seen that error in the past too. I'm actually looking at bringing nz-tour into the framework agnostic world right now, as I recently started using Jumpsuit (react/redux) instead of angular. I'm not sure how quick I can get this fixed, so if you or anyone out there wants to spearhead this, my appreciation would go far.

tannerlinsley avatar May 20 '16 17:05 tannerlinsley

Great. In-App-Tour is a POC for us at the moment, but if I get product management onboard with this project and decide to fold this into the app as a proper feature then I can help out with adding a few methods to the service api.

jornncc avatar May 20 '16 17:05 jornncc

The nzTour service has a current parameter that's used internally. It's set to false by default (and when the tour stops or finishes) and is set to an object while the tour is active (on start).

So maybe you could use the truthiness of current in the meantime? This plunker prints out current before and after start.

lebolo avatar Jun 09 '16 17:06 lebolo

Would be nice to have a more public API for this, maybe harden some of the code? Keeping this issue open as an enhancement request.

lebolo avatar Jun 27 '16 13:06 lebolo

For posterity:

$scope.start = function() {
  console.log(nzTour.current, !!nzTour.current); // false
  nzTour.start(tour);
  console.log(nzTour.current, !!nzTour.current); // true
};

timelf123 avatar Aug 16 '16 14:08 timelf123