|
37 | 37 | '</md-button>' + |
38 | 38 | '</div>' + |
39 | 39 |
|
40 | | - // This pane (and its shadow) will be detached from here and re-attached to the |
41 | | - // document body. |
42 | | - '<div class="md-datepicker-calendar-pane">' + |
43 | | - '<md-calendar ng-model="ctrl.date" ng-if="ctrl.isCalendarOpen"></md-calendar>' + |
44 | | - '</div>' + |
45 | | - |
46 | | - // We have a separate shadow element in order to wrap both the floating pane and the |
47 | | - // inline input / trigger as one shadowed whole. |
48 | | - '<div class="md-datepicker-calendar-pane-shadow md-whiteframe-z1"></div>', |
| 40 | + // This pane will be detached from here and re-attached to the document body. |
| 41 | + '<div class="md-datepicker-calendar-pane md-whiteframe-z1">' + |
| 42 | + '<div class="md-datepicker-input-mask"></div>' + |
| 43 | + '<div class="md-datepicker-calendar">' + |
| 44 | + '<md-calendar ng-model="ctrl.date" ng-if="ctrl.isCalendarOpen"></md-calendar>' + |
| 45 | + '</div>' + |
| 46 | + '</div>', |
49 | 47 | require: ['ngModel', 'mdDatePicker'], |
50 | 48 | scope: { |
51 | 49 | placeholder: '@mdPlaceholder' |
|
71 | 69 | * @ngInject @constructor |
72 | 70 | */ |
73 | 71 | function DatePickerCtrl($scope, $element, $attrs, $compile, $timeout, $mdConstant, $mdUtil, |
74 | | - $$mdDateLocale, $$mdDateUtil) { |
| 72 | + $$mdDateLocale, $$mdDateUtil, $mdMenu, $$rAF) { |
75 | 73 | /** @final */ |
76 | 74 | this.$compile = $compile; |
77 | 75 |
|
|
90 | 88 | /* @final */ |
91 | 89 | this.$mdUtil = $mdUtil; |
92 | 90 |
|
| 91 | + /** @final */ |
| 92 | + this.$mdMenu = $mdMenu; |
| 93 | + |
| 94 | + this.$$rAF = $$rAF; |
| 95 | + |
93 | 96 | /** @type {!angular.NgModelController} */ |
94 | 97 | this.ngModelCtrl = null; |
95 | 98 |
|
|
102 | 105 | /** @type {HTMLElement} Floating calendar pane. */ |
103 | 106 | this.calendarPane = $element[0].querySelector('.md-datepicker-calendar-pane'); |
104 | 107 |
|
105 | | - /** @type {HTMLElement} Shadow for floating calendar pane and input trigger. */ |
106 | | - this.calendarShadow = $element[0].querySelector('.md-datepicker-calendar-pane-shadow'); |
107 | | - |
108 | 108 | /** @type {HTMLElement} Calendar icon button. */ |
109 | 109 | this.calendarButton = $element[0].querySelector('.md-datepicker-button'); |
110 | 110 |
|
|
240 | 240 |
|
241 | 241 | /** Position and attach the floating calendar to the document. */ |
242 | 242 | DatePickerCtrl.prototype.attachCalendarPane = function() { |
| 243 | + var calendarPane = this.calendarPane; |
243 | 244 | this.$element.addClass('md-datepicker-open'); |
244 | 245 |
|
245 | 246 | var elementRect = this.inputContainer.getBoundingClientRect(); |
246 | 247 | var bodyRect = document.body.getBoundingClientRect(); |
247 | 248 |
|
248 | | - this.calendarPane.style.left = (elementRect.left - bodyRect.left) + 'px'; |
249 | | - this.calendarPane.style.top = (elementRect.bottom - bodyRect.top) + 'px'; |
| 249 | + calendarPane.style.left = (elementRect.left - bodyRect.left) + 'px'; |
| 250 | + calendarPane.style.top = (elementRect.top - bodyRect.top) + 'px'; |
250 | 251 | document.body.appendChild(this.calendarPane); |
251 | 252 |
|
252 | | - // Add shadow to the calendar pane only after the UI thread has reached idle, allowing the |
253 | | - // content of the calender pane to be rendered. |
254 | | - this.$timeout(function() { |
255 | | - this.calendarPane.classList.add('md-pane-open'); |
256 | | - |
257 | | - this.calendarShadow.style.top = (elementRect.top - bodyRect.top) + 'px'; |
258 | | - this.calendarShadow.style.left = this.calendarPane.style.left; |
259 | | - this.calendarShadow.style.height = |
260 | | - (this.calendarPane.getBoundingClientRect().bottom - elementRect.top) + 'px'; |
261 | | - document.body.appendChild(this.calendarShadow); |
262 | | - }.bind(this), 0, false); |
| 253 | + // Add CSS class after one frame to trigger animation. |
| 254 | + this.$$rAF(function() { |
| 255 | + calendarPane.classList.add('md-pane-open'); |
| 256 | + }); |
263 | 257 | }; |
264 | 258 |
|
265 | 259 | /** Detach the floating calendar pane from the document. */ |
|
270 | 264 | // Use native DOM removal because we do not want any of the angular state of this element |
271 | 265 | // to be disposed. |
272 | 266 | this.calendarPane.parentNode.removeChild(this.calendarPane); |
273 | | - this.calendarShadow.parentNode.removeChild(this.calendarShadow); |
274 | 267 | }; |
275 | 268 |
|
276 | 269 | /** Open the floating calendar pane. */ |
|
0 commit comments