Skip to content
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

tour multi page #129

Open
brusand opened this issue May 23, 2017 · 8 comments
Open

tour multi page #129

brusand opened this issue May 23, 2017 · 8 comments

Comments

@brusand
Copy link

brusand commented May 23, 2017

hi Ben

i have some issue with multi pages.

I am using the exact versions of the following:

Browser: [Chome|Firefox|IE|Safari] Version 58.0.3029.110 (64-bit)
AngularJS: "angular": "1.5.5"
Angular Bootstrap:" angular-ui-bootstrap": "1.3.3"
Angular UI Tour: "angular-ui-tour": "^0.8.1",
I have installed this library via: (NPM, Bower, or downloaded package)
npm
I have observed the following behavior:
this.$state.go(path);
return this.welcome.waitFor(stepId); => error : no step

This is how I expected it to behave:
the new page with the step viewed

Here is my tour config, and all related step configs:

var tourConfig = {};
<div ui-tour></div>
page 1:
<div ui-tour="help"
ui-tour-on-ready="$ctrl.startTourOnFirstVisit()"
ui-tour-popup-class="onboarding"
ui-tour-template-url="'onboarding.tpl.html'";
ui-tour-backdrop="true"
>

  <div
    tour-step="step1"
    tour-step-title="lo.onboarding.tour.title"
    tour-step-content="lo.onboarding.tour.description"
    tour-step-on-next="$ctrl.navigateToAndWaitFor('welcome', 'lo.app.auth.dashboard', 'dashboard')">
  </div>
</div>

page 2:
<nav id="header-bottom" class="navbar navbar-default navbar-secondary" ng-show="$ctrl.isAuth" role="navigation"
      ui-tour="welcome"
      ui-tour-popup-class="onboarding"
      ui-tour-template-url="'onboarding.tpl.html'"
      ui-tour-backdrop="true"
      >
    <div class="navbar-header">
      <!-- Brand and toggle get grouped for better mobile display -->
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu">
        <span class="sr-only">Toggle navigation</span>
        <span class="glyphicon glyphicon-menu-hamburger"></span>
      </button>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="main-menu">
      <ul class="nav navbar-nav">
        <!-- HOME DASHBOARD-->
        <li
          cmn-state-active="lo.app.auth.dashboard">

          <a id="dashboard-nav-link" href="#/dashboard" ng-show="!$ctrl.rights.TENANT.WRITE">
            <i class="fa fa-lg lte-icon-home hidden-xs" aria-hidden="false" aria-label="Home"></i>
            <span class="visible-xs" translate="lo.menu.home">Home</span>
          </a>
          <div
             tour-step="dashboard"
             tour-step-title="{{'lo.onboarding.dashboard.title' | translate }}"
             tour-step-content="{{'lo.onboarding.dashboard.description' | translate }}"
             tour-step-placement="bottom-left"
             >
            </div>
        </li>
       ...

**Additional notes/code:**
in my page 1 controller, here my code sequence :

    public startTourOnFirstVisit= () => {   => onReady()
      // TODO: test if first visit
      console.log("tour start");
      this.help = this.uiTourService.getTourByName('help'); => page 1
      this.welcome = this.uiTourService.getTourByName('welcome'); => page 2
      var help_steps = this.help._getSteps();
      var welcome_steps = this.welcome._getSteps();
      //this.welcome.startAt("dashboard");  => when uncomment it works well (page 2 step : 'dashboard')
      this.navigateToAndWaitFor('welcome','lo.app.auth.dashboard','dashboard');
    }
    public navigateToAndWaitFor = ( _tour, path, stepId) => { when click on next button of page1:step1)
      //var tour = this.uiTourService.getTourByName(_tour). => KO (return undefined but works well in startTourOnFirstVisit()
      this.$state.go(path); // go to page 2
      return this.welcome.waitFor(stepId); => FAILED return no step (but works well in startTourOnFirstVisit()

    }

any idea ?
Bruno
@benmarch
Copy link
Owner

Hey Bruno,

