OLD | NEW |
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 var ui = (function() { | 5 var ui = (function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * The scene class assists in managing element and animations in the scene. | 9 * The scene class assists in managing element and animations in the scene. |
10 * It allows scene update commands to be queued in batches, and manages | 10 * It allows scene update commands to be queued in batches, and manages |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 /** | 75 /** |
76 * Update an existing element, according to a UiElementUpdate object. | 76 * Update an existing element, according to a UiElementUpdate object. |
77 */ | 77 */ |
78 updateElement(id, update) { | 78 updateElement(id, update) { |
79 // To-do: Make sure ID exists. | 79 // To-do: Make sure ID exists. |
80 update.id = id; | 80 update.id = id; |
81 this.commands.push({ | 81 this.commands.push({ |
82 'type': api.Command.UPDATE_ELEMENT, | 82 'type': api.Command.UPDATE_ELEMENT, |
83 'data': update | 83 'data': update.properties |
84 }); | 84 }); |
85 } | 85 } |
86 | 86 |
87 /* | 87 /* |
88 * Remove an element from the scene. | 88 * Remove an element from the scene. |
89 */ | 89 */ |
90 removeElement(id) { | 90 removeElement(id) { |
91 // To-do: Make sure ID exists. | 91 // To-do: Make sure ID exists. |
92 this.commands.push({ | 92 this.commands.push({ |
93 'type': api.Command.REMOVE_ELEMENT, | 93 'type': api.Command.REMOVE_ELEMENT, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 }); | 126 }); |
127 delete this.animations[id]; | 127 delete this.animations[id]; |
128 } | 128 } |
129 | 129 |
130 /* | 130 /* |
131 * Purge all elements in the scene. | 131 * Purge all elements in the scene. |
132 */ | 132 */ |
133 purge() { | 133 purge() { |
134 var ids = Object.keys(this.animations); | 134 var ids = Object.keys(this.animations); |
135 for (let id_key of ids) { | 135 for (let id_key of ids) { |
136 var id = parseInt(id_key); | 136 var id = parseInt(id_key, 10); |
137 this.removeAnimation(id); | 137 this.removeAnimation(id); |
138 } | 138 } |
139 var ids = this.elements.values(); | 139 var ids = this.elements.values(); |
140 for (let id of ids) { | 140 for (let id of ids) { |
141 this.removeElement(id); | 141 this.removeElement(id); |
142 } | 142 } |
143 this.flush(); | 143 this.flush(); |
144 } | 144 } |
145 }; | 145 }; |
146 | 146 |
147 return { | 147 return { |
148 Scene: Scene, | 148 Scene: Scene, |
149 }; | 149 }; |
150 })(); | 150 })(); |
OLD | NEW |