Skip to content

Commit f58a55b

Browse files
authored
Merge pull request #23 from Locutus83/create-deconstructor
Add a destructor
2 parents 953e434 + 3387d36 commit f58a55b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/jTimeout.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
timeout.setMouseTimeout(window.setTimeout(function ()
181181
{
182182
//on mouse move
183-
$('body').on('mousemove', function ()
183+
$('body').on('mousemove.jTimeout', function ()
184184
{
185185
if (!timeout.mouseMoved && timeout.resetOnAlert())
186186
{
@@ -245,6 +245,16 @@
245245
timeout.stopPriorCountdown();
246246
timeout.hideCountdownAlert();
247247
}
248+
},
249+
/* When you are all done, destroy all the timers -- or just let the user navigate away from the page. */
250+
destructor: function () {
251+
timeout.stopFlashing();
252+
timeout.stopActivityMonitoring();
253+
delete timeout.options.onSessionExtended;
254+
delete timeout.countdown;
255+
256+
// Remove the event handlers
257+
$('body').off('mousemove.jTimeout');
248258
}
249259
};
250260

0 commit comments

Comments
 (0)