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

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

Issue 2022893003: [MD settings] scroll to section find host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 var RoutableBehaviorImpl = { 328 var RoutableBehaviorImpl = {
329 properties: { 329 properties: {
330 /** Contains the current route. */ 330 /** Contains the current route. */
331 currentRoute: { 331 currentRoute: {
332 type: Object, 332 type: Object,
333 notify: true, 333 notify: true,
334 observer: 'currentRouteChanged_', 334 observer: 'currentRouteChanged_',
335 }, 335 },
336 }, 336 },
337 337
338 /**
Dan Beam 2016/05/31 21:27:20 @param?
dschuyler 2016/05/31 22:02:15 Acknowledged.
339 * @return {Object} The enclosing (shadow dom) host of element.
Dan Beam 2016/05/31 21:27:20 this should not be an object
dschuyler 2016/05/31 22:02:15 Acknowledged.
340 * @private
341 */
342 findHost_: function(element) {
343 return findAncestor(element, function(node) {
344 return node.host;
345 }).host;
Dan Beam 2016/05/31 21:27:20 can this be: return findAncestor(el, function(n
Dan Beam 2016/05/31 21:27:20 wrong indent
dschuyler 2016/05/31 22:02:14 Acknowledged.
dschuyler 2016/05/31 22:02:15 Acknowledged.
346 },
347
338 /** @private */ 348 /** @private */
339 scrollToSection_: function() { 349 scrollToSection_: function() {
340 // TODO(dschuyler): Determine whether this setTimeout can be removed. 350 // TODO(dschuyler): Determine whether this setTimeout can be removed.
341 // See also: https://github.com/Polymer/polymer/issues/3629 351 // See also: https://github.com/Polymer/polymer/issues/3629
342 setTimeout(function pollForScrollHeight() { 352 setTimeout(function pollForScrollHeight() {
343 // If the current section changes while we are waiting for the page to be 353 // If the current section changes while we are waiting for the page to be
344 // ready, scroll to the newest requested section. 354 // ready, scroll to the newest requested section.
345 var element = this.getSection_(this.currentRoute.section); 355 var element = this.getSection_(this.currentRoute.section);
346 if (!element) 356 if (!element)
347 return; 357 return;
348 358
Dan Beam 2016/05/31 21:27:20 or maybe: var host = findAncestor(el, function(n)
dschuyler 2016/05/31 22:02:14 Done.
349 if (element.parentNode.host.scrollHeight == 0) { 359 if (this.findHost_(element).scrollHeight == 0) {
350 setTimeout(pollForScrollHeight.bind(this), 100); 360 setTimeout(pollForScrollHeight.bind(this), 100);
351 return; 361 return;
352 } 362 }
353 363
354 element.scrollIntoView(); 364 element.scrollIntoView();
355 }.bind(this)); 365 }.bind(this));
356 }, 366 },
357 367
358 /** @private */ 368 /** @private */
359 currentRouteChanged_: function(newRoute, oldRoute) { 369 currentRouteChanged_: function(newRoute, oldRoute) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 this.$$('[section=' + section + ']')); 406 this.$$('[section=' + section + ']'));
397 }, 407 },
398 }; 408 };
399 409
400 410
401 /** @polymerBehavior */ 411 /** @polymerBehavior */
402 var RoutableBehavior = [ 412 var RoutableBehavior = [
403 MainPageBehavior, 413 MainPageBehavior,
404 RoutableBehaviorImpl 414 RoutableBehaviorImpl
405 ]; 415 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698