EragonJ / Trip.js

🚀 Trip.js is a plugin that can help you customize a tutorial trip easily with more flexibilities.
https://eragonj.github.io/Trip.js/
MIT License
793 stars 111 forks source link

When using nextClickSelector, events are triggered twice #150

Closed EragonJ closed 8 years ago

EragonJ commented 8 years ago

Related discussions coming from https://github.com/EragonJ/Trip.js/issues/149#issuecomment-196866746

@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?