@@ -106,15 +106,15 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
106
106
}
107
107
else {
108
108
// otherwise focus the freshly-opened modal
109
- element [ 0 ] . focus ( ) ;
109
+ element [ 0 ] . querySelector ( 'div' ) . focus ( ) ;
110
110
}
111
111
} ) ;
112
112
}
113
113
} ;
114
114
} ] )
115
115
116
- . factory ( '$modalStack' , [ '$transition' , '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' ,
117
- function ( $transition , $timeout , $document , $compile , $rootScope , $$stackedMap ) {
116
+ . factory ( '$modalStack' , [ '$window' , '$ transition', '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' ,
117
+ function ( $window , $ transition, $timeout , $document , $compile , $rootScope , $$stackedMap ) {
118
118
119
119
var OPENED_MODAL_CLASS = 'modal-open' ;
120
120
@@ -229,7 +229,16 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
229
229
body . append ( backdropDomEl ) ;
230
230
}
231
231
232
- var angularDomEl = angular . element ( '<div modal-window></div>' ) ;
232
+ // Create a faux modal div just to measure its
233
+ // distance to top
234
+ var faux = angular . element ( '<div class="reveal-modal" style="z-index:-1""></div>' ) ;
235
+ body . append ( faux [ 0 ] ) ;
236
+ var marginTop = parseInt ( getComputedStyle ( faux [ 0 ] ) . top ) ;
237
+ faux . remove ( ) ;
238
+
239
+ var openAt = $window . scrollY + marginTop ;
240
+
241
+ var angularDomEl = angular . element ( '<div modal-window style="visibility: visible; top:' + openAt + 'px;"></div>' ) ;
233
242
angularDomEl . attr ( 'window-class' , modal . windowClass ) ;
234
243
angularDomEl . attr ( 'index' , openedWindows . length ( ) - 1 ) ;
235
244
angularDomEl . attr ( 'animate' , 'animate' ) ;
0 commit comments