Skip to content

Modal fix #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
}
else{
// otherwise focus the freshly-opened modal
element[0].focus();
element[0].querySelector('div').focus();
}
});
}
};
}])

.factory('$modalStack', ['$transition', '$timeout', '$document', '$compile', '$rootScope', '$$stackedMap',
function ($transition, $timeout, $document, $compile, $rootScope, $$stackedMap) {
.factory('$modalStack', ['$window', '$transition', '$timeout', '$document', '$compile', '$rootScope', '$$stackedMap',
function ($window, $transition, $timeout, $document, $compile, $rootScope, $$stackedMap) {

var OPENED_MODAL_CLASS = 'modal-open';

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

var angularDomEl = angular.element('<div modal-window></div>');
// Create a faux modal div just to measure its
// distance to top
var faux = angular.element('<div class="reveal-modal" style="z-index:-1""></div>');
body.append(faux[0]);
var marginTop = parseInt(getComputedStyle(faux[0]).top);
faux.remove();

var openAt = $window.scrollY + marginTop;

var angularDomEl = angular.element('<div modal-window style="visibility: visible; top:' + openAt +'px;"></div>');
angularDomEl.attr('window-class', modal.windowClass);
angularDomEl.attr('index', openedWindows.length() - 1);
angularDomEl.attr('animate', 'animate');
Expand Down
2 changes: 1 addition & 1 deletion template/modal/window.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div tabindex="-1" class="reveal-modal fade {{ windowClass }}"
ng-class="{in: animate}" ng-click="close($event)"
style="display: block; position: fixed; visibility: visible">
style="display: block; visibility: visible">
<div ng-transclude></div>
</div>