OLD | NEW |
1 <!-- | 1 <!-- |
2 @license | 2 @license |
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
4 This code may only be used under the BSD style license found at http://polym
er.github.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polym
er.github.io/LICENSE.txt |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS
.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS
.txt |
6 The complete set of contributors may be found at http://polymer.github.io/CO
NTRIBUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CO
NTRIBUTORS.txt |
7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
8 subject to an additional IP rights grant found at http://polymer.github.io/P
ATENTS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/P
ATENTS.txt |
9 --> | 9 --> |
10 <link href="../core-selector/core-selector.html" rel="import"> | 10 <link href="../core-selector/core-selector.html" rel="import"> |
| 11 <link href="../core-resizable/core-resizable.html" rel="import"> |
11 | 12 |
12 <link href="transitions/hero-transition.html" rel="import"> | 13 <link href="transitions/hero-transition.html" rel="import"> |
13 <link href="transitions/cross-fade.html" rel="import"> | 14 <link href="transitions/cross-fade.html" rel="import"> |
14 | 15 |
15 <!-- | 16 <!-- |
16 | 17 |
17 `core-animated-pages` selects one of its children "pages" to show and runs a tra
nsition | 18 `core-animated-pages` selects one of its children "pages" to show and runs a tra
nsition |
18 when switching between them. The transitions are designed to be pluggable, and c
an | 19 when switching between them. The transitions are designed to be pluggable, and c
an |
19 accept any object that is an instance of a `core-transition-pages`. Transitions
to run | 20 accept any object that is an instance of a `core-transition-pages`. Transitions
to run |
20 are specified in the `transitions` attribute as a space-delimited string of `id`
s of | 21 are specified in the `transitions` attribute as a space-delimited string of `id`
s of |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 <template> | 239 <template> |
239 | 240 |
240 <link href="core-animated-pages.css" rel="stylesheet"> | 241 <link href="core-animated-pages.css" rel="stylesheet"> |
241 | 242 |
242 <shadow></shadow> | 243 <shadow></shadow> |
243 | 244 |
244 </template> | 245 </template> |
245 | 246 |
246 <script> | 247 <script> |
247 | 248 |
248 Polymer({ | 249 Polymer(Polymer.mixin({ |
249 | 250 |
250 eventDelegates: { | 251 eventDelegates: { |
251 'core-transitionend': 'transitionEnd' | 252 'core-transitionend': 'transitionEnd' |
252 }, | 253 }, |
253 | 254 |
254 /** | 255 /** |
255 * A space-delimited string of transitions to use when switching between pag
es in this element. | 256 * A space-delimited string of transitions to use when switching between pag
es in this element. |
256 * The strings are `id`s of `core-transition-pages` elements included elsewh
ere. See the | 257 * The strings are `id`s of `core-transition-pages` elements included elsewh
ere. See the |
257 * individual transition's document for specific details. | 258 * individual transition's document for specific details. |
258 * | 259 * |
(...skipping 17 matching lines...) Expand all Loading... |
276 | 277 |
277 registerCallback: function() { | 278 registerCallback: function() { |
278 this.tmeta = document.createElement('core-transition'); | 279 this.tmeta = document.createElement('core-transition'); |
279 }, | 280 }, |
280 | 281 |
281 created: function() { | 282 created: function() { |
282 this._transitions = []; | 283 this._transitions = []; |
283 this.transitioning = []; | 284 this.transitioning = []; |
284 }, | 285 }, |
285 | 286 |
| 287 attached: function() { |
| 288 this.resizerAttachedHandler(); |
| 289 }, |
| 290 |
| 291 detached: function() { |
| 292 this.resizerDetachedHandler(); |
| 293 }, |
| 294 |
286 transitionsChanged: function() { | 295 transitionsChanged: function() { |
287 this._transitions = this.transitions.split(' '); | 296 this._transitions = this.transitions.split(' '); |
288 }, | 297 }, |
289 | 298 |
290 _transitionsChanged: function(old) { | 299 _transitionsChanged: function(old) { |
291 if (this._transitionElements) { | 300 if (this._transitionElements) { |
292 this._transitionElements.forEach(function(t) { | 301 this._transitionElements.forEach(function(t) { |
293 t.teardown(this); | 302 t.teardown(this); |
294 }, this); | 303 }, this); |
295 } | 304 } |
(...skipping 15 matching lines...) Expand all Loading... |
311 this.updateSelectedItem(); | 320 this.updateSelectedItem(); |
312 // Wait to call applySelection when we run the transition | 321 // Wait to call applySelection when we run the transition |
313 }, | 322 }, |
314 | 323 |
315 applyTransition: function(src, dst) { | 324 applyTransition: function(src, dst) { |
316 if (this.animating) { | 325 if (this.animating) { |
317 this.cancelAsync(this.animating); | 326 this.cancelAsync(this.animating); |
318 this.animating = null; | 327 this.animating = null; |
319 } | 328 } |
320 | 329 |
321 Platform.flush(); | 330 Polymer.flush(); |
322 | 331 |
323 if (this.transitioning.indexOf(src) === -1) { | 332 if (this.transitioning.indexOf(src) === -1) { |
324 this.transitioning.push(src); | 333 this.transitioning.push(src); |
325 } | 334 } |
326 if (this.transitioning.indexOf(dst) === -1) { | 335 if (this.transitioning.indexOf(dst) === -1) { |
327 this.transitioning.push(dst); | 336 this.transitioning.push(dst); |
328 } | 337 } |
329 // force src, dst to display | 338 // force src, dst to display |
330 src.setAttribute('animate', ''); | 339 src.setAttribute('animate', ''); |
331 dst.setAttribute('animate', ''); | 340 dst.setAttribute('animate', ''); |
332 // | 341 // |
333 var options = { | 342 var options = { |
334 src: src, | 343 src: src, |
335 dst: dst, | 344 dst: dst, |
336 easing: 'cubic-bezier(0.4, 0, 0.2, 1)' | 345 easing: 'cubic-bezier(0.4, 0, 0.2, 1)' |
337 } | 346 }; |
338 | 347 |
339 // fire an event so clients have a chance to do something when the | 348 // fire an event so clients have a chance to do something when the |
340 // new page becomes visible but before it draws. | 349 // new page becomes visible but before it draws. |
341 this.fire('core-animated-pages-transition-prepare'); | 350 this.fire('core-animated-pages-transition-prepare'); |
342 | 351 |
343 // | 352 // |
344 // prepare transition | 353 // prepare transition |
345 this._transitionElements.forEach(function(transition) { | 354 this._transitionElements.forEach(function(transition) { |
346 transition.prepare(this, options); | 355 transition.prepare(this, options); |
347 }, this); | 356 }, this); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 this.super(arguments); | 418 this.super(arguments); |
410 | 419 |
411 if (!oldItem) { | 420 if (!oldItem) { |
412 this.applySelection(this.selectedItem, true); | 421 this.applySelection(this.selectedItem, true); |
413 return; | 422 return; |
414 } | 423 } |
415 | 424 |
416 if (this.hasAttribute('no-transition') || !this._transitionElements || !th
is._transitionElements.length) { | 425 if (this.hasAttribute('no-transition') || !this._transitionElements || !th
is._transitionElements.length) { |
417 this.applySelection(oldItem, false); | 426 this.applySelection(oldItem, false); |
418 this.applySelection(this.selectedItem, true); | 427 this.applySelection(this.selectedItem, true); |
| 428 this.notifyResize(); |
419 return; | 429 return; |
420 } | 430 } |
421 | 431 |
422 if (oldItem && this.selectedItem) { | 432 if (oldItem && this.selectedItem) { |
423 // TODO(sorvell): allow bindings to update first? | 433 // TODO(sorvell): allow bindings to update first? |
424 var self = this; | 434 var self = this; |
425 Platform.flush(); | 435 Polymer.flush(); |
426 Platform.endOfMicrotask(function() { | 436 Polymer.endOfMicrotask(function() { |
427 self.applyTransition(oldItem, self.selectedItem); | 437 self.applyTransition(oldItem, self.selectedItem); |
| 438 self.notifyResize(); |
428 }); | 439 }); |
429 } | 440 } |
| 441 }, |
| 442 |
| 443 resizerShouldNotify: function(el) { |
| 444 // Only notify descendents of selected item |
| 445 while (el && (el != this)) { |
| 446 if (el == this.selectedItem) { |
| 447 return true; |
| 448 } |
| 449 el = el.parentElement || (el.parentNode && el.parentNode.host); |
| 450 } |
430 } | 451 } |
431 | 452 |
432 }); | 453 }, Polymer.CoreResizer)); |
433 | 454 |
434 </script> | 455 </script> |
435 | 456 |
436 </polymer-element> | 457 </polymer-element> |
OLD | NEW |