From 954dd081478af0100182632390c8b0a43845eaa9 Mon Sep 17 00:00:00 2001 From: Edelcio Molina Date: Tue, 10 Jan 2017 22:13:31 -0200 Subject: [PATCH 1/2] Add callback to Next and Prev when pressed --- src/js/hopscotch.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index aa7b0ade..0dc52b1d 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1971,7 +1971,12 @@ * @param {Boolean} doCallbacks Flag for invoking onPrev callback. Defaults to true. * @returns {Object} Hopscotch */ - this.prevStep = function(doCallbacks) { + this.prevStep = function (doCallbacks) { + + //forcing callback + var step = getCurrStep(); + if (typeof step.onPrev == 'function') step.onPrev(); + changeStep.call(this, doCallbacks, -1); return this; }; @@ -1984,7 +1989,12 @@ * @param {Boolean} doCallbacks Flag for invoking onNext callback. Defaults to true. * @returns {Object} Hopscotch */ - this.nextStep = function(doCallbacks) { + this.nextStep = function (doCallbacks) { + + //forcing callback + var step = getCurrStep(); + if (typeof step.onNext == 'function') step.onNext(); + changeStep.call(this, doCallbacks, 1); return this; }; From 8c7f54ae1963cb3b40aa4dd795793e0860b30906 Mon Sep 17 00:00:00 2001 From: Edelcio Molina Date: Tue, 10 Jan 2017 23:54:05 -0200 Subject: [PATCH 2/2] Checking if step exists before to continue --- src/js/hopscotch.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 0dc52b1d..d8854ef8 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1589,6 +1589,7 @@ doCallbacks = utils.valOrDefault(doCallbacks, true); step = getCurrStep(); + if (typeof step == 'undefined') return; if (step.nextOnTargetClick) { // Detach the listener when tour is moving to a different step