Skip to content

Commit 38fb008

Browse files
committed
Merge pull request usablica#412 from mindblender/exit_callback_not_getting_called
The onExitCallback was not getting called when pressing Esc or clicking ...
2 parents c1a5d39 + 6fd0378 commit 38fb008

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

intro.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@
195195
self._onKeyDown = function(e) {
196196
if (e.keyCode === 27 && self._options.exitOnEsc == true) {
197197
//escape key pressed, exit the intro
198-
_exitIntro.call(self, targetElm);
199-
//check if any callback is defined
198+
//check if exit callback is defined
200199
if (self._introExitCallback != undefined) {
201200
self._introExitCallback.call(self);
202201
}
202+
_exitIntro.call(self, targetElm);
203203
} else if(e.keyCode === 37) {
204204
//left arrow
205205
_previousStep.call(self);
@@ -214,6 +214,13 @@
214214
_previousStep.call(self);
215215
} else if (target && target.className.indexOf('introjs-skipbutton') > 0) {
216216
//user hit enter while focusing on skip button
217+
if (self._introItems.length - 1 == self._currentStep && typeof (self._introCompleteCallback) === 'function') {
218+
self._introCompleteCallback.call(self);
219+
}
220+
//check if any callback is defined
221+
if (self._introExitCallback != undefined) {
222+
self._introExitCallback.call(self);
223+
}
217224
_exitIntro.call(self, targetElm);
218225
} else {
219226
//default behavior for responding to enter
@@ -1072,12 +1079,12 @@
10721079

10731080
overlayLayer.onclick = function() {
10741081
if (self._options.exitOnOverlayClick == true) {
1075-
_exitIntro.call(self, targetElm);
10761082

10771083
//check if any callback is defined
10781084
if (self._introExitCallback != undefined) {
10791085
self._introExitCallback.call(self);
10801086
}
1087+
_exitIntro.call(self, targetElm);
10811088
}
10821089
};
10831090

0 commit comments

Comments
 (0)