OLD | NEW |
| (Empty) |
1 | |
2 | |
3 (function() { | |
4 | |
5 Polymer({ | |
6 | |
7 is: 'paper-dialog-scrollable', | |
8 | |
9 properties: { | |
10 | |
11 /** | |
12 * The dialog element that implements `Polymer.PaperDialogBehavior` contai
ning this element. | |
13 * @type {?Node} | |
14 */ | |
15 dialogElement: { | |
16 type: Object, | |
17 value: function() { | |
18 return this.parentNode; | |
19 } | |
20 } | |
21 | |
22 }, | |
23 | |
24 listeners: { | |
25 'scrollable.scroll': '_onScroll', | |
26 'iron-resize': '_onIronResize' | |
27 }, | |
28 | |
29 /** | |
30 * Returns the scrolling element. | |
31 */ | |
32 get scrollTarget() { | |
33 return this.$.scrollable; | |
34 }, | |
35 | |
36 attached: function() { | |
37 this.classList.add('no-padding'); | |
38 // Set itself to the overlay sizing target | |
39 this.dialogElement.sizingTarget = this.scrollTarget; | |
40 // If the host is sized, fit the scrollable area to the container. Otherwi
se let it be | |
41 // its natural size. | |
42 requestAnimationFrame(function() { | |
43 if (this.offsetHeight > 0) { | |
44 this.$.scrollable.classList.add('fit'); | |
45 } | |
46 this._scroll(); | |
47 }.bind(this)); | |
48 }, | |
49 | |
50 _scroll: function() { | |
51 this.toggleClass('is-scrolled', this.scrollTarget.scrollTop > 0); | |
52 this.toggleClass('can-scroll', this.scrollTarget.offsetHeight < this.scrol
lTarget.scrollHeight); | |
53 this.toggleClass('scrolled-to-bottom', | |
54 this.scrollTarget.scrollTop + this.scrollTarget.offsetHeight >= this.scr
ollTarget.scrollHeight); | |
55 }, | |
56 | |
57 _onScroll: function() { | |
58 this._scroll(); | |
59 } | |
60 | |
61 }) | |
62 | |
63 })(); | |
64 | |
OLD | NEW |