1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 * 'cr-settings-section' shows a paper material themed section with a header
8 * which shows its page title and icon.
12 * <cr-settings-section page-title="[[pageTitle]]" icon="[[icon]]">
13 * <!-- Insert your section controls here -->
14 * </cr-settings-section>
16 * @group Chrome Settings Elements
17 * @element cr-settings-section
20 is
: 'cr-settings-section',
23 Polymer
.NeonAnimationRunnerBehavior
,
28 * Title for the page header and navigation menu.
33 * Name of the 'iron-icon' to show.
38 * True if the section should be expanded to take up the full height of
39 * the page (except the toolbar). The title and icon of the section will be
40 * hidden, and the section contents is expected to provide its own subtitle.
44 observer
: 'expandedChanged',
48 * Container that determines the sizing of expanded sections.
59 name
: 'expand-card-animation',
63 name
: 'collapse-card-animation',
71 expandedChanged: function() {
73 this.playAnimation('expand');
75 this.playAnimation('collapse');
81 is
: 'expand-card-animation',
84 Polymer
.NeonAnimationBehavior
87 configure: function(config
) {
88 var node
= config
.node
;
89 var containerRect
= node
.expandContainer
.getBoundingClientRect();
90 var nodeRect
= node
.getBoundingClientRect();
92 // Save section's original height.
93 node
.unexpandedHeight
= nodeRect
.height
;
95 var headerHeight
= node
.$.header
.getBoundingClientRect().height
;
96 var newTop
= containerRect
.top
- headerHeight
;
97 var newHeight
= containerRect
.height
+ headerHeight
;
99 node
.style
.position
= 'fixed';
101 this._effect
= new KeyframeEffect(node
, [
102 {'top': nodeRect
.top
, 'height': nodeRect
.height
},
103 {'top': newTop
, 'height': newHeight
},
104 ], this.timingFromConfig(config
));
108 complete: function(config
) {
109 config
.node
.style
.position
= 'absolute';
110 config
.node
.style
.top
=
111 -config
.node
.$.header
.getBoundingClientRect().height
+ 'px';
112 config
.node
.style
.bottom
= 0;
117 is
: 'collapse-card-animation',
120 Polymer
.NeonAnimationBehavior
123 configure: function(config
) {
124 var node
= config
.node
;
126 var oldRect
= node
.getBoundingClientRect();
128 // Temporarily set position to static to determine new height.
129 node
.style
.position
= '';
130 var newTop
= node
.getBoundingClientRect().top
;
131 var newHeight
= node
.unexpandedHeight
;
133 node
.style
.position
= 'fixed';
135 this._effect
= new KeyframeEffect(node
, [
136 {'top': oldRect
.top
, 'height': oldRect
.height
},
137 {'top': newTop
, 'height': newHeight
},
138 ], this.timingFromConfig(config
));
142 complete: function(config
) {
143 config
.node
.style
.position
= '';