mirror of
https://github.com/nasa/openmct.git
synced 2025-02-04 10:10:43 +00:00
[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:
parent
b7f4539cdb
commit
a9f7cc9658
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user