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

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

Issue 1290583002: Settings: Implement sub-subpages, and clean up some animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify further. fixes display artifact. Created 5 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @fileoverview 6 * @fileoverview
7 * 'cr-settings-animated-pages' is a container for a page and animated subpages. 7 * 'cr-settings-animated-pages' is a container for a page and animated subpages.
8 * It provides a set of common behaviors and animations. Notably, it provides 8 * It provides a set of common behaviors and animations. Notably, it provides
9 * an 'inSubpage' property that indicates when a subpage is active. 9 * an 'inSubpage' property that indicates when a subpage is active.
10 * 10 *
11 * Example: 11 * Example:
12 * 12 *
13 * <cr-settings-animated-pages> 13 * <cr-settings-animated-pages>
14 * <!-- Insert your section controls here --> 14 * <!-- Insert your section controls here -->
15 * </cr-settings-animated-pages> 15 * </cr-settings-animated-pages>
16 * 16 *
17 * @group Chrome Settings Elements 17 * @group Chrome Settings Elements
18 * @element cr-settings-animated-pages 18 * @element cr-settings-animated-pages
19 */ 19 */
20 Polymer({ 20 Polymer({
21 is: 'cr-settings-animated-pages', 21 is: 'cr-settings-animated-pages',
22 22
23 properties: { 23 properties: {
24 /**
25 * Corresponds to a page id.
26 */
27 selectedPage: {
28 type: String,
29 value: 'main',
30 },
31
32 entryAnimation: {
33 type: String,
34 value: 'next-page-enter-animation',
35 },
36
37 exitAnimation: {
38 type: String,
39 value: 'next-page-exit-animation',
40 },
41
42 inSubpage: { 24 inSubpage: {
43 type: Boolean, 25 type: Boolean,
44 notify: true, 26 notify: true,
45 observer: 'inSubpageChanged_', 27 observer: 'inSubpageChanged_',
46 }, 28 },
47 }, 29 },
48 30
49 created: function() { 31 created: function() {
50 this.history_ = ['main']; 32 this.history_ = ['main'];
51 }, 33 },
52 34
35 /** @private */
53 inSubpageChanged_: function() { 36 inSubpageChanged_: function() {
54 this.classList.toggle('in-subpage', this.inSubpage); 37 this.classList.toggle('in-subpage', this.inSubpage);
55 }, 38 },
56 39
57 navigateTo: function(page) { 40 navigateTo: function(page) {
41 if (this.inSubpage) {
42 this.$.animatedPages.exitAnimation = 'slide-left-animation';
43 this.$.animatedPages.entryAnimation = 'slide-from-right-animation';
44 } else {
45 this.$.animatedPages.exitAnimation = 'fade-out-animation';
46 this.$.animatedPages.entryAnimation = 'fade-in-animation';
47 }
48
58 this.history_.push(page); 49 this.history_.push(page);
59 this.inSubpage = true; 50 this.inSubpage = true;
60 this.selectedPage = page; 51
52 this.$.animatedPages.selected = page;
61 }, 53 },
62 54
63 back: function() { 55 back: function() {
64 this.history_.pop(); 56 this.history_.pop();
65 this.inSubpage = this.history_.length > 1; 57 this.inSubpage = this.history_.length > 1;
66 this.selectedPage = this.history_.slice(-1)[0]; 58 var page = this.history_.slice(-1)[0];
Dan Beam 2015/08/12 21:38:04 why can't this just be inlined?
tommycli 2015/08/12 22:11:57 Done.
59
60 if (this.inSubpage) {
61 this.$.animatedPages.exitAnimation = 'slide-right-animation';
62 this.$.animatedPages.entryAnimation = 'slide-from-left-animation';
63 } else {
64 this.$.animatedPages.exitAnimation = 'fade-out-animation';
65 this.$.animatedPages.entryAnimation = 'fade-in-animation';
66 }
67
68 this.$.animatedPages.selected = page;
67 }, 69 },
68 }); 70 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698