Labs64 / GuideChimp

Create interactive guided product tours in minutes with the most non-technical friendly, lightweight and extendable library.
https://www.labs64.com/guidechimp/
European Union Public License 1.2
204 stars 20 forks source link

JavaScript events plugin doesn't work (v3.x) #70

Closed r-brown closed 3 years ago

r-brown commented 3 years ago

Describe the bug https://codepen.io/netlicensing/pen/BazaXYo

v-rudkovskiy commented 3 years ago

Object "fromStep" at the first step in the version(> 3.0) instead of an empty object will be null. So you need to check formStep for null.

Change example: from

guideChimp.on('onBeforeChange', (to, from)=>{
  document.getElementById('log').innerHTML = 'log: ' + from.title + ' -> ' + to.title;
});

to

guideChimp.on('onBeforeChange', (to, from)=>{
  var fromTitle = (from) ? from.title : undefined;
  var toTitle = to.title;

  document.getElementById('log').innerHTML = 'log: ' + fromTitle + ' -> ' + toTitle;
});