Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Deferred tour starting misses stepNum argument #321

Open
NickHeiner opened this issue Feb 28, 2017 · 2 comments
Open

Deferred tour starting misses stepNum argument #321

NickHeiner opened this issue Feb 28, 2017 · 2 comments
Labels

Comments

@NickHeiner
Copy link

startTour() accepts a stepNum argument:

this.startTour = function(tour, stepNum) {

If the document is not ready, the following code runs:

      // If document isn't ready, wait for it to finish loading.
      // (so that we can calculate positioning accurately)
      if (!utils.documentIsReady()) {
        waitingToStart = true;
        return this;
      }

waitingToStart is used here:

  /**
   * Called when the page is done loading.
   *
   * @private
   */
  winLoadHandler = function() {
    if (waitingToStart) {
      winHopscotch.startTour();
    }
  };

If the user passed stepNum to the original call to startTour(), then that value will be ignored in winLoadHandler, where startTour() is called with no arguments.

I observed this in 0.2.7.

Thanks!

@kirilloid
Copy link

kirilloid commented Oct 23, 2017

Still reproducible in the latest 0.3.1, worked around, wrapping startTour call in window.onload callback—doesn't work with DOMContentReady.

@Pinolo
Copy link

Pinolo commented Dec 1, 2017

I think the root problem with this issue is inconsistency in what different browsers call "ready". I've seen a use case with lots of ajax-loading elements in a page, where Firefox had window.readyState with value "complete", while Chrome had value "interactive", thus triggering the reload of the library without the provided arguments about current step. The fix should involve making sure the passed arguments for startTour() are optionally handled when the main object is returned.

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

No branches or pull requests

4 participants