Skip to content

Commit efc57e6

Browse files
committed
Merge pull request #89 from circlingthesun/modal-fix
Modal fix
2 parents 1e58dfe + cb55eda commit efc57e6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/modal/modal.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
106106
}
107107
else{
108108
// otherwise focus the freshly-opened modal
109-
element[0].focus();
109+
element[0].querySelector('div').focus();
110110
}
111111
});
112112
}
113113
};
114114
}])
115115

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) {
118118

119119
var OPENED_MODAL_CLASS = 'modal-open';
120120

@@ -229,7 +229,16 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
229229
body.append(backdropDomEl);
230230
}
231231

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>');
233242
angularDomEl.attr('window-class', modal.windowClass);
234243
angularDomEl.attr('index', openedWindows.length() - 1);
235244
angularDomEl.attr('animate', 'animate');

template/modal/window.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div tabindex="-1" class="reveal-modal fade {{ windowClass }}"
22
ng-class="{in: animate}" ng-click="close($event)"
3-
style="display: block; position: fixed; visibility: visible">
3+
style="display: block; visibility: visible">
44
<div ng-transclude></div>
55
</div>

0 commit comments

Comments
 (0)