There are a couple things that might cause this issue. The first is that you are navigating from one tour to another (from the "help" tour to the "welcome" tour). I haven't tried this, so I don't know if it works or not. The other thing is that the "welcome" tour is defined on page 2, so it's possible that the tour is not yet defined when you try to get a reference to it. I generally recommend only using a single tour, but if you have to use multiple tours then they really shouldn't interact.

-Ben

@brusand
Copy link
Author

brusand commented May 23, 2017

hey Ben

yes i understood that so now i place a single ui-tour on an it works better.
howewer i still have 2 smaller issues :

. i don t know if it works like that, but is it possible to use .waitfor() with a url to show sub screen of the step ?
public navigateToAndWaitFor = ( _tour, path, stepId) => { when click on next button of page1:step1)
//var tour = this.uiTourService.getTourByName(_tour). => KO (return undefined but works well in startTourOnFirstVisit()
this.$state.go(path); // go to page 2
return this.welcome.waitFor(stepId); => FAILED return no step (but works well in startTourOnFirstVisit()

. how to reference _getSteps() in the popover template (template-url) html ? is there a global instance of uiTourService ? ($scope ? ; $ctrl ?)

thx

@benmarch
Copy link
Owner

You can only use waitFor with a step, but you can navigate using any library (as long as it doesn't do a full browser reload). Basically, waitFor doesn't care what you do when you wait, it just sets up a listener that resumes the tour when the specified step is found.

You can reference _getSteps() on the tour object (this.welcome._getSteps()) so if you have the tour object available in the HTML then you can use that to get the reference.

@brusand
Copy link
Author

brusand commented May 23, 2017

last question,, waitFor() finally is not adapted to my case, i think i d better catch the stepChanged notification but how ( both failed) ?
tour-on-step-changed="$ctrl.go('lo.app.auth.dashboard')"> ?
tour-step-on-step-changed="$ctrl.go('lo.app.auth.dashboard')"> ?

i tried tour-step-on-next="navigateToAndWaitFor(tour, 'page2', 'stepTwo') but stepTwo is already defined.
if i do $state.go() and tour.goTo(stepTwo) the tour start step2 as step 1 (and not as 2).
if i do $state.go() and tour.next() the tourStep loop (go to navigateToAndWaitFor() notification again) .
thx
Bruno

@benmarch
Copy link
Owner

So the events are a little different from the lifecycle hooks. You would use the stepChanged event like this:

//somewhere in your controller
tour.on('stepChanged', () => ...);

//later, be sure to turn it off!
tour.off('stepChanged'[,optionalReferenceToFunction])

More information here: https://github.com/benmarch/angular-ui-tour#tour-notifications

This is the EventEmitter documentation (the tour itself is an event emitter): https://github.com/benmarch/ez-ng#module_ezNg.ezEventEmitter..EventEmitter

@benmarch
Copy link
Owner

Hey @brusand, any updates?

@anupbelambe
Copy link

Not able to get the multi-page tours to be working with angular-ui-tour version 0.8.2.

As specified in the documentation, added api to navigate to new page and add waitfor().

Page 1:
<tour-step="stepEntry" tour-step-title="Step 1 Title" tour-step-content="Step 1 content" tour-step-order="4" tour-step-placement="bottom-right" tour-step-on-next="ctrl.navigateToAndWaitFor('tourName', 'page2', 'stepTarget')">

Page 1 ctrl:
this.navigateToAndWaitFor = function (tour, path, stepId) {
var uitour = uiTourService.getTourByName(tour);
$state.go('targetPage2', { param: data });
return uitour.waitFor(stepId);
};

Page 2:

Following is sequence of events seen on pressing next in Page 1 tour popup

  1. navigateToAndWaitFor() is called
  2. waitFor is called on given stepId "stepTarget"
  3. ended event is called
  4. paused event is called
  5. After navigating to Page 2, stepAdded event is called.

But the tour step in page 2 is getting added but not shown. Not sure if I have missed something. Any pointers are appreciated. Are there any sample which I can refer to?

@anupbelambe
Copy link

Found the root cause

It was due to enabling navigation interceptors and step placement
module.config(function (TourConfigProvider) {
TourConfigProvider.enableNavigationInterceptors();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants