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

Commit

Permalink
fix(menubar): fix RTE with close dialogs invoked from menubar
Browse files Browse the repository at this point in the history
Closes #5476
  • Loading branch information
ThomasBurleson committed Oct 31, 2015
1 parent faa8b5b commit 5c129be
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/core/util/animation/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
calculateZoomToOrigin: function (element, originator) {
var origin = originator.element;
var bounds = originator.bounds;

var zoomTemplate = "translate3d( {centerX}px, {centerY}px, 0 ) scale( {scaleX}, {scaleY} )";
var buildZoom = angular.bind(null, $mdUtil.supplant, zoomTemplate);
var zoomStyle = buildZoom({centerX: 0, centerY: 0, scaleX: 0.5, scaleY: 0.5});

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

return zoomStyle;

/**
* This is a fallback if the origin information is no longer valid, then the
* origin bounds simply becomes the current bounds for the dialogContainer's parent
*/
function currentBounds() {
var cntr = element ? element.parent() : null;
var parent = cntr ? cntr.parent() : null;

return parent ? self.clientRect(parent) : null;
}
},

/**
Expand Down Expand Up @@ -199,10 +211,10 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
* Calculate 'rounded' center point of Rect
*/
centerPointFor: function (targetRect) {
return {
return targetRect ? {
x: Math.round(targetRect.left + (targetRect.width / 2)),
y: Math.round(targetRect.top + (targetRect.height / 2))
}
} : { x : 0, y : 0 };
}

};
Expand Down

0 comments on commit 5c129be

Please sign in to comment.