Skip to content

Instantly share code, notes, and snippets.

@niusounds
Created August 27, 2014 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niusounds/8264b34700f0fca1e874 to your computer and use it in GitHub Desktop.
Save niusounds/8264b34700f0fca1e874 to your computer and use it in GitHub Desktop.
Bootstrapのmodalを画面中央に表示するためのAngularJS Directive。要jQuery
angular.module('ModalCenter', []).directive('modalDialog', function($window) {
return {
restrict: 'C',
link: function(scope, element, attrs) {
var win = $($window);
win.on('resize', modalCenter);
function modalCenter() {
element.css('margin-top', (win.height() - element.height()) * 0.5 + 'px');
}
modalCenter();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment