From 54dda91726d136b5371bc605aae578b4538135c9 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Fri, 8 Apr 2016 17:27:02 +0200 Subject: [PATCH] fix issue with show/hide callbacks --- js/main.js | 6 ++++-- js/module.js | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index 9fb5415c..ed89826e 100644 --- a/js/main.js +++ b/js/main.js @@ -162,7 +162,8 @@ var MM = (function() { moduleWrapper.style.transition = "opacity " + speed / 1000 + "s"; moduleWrapper.style.opacity = 0; - setTimeout(function() { + clearTimeout(module.showHideTimer); + module.showHideTimer = setTimeout(function() { // To not take up any space, we just make the position absolute. // since it's fade out anyway, we can see it lay above or // below other modules. This works way better than adjusting @@ -189,7 +190,8 @@ var MM = (function() { moduleWrapper.style.position = "static"; moduleWrapper.style.opacity = 1; - setTimeout(function() { + clearTimeout(module.showHideTimer); + module.showHideTimer = setTimeout(function() { if (typeof callback === "function") { callback(); } }, speed); diff --git a/js/module.js b/js/module.js index ab0f8ad3..9be652bf 100644 --- a/js/module.js +++ b/js/module.js @@ -17,6 +17,9 @@ var Module = Class.extend({ // Module config defaults. defaults: {}, + // Timer reference used for showHide animation callbacks. + showHideTimer: null, + /* init() * Is called when the module is instantiated. */