[Common UI] Avoid apply-in-a-digest

Don't invoke  from mct-resize when first observing
an element's size during linking; observed issue in the
context of adding domain selector to time conductor.
This commit is contained in:
Victor Woeltjen 2015-09-23 17:22:32 -07:00
parent f182d1f2c4
commit 928e31b548

View File

@ -58,6 +58,7 @@ define(
// Link; start listening for changes to an element's size
function link(scope, element, attrs) {
var lastBounds,
linking = true,
active = true;
// Determine how long to wait before the next update
@ -74,7 +75,9 @@ define(
lastBounds.width !== bounds.width ||
lastBounds.height !== bounds.height) {
scope.$eval(attrs.mctResize, { bounds: bounds });
scope.$apply(); // Trigger a digest
if (!linking) { // Avoid apply-in-a-digest
scope.$apply();
}
lastBounds = bounds;
}
}
@ -101,6 +104,9 @@ define(
// Handle the initial callback
onInterval();
// Trigger scope.$apply on subsequent changes
linking = false;
}
return {