|
19 | 19 |
|
20 | 20 | angular
|
21 | 21 | .module('material.components.backdrop', ['material.core'])
|
22 |
| - .directive('mdBackdrop', function BackdropDirective($mdTheming, $animate, $rootElement, $window, $log, $$rAF, $document) { |
| 22 | + .directive('mdBackdrop', function BackdropDirective($mdTheming, $mdUtil, $animate, $rootElement, $window, $log, $$rAF, $document) { |
23 | 23 | var ERROR_CSS_POSITION = "<md-backdrop> may not work properly in a scrolled, static-positioned parent container.";
|
24 | 24 |
|
25 | 25 | return {
|
26 | 26 | restrict: 'E',
|
27 | 27 | link: postLink
|
28 | 28 | };
|
29 | 29 |
|
30 |
| - function postLink(scope, element, attrs) { |
| 30 | + function postLink(scope, element) { |
31 | 31 |
|
32 | 32 | // If body scrolling has been disabled using mdUtil.disableBodyScroll(),
|
33 | 33 | // adjust the 'backdrop' height to account for the fixed 'body' top offset
|
34 | 34 | var body = $window.getComputedStyle($document[0].body);
|
| 35 | + |
35 | 36 | if (body.position == 'fixed') {
|
36 |
| - var hViewport = parseInt(body.height, 10) + Math.abs(parseInt(body.top, 10)); |
37 |
| - element.css({ |
38 |
| - height: hViewport + 'px' |
| 37 | + var debouncedResize = $mdUtil.debounce(resize, 60, null, false); |
| 38 | + |
| 39 | + resize(); |
| 40 | + angular.element($window).on('resize', debouncedResize); |
| 41 | + |
| 42 | + scope.$on('$destroy', function() { |
| 43 | + angular.element($window).off('resize', debouncedResize); |
39 | 44 | });
|
40 | 45 | }
|
41 | 46 |
|
@@ -66,6 +71,13 @@ angular
|
66 | 71 | }
|
67 | 72 | });
|
68 | 73 |
|
| 74 | + function resize() { |
| 75 | + var hViewport = parseInt(body.height, 10) + Math.abs(parseInt(body.top, 10)); |
| 76 | + element.css({ |
| 77 | + height: hViewport + 'px' |
| 78 | + }); |
| 79 | + } |
| 80 | + |
69 | 81 | }
|
70 | 82 |
|
71 | 83 | });
|
0 commit comments