Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / polymer / v1_0 / components / neon-animation / animations / hero-animation.html
bloba9075e138fd08e2503be6424ca3073feac6b5fdf
1 <!--
2 @license
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.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/CONTRIBUTORS.txt
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/PATENTS.txt
9 -->
11 <link rel="import" href="../../polymer/polymer.html">
12 <link rel="import" href="../neon-shared-element-animation-behavior.html">
13 <link rel="import" href="../web-animations.html">
15 <!--
16 `<hero-animation>` is a shared element animation that scales and transform an element such that it
17 appears to be shared between two pages. Use this in `<neon-animated-pages>`. The source page
18 should use this animation in an 'exit' animation and set the `fromPage` configuration property to
19 itself, and the destination page should use this animation in an `entry` animation and set the
20 `toPage` configuration property to itself. They should also define the hero elements in the
21 `sharedElements` property (not a configuration property, see
22 `Polymer.NeonSharedElementAnimatableBehavior`).
24 Configuration:
25 ```
27 name: 'hero-animation',
28 id: <shared-element-id>,
29 timing: <animation-timing>,
30 toPage: <node>, /* define for the destination page */
31 fromPage: <node>, /* define for the source page */
33 ```
34 -->
36 <script>
38 Polymer({
40 is: 'hero-animation',
42 behaviors: [
43 Polymer.NeonSharedElementAnimationBehavior
46 configure: function(config) {
47 var shared = this.findSharedElements(config);
48 if (!shared) {
49 return;
52 var fromRect = shared.from.getBoundingClientRect();
53 var toRect = shared.to.getBoundingClientRect();
55 var deltaLeft = fromRect.left - toRect.left;
56 var deltaTop = fromRect.top - toRect.top;
57 var deltaWidth = fromRect.width / toRect.width;
58 var deltaHeight = fromRect.height / toRect.height;
60 this.setPrefixedProperty(shared.to, 'transformOrigin', '0 0');
61 shared.to.style.zIndex = 10000;
62 shared.from.style.visibility = 'hidden';
64 this._effect = new KeyframeEffect(shared.to, [
65 {'transform': 'translate(' + deltaLeft + 'px,' + deltaTop + 'px) scale(' + deltaWidth + ',' + deltaHeight + ')'},
66 {'transform': 'none'}
67 ], this.timingFromConfig(config));
69 return this._effect;
72 complete: function(config) {
73 var shared = this.findSharedElements(config);
74 if (!shared) {
75 return null;
77 shared.to.style.zIndex = '';
78 shared.from.style.visibility = '';
81 });
83 </script>