The Hopscotch example tour sets up the parameters and calls hopscotch.startTour(tour);
however neither the close "x" nor the "Done" buttons seem to prevent it from playing again after the page loads.
How can that be accomplished?
The Hopscotch example tour sets up the parameters and calls hopscotch.startTour(tour);
however neither the close "x" nor the "Done" buttons seem to prevent it from playing again after the page loads.
How can that be accomplished?
You can make use of localstorage/cookie on the onend function.
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value + ';path=/' + ';expires=' + expires.toUTCString();
};
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
};
var tour = {
onEnd: function() {
setCookie("toured", "toured");
},
onClose: function() {
setCookie("toured", "toured");
}
};
// Initialize tour if it's the user's first time
if (!getCookie("toured")) {
hopscotch.startTour(tour);
}