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

Side by Side Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2039603002: MD Settings: Fix scroll to section (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test coverage Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Fast out, slow in. 5 // Fast out, slow in.
6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)'; 6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)';
7 var EXPAND_DURATION = 350; 7 var EXPAND_DURATION = 350;
8 8
9 /** 9 /**
10 * Provides animations to expand and collapse individual sections in a page. 10 * Provides animations to expand and collapse individual sections in a page.
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 scrollToSection_: function() { 339 scrollToSection_: function() {
340 // TODO(dschuyler): Determine whether this setTimeout can be removed. 340 // TODO(dschuyler): Determine whether this setTimeout can be removed.
341 // See also: https://github.com/Polymer/polymer/issues/3629 341 // See also: https://github.com/Polymer/polymer/issues/3629
342 setTimeout(function pollForScrollHeight() { 342 setTimeout(function pollForScrollHeight() {
343 // If the current section changes while we are waiting for the page to be 343 // If the current section changes while we are waiting for the page to be
344 // ready, scroll to the newest requested section. 344 // ready, scroll to the newest requested section.
345 var element = this.getSection_(this.currentRoute.section); 345 var element = this.getSection_(this.currentRoute.section);
346 if (!element) 346 if (!element)
347 return; 347 return;
348 348
349 if (element.parentNode.host.scrollHeight == 0) { 349 if (this.scrollHeight == 0) {
350 setTimeout(pollForScrollHeight.bind(this), 100); 350 setTimeout(pollForScrollHeight.bind(this), 100);
351 return; 351 return;
352 } 352 }
353 353
354 element.scrollIntoView(); 354 element.scrollIntoView();
355 }.bind(this)); 355 }.bind(this));
356 }, 356 },
357 357
358 /** @private */ 358 /** @private */
359 currentRouteChanged_: function(newRoute, oldRoute) { 359 currentRouteChanged_: function(newRoute, oldRoute) {
(...skipping 13 matching lines...) Expand all
373 373
374 if (!newRouteIsSubpage && oldRouteIsSubpage) { 374 if (!newRouteIsSubpage && oldRouteIsSubpage) {
375 var section = this.getSection_(oldRoute.section); 375 var section = this.getSection_(oldRoute.section);
376 if (section) 376 if (section)
377 this.collapseSection(section); 377 this.collapseSection(section);
378 } else if (newRouteIsSubpage && 378 } else if (newRouteIsSubpage &&
379 (!oldRouteIsSubpage || newRoute.section != oldRoute.section)) { 379 (!oldRouteIsSubpage || newRoute.section != oldRoute.section)) {
380 var section = this.getSection_(newRoute.section); 380 var section = this.getSection_(newRoute.section);
381 if (section) 381 if (section)
382 this.expandSection(section); 382 this.expandSection(section);
383 } else if (newRoute && newRoute.section) { 383 } else if (newRoute && newRoute.section && !oldRouteIsSubpage) {
dschuyler 2016/06/06 23:51:42 What is this addition addressing?
michaelpg 2016/06/07 02:55:05 Warning: wall of text that I'm publishing for my n
dschuyler 2016/06/08 00:35:05 That's a lot of indirect logic for folks following
384 this.scrollToSection_(); 384 this.scrollToSection_();
385 } 385 }
386 }, 386 },
387 387
388 /** 388 /**
389 * Helper function to get a section from the local DOM. 389 * Helper function to get a section from the local DOM.
390 * @param {string} section Section name of the element to get. 390 * @param {string} section Section name of the element to get.
391 * @return {?SettingsSectionElement} 391 * @return {?SettingsSectionElement}
392 * @private 392 * @private
393 */ 393 */
394 getSection_: function(section) { 394 getSection_: function(section) {
395 return /** @type {?SettingsSectionElement} */( 395 return /** @type {?SettingsSectionElement} */(
396 this.$$('[section=' + section + ']')); 396 this.$$('[section=' + section + ']'));
397 }, 397 },
398 }; 398 };
399 399
400 400
401 /** @polymerBehavior */ 401 /** @polymerBehavior */
402 var RoutableBehavior = [ 402 var RoutableBehavior = [
403 MainPageBehavior, 403 MainPageBehavior,
404 RoutableBehaviorImpl 404 RoutableBehaviorImpl
405 ]; 405 ];
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | chrome/test/data/webui/settings/navigation_browsertest.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698