Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Add callback to Next and Prev when pressed #311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/js/hopscotch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1971,7 +1972,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;
};
Expand All @@ -1984,7 +1990,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;
};
Expand Down