Chromium Code Reviews| Index: chrome/browser/resources/settings/settings_page/settings_section.js |
| diff --git a/chrome/browser/resources/settings/settings_page/settings_section.js b/chrome/browser/resources/settings/settings_page/settings_section.js |
| index 123ce46ceadfdd45909321023bbc8713a40289c4..b8de9382116e187b0fb4f2fad37c4912464cdc03 100644 |
| --- a/chrome/browser/resources/settings/settings_page/settings_section.js |
| +++ b/chrome/browser/resources/settings/settings_page/settings_section.js |
| @@ -50,7 +50,6 @@ Polymer({ |
| */ |
| expandContainer: { |
| type: Object, |
| - notify: true, |
| }, |
| animationConfig: { |
| @@ -69,6 +68,10 @@ Polymer({ |
| }, |
| }, |
| + listeners: { |
| + 'expand-animation-complete': 'onExpandAnimationComplete_', |
| + }, |
| + |
| /** @private */ |
| expanded_: false, |
| @@ -83,7 +86,18 @@ Polymer({ |
| var visible = expanded || this.currentRoute.section == ''; |
| this.$.section.elevation = visible ? 1 : 0; |
| + |
| + // Remove 'hidden' class immediately, but defer adding it if we are invisble |
| + // until the animation is complete. |
| + if (visible) |
| + this.classList.remove('hidden'); |
| }, |
| + |
| + /** @private */ |
| + onExpandAnimationComplete_: function() { |
| + this.classList.toggle('hidden', this.currentRoute.section != '' && |
| + this.currentRoute.section != this.section); |
|
Dan Beam
2015/09/25 00:49:42
this.classList.toggle('hidden', ...); -> this.hidd
tommycli
2015/09/25 17:23:22
Done.
|
| + } |
| }); |
| Polymer({ |
| @@ -94,32 +108,35 @@ Polymer({ |
| ], |
| configure: function(config) { |
| - var node = config.node; |
| - var containerRect = node.expandContainer.getBoundingClientRect(); |
| + var node = config.node.$.section; |
|
Dan Beam
2015/09/25 00:49:42
update var name
tommycli
2015/09/25 17:23:22
Done.
|
| + var containerRect = config.node.expandContainer.getBoundingClientRect(); |
| var nodeRect = node.getBoundingClientRect(); |
| - // Save section's original height. |
| - node.unexpandedHeight = nodeRect.height; |
| + // Set placeholder height so the page does not reflow during animation. |
| + var placeholder = config.node.$.placeholder; |
| + placeholder.style.top = node.offsetTop + 'px'; |
| + placeholder.style.height = node.offsetHeight + 'px'; |
| - var headerHeight = node.$.header.getBoundingClientRect().height; |
| - var newTop = containerRect.top - headerHeight; |
| - var newHeight = containerRect.height + headerHeight; |
| - |
| - node.style.position = 'fixed'; |
| - node.style.zIndex = '1'; |
| + config.node.classList.add('neon-animating'); |
| this._effect = new KeyframeEffect(node, [ |
| {'top': nodeRect.top + 'px', 'height': nodeRect.height + 'px'}, |
| - {'top': newTop + 'px', 'height': newHeight + 'px'}, |
| + {'top': containerRect.top + 'px', 'height': containerRect.height + 'px'}, |
| ], this.timingFromConfig(config)); |
| return this._effect; |
| }, |
| complete: function(config) { |
| - config.node.style.position = 'absolute'; |
| - config.node.style.top = |
| - -config.node.$.header.getBoundingClientRect().height + 'px'; |
| - config.node.style.bottom = 0; |
| + config.node.classList.remove('neon-animating'); |
| + config.node.classList.add('expanded'); |
| + config.node.expandContainer.classList.add('expanded'); |
| + |
| + for (var i = 0; i < config.node.parentNode.children.length; ++i) { |
| + if (config.node.parentNode.children[i].fire) |
|
Dan Beam
2015/09/25 00:49:42
when is this false?
tommycli
2015/09/25 17:23:22
Done. First sibling is a STYLE tag. I updated the
|
| + config.node.parentNode.children[i].fire('expand-animation-complete'); |
| + } |
| + |
| + config.node.expandContainer.scrollTop = 0; |
| } |
| }); |
| @@ -131,30 +148,25 @@ Polymer({ |
| ], |
| configure: function(config) { |
| - var node = config.node; |
| - |
| - var oldRect = node.getBoundingClientRect(); |
| + var node = config.node.$.section; |
|
Dan Beam
2015/09/25 00:49:42
update var name
tommycli
2015/09/25 17:23:22
Done.
|
| + var oldRect = config.node.expandContainer.getBoundingClientRect(); |
| - // Temporarily set position to static to determine new height. |
| - node.style.position = ''; |
| - var newTop = node.getBoundingClientRect().top; |
| + config.node.classList.remove('expanded'); |
| + config.node.expandContainer.classList.remove('expanded'); |
| - // TODO(tommycli): This value is undefined when the user navigates to a |
| - // subpage directly by URL instead of from the settings root. Find a better |
| - // method than using 200 as a dummy height. |
| - var newHeight = node.unexpandedHeight || 200; |
| + // Get the placeholder coordinates before reflowing. |
| + var newRect = config.node.$.placeholder.getBoundingClientRect(); |
| - node.style.position = 'fixed'; |
| + config.node.classList.add('neon-animating'); |
| this._effect = new KeyframeEffect(node, [ |
| {'top': oldRect.top + 'px', 'height': oldRect.height + 'px'}, |
| - {'top': newTop + 'px', 'height': newHeight + 'px'}, |
| + {'top': newRect.top + 'px', 'height': newRect.height + 'px'}, |
| ], this.timingFromConfig(config)); |
| return this._effect; |
| }, |
| complete: function(config) { |
| - config.node.style.position = ''; |
| - config.node.style.zIndex = '0'; |
| + config.node.classList.remove('neon-animating'); |
| } |
| }); |