Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: chrome/browser/resources/settings/settings_page/settings_section.js

Issue 1358313004: Settings Rewrite: Make subpage scrolling work. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..75491a4f237973714ca2ae47fd5bf860a1bcc358 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.hidden = false;
},
+
+ /** @private */
+ onExpandAnimationComplete_: function() {
+ this.hidden = this.currentRoute.section != '' &&
+ this.currentRoute.section != this.section;
+ }
});
Polymer({
@@ -94,32 +108,38 @@ Polymer({
],
configure: function(config) {
- var node = config.node;
- var containerRect = node.expandContainer.getBoundingClientRect();
- var nodeRect = node.getBoundingClientRect();
-
- // Save section's original height.
- node.unexpandedHeight = nodeRect.height;
-
- var headerHeight = node.$.header.getBoundingClientRect().height;
- var newTop = containerRect.top - headerHeight;
- var newHeight = containerRect.height + headerHeight;
-
- node.style.position = 'fixed';
- node.style.zIndex = '1';
-
- this._effect = new KeyframeEffect(node, [
- {'top': nodeRect.top + 'px', 'height': nodeRect.height + 'px'},
- {'top': newTop + 'px', 'height': newHeight + 'px'},
+ var element = config.node;
+ var section = element.$.section;
+ var containerRect = element.expandContainer.getBoundingClientRect();
+ var sectionRect = section.getBoundingClientRect();
+
+ // Set placeholder height so the page does not reflow during animation.
+ // TODO(tommycli): For URLs that directly load subpages, this does not work.
+ var placeholder = element.$.placeholder;
+ placeholder.style.top = section.offsetTop + 'px';
+ placeholder.style.height = section.offsetHeight + 'px';
+
+ element.classList.add('neon-animating');
+
+ this._effect = new KeyframeEffect(section, [
+ {'top': sectionRect.top + 'px', 'height': sectionRect.height + '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;
+ var element = config.node;
+ element.classList.remove('neon-animating');
+ element.classList.add('expanded');
+ element.expandContainer.classList.add('expanded');
+
+ var siblings = element.parentNode.querySelectorAll('cr-settings-section');
Dan Beam 2015/09/25 23:49:03 this includes |element|. make sure to capture thi
Dan Beam 2015/09/25 23:49:03 let's make sure this is limited to 1 level of dept
tommycli 2015/09/25 23:53:29 Done.
tommycli 2015/09/25 23:53:29 Done.
+ for (var i = 0; i < siblings.length; ++i) {
+ siblings[i].fire('expand-animation-complete');
+ }
+
+ element.expandContainer.scrollTop = 0;
}
});
@@ -131,30 +151,25 @@ Polymer({
],
configure: function(config) {
- var node = config.node;
-
- var oldRect = node.getBoundingClientRect();
+ var element = config.node;
+ var oldRect = element.expandContainer.getBoundingClientRect();
- // Temporarily set position to static to determine new height.
- node.style.position = '';
- var newTop = node.getBoundingClientRect().top;
+ element.classList.remove('expanded');
+ element.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 = element.$.placeholder.getBoundingClientRect();
- node.style.position = 'fixed';
+ element.classList.add('neon-animating');
- this._effect = new KeyframeEffect(node, [
+ this._effect = new KeyframeEffect(element.$.section, [
{'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');
}
});

Powered by Google App Engine
This is Rietveld 408576698