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

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

Issue 2777013006: MD Settings: Prevent erroneous scroll when navigating subpage->subpage. (Closed)
Patch Set: address comment Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * Responds to route changes by expanding, collapsing, or scrolling to sections 6 * Responds to route changes by expanding, collapsing, or scrolling to sections
7 * on the page. Expanded sections take up the full height of the container. At 7 * on the page. Expanded sections take up the full height of the container. At
8 * most one section should be expanded at any given time. 8 * most one section should be expanded at any given time.
9 * @polymerBehavior MainPageBehavior 9 * @polymerBehavior MainPageBehavior
10 */ 10 */
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 // Play the actual collapse animation. 285 // Play the actual collapse animation.
286 return new Promise(function(resolve, reject) { 286 return new Promise(function(resolve, reject) {
287 // Wait for the other sections to show up so we can scroll properly. 287 // Wait for the other sections to show up so we can scroll properly.
288 setTimeout(function() { 288 setTimeout(function() {
289 var newSection = settings.getCurrentRoute().section && 289 var newSection = settings.getCurrentRoute().section &&
290 this.getSection(settings.getCurrentRoute().section); 290 this.getSection(settings.getCurrentRoute().section);
291 291
292 // Scroll to the new section or the original position. 292 // Scroll to the new section or the original position.
293 if (newSection && !settings.lastRouteChangeWasPopstate()) 293 if (newSection && !settings.lastRouteChangeWasPopstate() &&
294 !settings.getCurrentRoute().isSubpage()) {
294 newSection.scrollIntoView(); 295 newSection.scrollIntoView();
295 else 296 } else {
296 this.scroller.scrollTop = this.origScrollTop_; 297 this.scroller.scrollTop = this.origScrollTop_;
298 }
297 299
298 this.currentAnimation_ = section.animateCollapse( 300 this.currentAnimation_ = section.animateCollapse(
299 /** @type {!HTMLElement} */(this.scroller)); 301 /** @type {!HTMLElement} */(this.scroller));
300 302
301 this.currentAnimation_.finished.catch(function() { 303 this.currentAnimation_.finished.catch(function() {
302 // The collapse was canceled, so the page is showing a subpage still. 304 // The collapse was canceled, so the page is showing a subpage still.
303 this.fire('subpage-expand'); 305 this.fire('subpage-expand');
304 }.bind(this)).then(function() { 306 }.bind(this)).then(function() {
305 // Clean up after the animation succeeds or cancels. 307 // Clean up after the animation succeeds or cancels.
306 section.setFrozen(false); 308 section.setFrozen(false);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 return /** @type {?SettingsSectionElement} */( 340 return /** @type {?SettingsSectionElement} */(
339 this.$$('settings-section[section="' + section + '"]')); 341 this.$$('settings-section[section="' + section + '"]'));
340 }, 342 },
341 }; 343 };
342 344
343 /** @polymerBehavior */ 345 /** @polymerBehavior */
344 var MainPageBehavior = [ 346 var MainPageBehavior = [
345 settings.RouteObserverBehavior, 347 settings.RouteObserverBehavior,
346 MainPageBehaviorImpl, 348 MainPageBehaviorImpl,
347 ]; 349 ];
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698