@@ -88,12 +88,13 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
88
88
calculateZoomToOrigin : function ( element , originator ) {
89
89
var origin = originator . element ;
90
90
var bounds = originator . bounds ;
91
+
91
92
var zoomTemplate = "translate3d( {centerX}px, {centerY}px, 0 ) scale( {scaleX}, {scaleY} )" ;
92
93
var buildZoom = angular . bind ( null , $mdUtil . supplant , zoomTemplate ) ;
93
94
var zoomStyle = buildZoom ( { centerX : 0 , centerY : 0 , scaleX : 0.5 , scaleY : 0.5 } ) ;
94
95
95
96
if ( origin || bounds ) {
96
- var originBnds = origin ? self . clientRect ( origin ) : self . copyRect ( bounds ) ;
97
+ var originBnds = origin ? self . clientRect ( origin ) || currentBounds ( ) : self . copyRect ( bounds ) ;
97
98
var dialogRect = self . copyRect ( element [ 0 ] . getBoundingClientRect ( ) ) ;
98
99
var dialogCenterPt = self . centerPointFor ( dialogRect ) ;
99
100
var originCenterPt = self . centerPointFor ( originBnds ) ;
@@ -109,6 +110,17 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
109
110
}
110
111
111
112
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
+ }
112
124
} ,
113
125
114
126
/**
@@ -199,10 +211,10 @@ function AnimateDomUtils($mdUtil, $q, $timeout, $mdConstant, $animateCss) {
199
211
* Calculate 'rounded' center point of Rect
200
212
*/
201
213
centerPointFor : function ( targetRect ) {
202
- return {
214
+ return targetRect ? {
203
215
x : Math . round ( targetRect . left + ( targetRect . width / 2 ) ) ,
204
216
y : Math . round ( targetRect . top + ( targetRect . height / 2 ) )
205
- }
217
+ } : { x : 0 , y : 0 } ;
206
218
}
207
219
208
220
} ;
0 commit comments