Intro.js: onExit callback is called twice when clicking the Skip button

Created on 31 Aug 2018  Â·  9Comments  Â·  Source: usablica/intro.js

Description

The onExit callback is called twice when clicking the Skip button.

Expected Behavior

The onExit callback should be called once whatever the way one exits.

Actual Behavior

The onExit callback is called twice when one uses the Skip button (before the last step according to code).

Errors and Screenshots (optional)

No

Example (recommended)

Set up an exit callback writing on the console. Push the Skip button on a multi-step introduction. Check the console.

Environment (optional)

According to code, everytime

Most helpful comment

@adamcoulombe Yeah I ended up modifying the plugin locally and changed how the skipTooltipButton event works.

Here is my solution

skipTooltipButton.onclick = function() {
  /** ModifiedBy: Alen
   *        When: 8/16/2019
   *         Bug: When using oncomplete event the onskip event would fire.
   *    Comments: Added check for isLastStep to the complete, exit, skip callbacks.
  */
  var isLastStep = self._introItems.length - 1 === self._currentStep;
  if (isLastStep && typeof (self._introCompleteCallback) === 'function') {
    self._introCompleteCallback.call(self);
  }

  if (!isLastStep && typeof (self._introExitCallback) === 'function') {
    self._introExitCallback.call(self);
  }

  if (!isLastStep && typeof(self._introSkipCallback) === 'function') {
    self._introSkipCallback.call(self);
  }

  _exitIntro.call(self, self._targetElement);
};

All 9 comments

After almost a year this is still an issue.

@subasically curious, did you look into any possible patch for this?

@adamcoulombe Yeah I ended up modifying the plugin locally and changed how the skipTooltipButton event works.

Here is my solution

skipTooltipButton.onclick = function() {
  /** ModifiedBy: Alen
   *        When: 8/16/2019
   *         Bug: When using oncomplete event the onskip event would fire.
   *    Comments: Added check for isLastStep to the complete, exit, skip callbacks.
  */
  var isLastStep = self._introItems.length - 1 === self._currentStep;
  if (isLastStep && typeof (self._introCompleteCallback) === 'function') {
    self._introCompleteCallback.call(self);
  }

  if (!isLastStep && typeof (self._introExitCallback) === 'function') {
    self._introExitCallback.call(self);
  }

  if (!isLastStep && typeof(self._introSkipCallback) === 'function') {
    self._introSkipCallback.call(self);
  }

  _exitIntro.call(self, self._targetElement);
};

Thanks for sharing your patch.

I wondered, when reviewing the code in this library, why there isn’t just an exclusive done button. It’s kind of a weird approach to modify the skip button, but oh well.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I just notice this when using the lib for the first week.. thought at first I was doing something wrong and started google it after 20 min of debugging.. please fix this issue. using v2.9.3

I will fix this in 3.0.1

On Fri 16 Oct 2020 at 11:37, LeonBeilis notifications@github.com wrote:

I just notice this when using the lib for the first week.. thought at
first I was doing something wrong and started google it after 20 min of
debugging.. please fix this issue. using v2.9.3

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/usablica/intro.js/issues/885#issuecomment-709967688,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AACMXVWX54O2E7R37ZAUHELSLAO63ANCNFSM4FSWHY3Q
.

Please install 3.0.1 and let me know if the issue is fixed. Thanks and apologies for the delay.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pehuensolari picture pehuensolari  Â·  5Comments

namgiang picture namgiang  Â·  6Comments

alexandernst picture alexandernst  Â·  5Comments

Floby picture Floby  Â·  4Comments

amanshu-kataria picture amanshu-kataria  Â·  9Comments