EragonJ / Trip.js

🚀 Trip.js is a plugin that can help you customize a tutorial trip easily with more flexibilities.

Home Page:https://eragonj.github.io/Trip.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When using nextClickSelector, events are triggered twice

EragonJ opened this issue · comments

Related discussions coming from #149 (comment)

@Tobysauce77

I have another issue with nextClickSelector that I could only fix by modifying trip.js code.

In setTripBlock where it sets up the "one" event for the nextClickSelector I added a line because something is making the "one" event trigger twice, so I added "e.stopImmediatePropagation();" to prevent it from triggering again. It makes no sense because it's using jquery's "one," so it should be triggering just once.

// if we have a nextClickSelector use that as the trigger for
// the next button
if (o.nextClickSelector) {
   $(o.nextClickSelector).one('click.Trip', function (e) {
      e.stopImmediatePropagation();
      e.preventDefault();
      // Force IE/FF to lose focus
      $(this).blur();
      that.next();
  });
}

Also, we are trying to stop the whole trip in our onTripEnd function, and stop resets the index, but tripEnd is called before increaseIndex, so it will set the index to 1 after resetting the index and act like it's on that trip instead of stopping the whole trip. Which events can we safely stop the whole trip?