Created
August 27, 2014 02:59
-
-
Save niusounds/8264b34700f0fca1e874 to your computer and use it in GitHub Desktop.
Bootstrapのmodalを画面中央に表示するためのAngularJS Directive。要jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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