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

Commit 8134776

Browse files
committed
Added onbeforechange callback
1 parent 2659b96 commit 8134776

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

intro.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@
159159
* @method _nextStep
160160
*/
161161
function _nextStep() {
162+
if (typeof (this._introBeforeChangeCallback) !== 'undefined') {
163+
this._introBeforeChangeCallback.call(this, this._targetElement);
164+
}
165+
162166
if (typeof (this._currentStep) === 'undefined') {
163167
this._currentStep = 0;
164168
} else {
@@ -189,6 +193,10 @@
189193
return false;
190194
}
191195

196+
if (typeof (this._introBeforeChangeCallback) !== 'undefined') {
197+
this._introBeforeChangeCallback.call(this, this._targetElement);
198+
}
199+
192200
_showElement.call(this, this._introItems[--this._currentStep]);
193201
}
194202

@@ -702,6 +710,14 @@
702710
exit: function() {
703711
_exitIntro.call(this, this._targetElement);
704712
},
713+
onbeforechange: function(providedCallback) {
714+
if (typeof (providedCallback) === 'function') {
715+
this._introBeforeChangeCallback = providedCallback;
716+
} else {
717+
throw new Error('Provided callback for onbeforechange was not a function');
718+
}
719+
return this;
720+
},
705721
onchange: function(providedCallback) {
706722
if (typeof (providedCallback) === 'function') {
707723
this._introChangeCallback = providedCallback;

0 commit comments

Comments
 (0)