[Performance] Deactive mct-resize on destroy

Deactive mct-resize when its containing scope is destroyed;
that is, don't go on polling for size changes indefinitely.
Issue discovered/addressed in the context of investigating
sluggishness of plotting in WTD-717.
This commit is contained in:
Victor Woeltjen 2015-01-26 17:48:33 -08:00
parent b7f4539cdb
commit a9f7cc9658

View File

@ -35,7 +35,8 @@ define(
// Link; start listening for changes to an element's size
function link(scope, element, attrs) {
var lastBounds;
var lastBounds,
active = true;
// Determine how long to wait before the next update
function currentInterval() {
@ -62,9 +63,19 @@ define(
width: element[0].offsetWidth,
height: element[0].offsetHeight
});
$timeout(onInterval, currentInterval());
if (active) {
$timeout(onInterval, currentInterval());
}
}
// Stop running in the background
function deactivate() {
active = false;
}
// Unregister once out-of-scope
scope.$on("$destroy", deactivate);
// Handle the initial callback
onInterval();
}