Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 5c129be

Browse files
fix(menubar): fix RTE with close dialogs invoked from menubar
Closes #5476
1 parent faa8b5b commit 5c129be

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/core/util/animation/animate.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
8888
calculateZoomToOrigin: function (element, originator) {
8989
var origin = originator.element;
9090
var bounds = originator.bounds;
91+
9192
var zoomTemplate = "translate3d( {centerX}px, {centerY}px, 0 ) scale( {scaleX}, {scaleY} )";
9293
var buildZoom = angular.bind(null, $mdUtil.supplant, zoomTemplate);
9394
var zoomStyle = buildZoom({centerX: 0, centerY: 0, scaleX: 0.5, scaleY: 0.5});
9495

9596
if (origin || bounds) {
96-
var originBnds = origin ? self.clientRect(origin) : self.copyRect(bounds);
97+
var originBnds = origin ? self.clientRect(origin) || currentBounds() : self.copyRect(bounds);
9798
var dialogRect = self.copyRect(element[0].getBoundingClientRect());
9899
var dialogCenterPt = self.centerPointFor(dialogRect);
99100
var originCenterPt = self.centerPointFor(originBnds);
@@ -109,6 +110,17 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
109110
}
110111

111112
return zoomStyle;
113+
114+
/**
115+
* This is a fallback if the origin information is no longer valid, then the
116+
* origin bounds simply becomes the current bounds for the dialogContainer's parent
117+
*/
118+
function currentBounds() {
119+
var cntr = element ? element.parent() : null;
120+
var parent = cntr ? cntr.parent() : null;
121+
122+
return parent ? self.clientRect(parent) : null;
123+
}
112124
},
113125

114126
/**
@@ -199,10 +211,10 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
199211
* Calculate 'rounded' center point of Rect
200212
*/
201213
centerPointFor: function (targetRect) {
202-
return {
214+
return targetRect ? {
203215
x: Math.round(targetRect.left + (targetRect.width / 2)),
204216
y: Math.round(targetRect.top + (targetRect.height / 2))
205-
}
217+
} : { x : 0, y : 0 };
206218
}
207219

208220
};

0 commit comments

Comments
 (0)