mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +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:
@ -35,7 +35,8 @@ define(
|
|||||||
|
|
||||||
// Link; start listening for changes to an element's size
|
// Link; start listening for changes to an element's size
|
||||||
function link(scope, element, attrs) {
|
function link(scope, element, attrs) {
|
||||||
var lastBounds;
|
var lastBounds,
|
||||||
|
active = true;
|
||||||
|
|
||||||
// Determine how long to wait before the next update
|
// Determine how long to wait before the next update
|
||||||
function currentInterval() {
|
function currentInterval() {
|
||||||
@ -62,8 +63,18 @@ define(
|
|||||||
width: element[0].offsetWidth,
|
width: element[0].offsetWidth,
|
||||||
height: element[0].offsetHeight
|
height: element[0].offsetHeight
|
||||||
});
|
});
|
||||||
|
if (active) {
|
||||||
$timeout(onInterval, currentInterval());
|
$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
|
// Handle the initial callback
|
||||||
onInterval();
|
onInterval();
|
||||||
|
Reference in New Issue
Block a user