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

Side by Side Diff: third_party/polymer/v1_0/components/neon-animation/animations/reverse-ripple-animation.html

Issue 1221923003: Update bower.json for Polymer elements and add PRESUBMIT.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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 <!-- 1 <!--
2 @license 2 @license
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 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.g ithub.io/LICENSE.txt 4 This code may only be used under the BSD style license found at http://polymer.g ithub.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/CONTRI BUTORS.txt 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.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/PATEN TS.txt 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 --> 9 -->
10 10
11
11 <link rel="import" href="../../polymer/polymer.html"> 12 <link rel="import" href="../../polymer/polymer.html">
12 <link rel="import" href="../neon-shared-element-animation-behavior.html"> 13 <link rel="import" href="../neon-shared-element-animation-behavior.html">
13 <link rel="import" href="../web-animations.html"> 14 <link rel="import" href="../web-animations.html">
14 15
15 <!-- 16 <!--
16 `<ripple-animation>` scales and transform an element such that it appears to rip ple from either 17 `<reverse-ripple-animation>` scales and transform an element such that it appear s to ripple down from this element, to either
17 a shared element, or from a screen position, to full screen. 18 a shared element, or a screen position.
18 19
19 If using as a shared element animation in `<neon-animated-pages>`, use this anim ation in an `exit` 20 If using as a shared element animation in `<neon-animated-pages>`, use this anim ation in an `exit`
20 animation in the source page and in an `entry` animation in the destination page . Also, define the 21 animation in the source page and in an `entry` animation in the destination page . Also, define the
21 hero elements in the `sharedElements` property (not a configuration property, se e 22 reverse-ripple elements in the `sharedElements` property (not a configuration pr operty, see
22 `Polymer.NeonSharedElementAnimatableBehavior`). 23 `Polymer.NeonSharedElementAnimatableBehavior`).
23
24 If using a screen position, define the `gesture` property. 24 If using a screen position, define the `gesture` property.
25
26 Configuration: 25 Configuration:
27 ``` 26 ```
28 { 27 {
29 name: 'ripple-animation`. 28 name: 'reverse-ripple-animation`.
30 id: <shared-element-id>, /* set this or gesture */ 29 id: <shared-element-id>, /* set this or gesture */
31 gesture: {x: <page-x>, y: <page-y>}, /* set this or id */ 30 gesture: {x: <page-x>, y: <page-y>}, /* set this or id */
32 timing: <animation-timing>, 31 timing: <animation-timing>,
33 toPage: <node>, /* define for the destination page */ 32 toPage: <node>, /* define for the destination page */
34 fromPage: <node>, /* define for the source page */ 33 fromPage: <node>, /* define for the source page */
35 } 34 }
36 ``` 35 ```
37 --> 36 -->
38 37
39 <script> 38 <script>
40
41 Polymer({ 39 Polymer({
42 40 is: 'reverse-ripple-animation',
43 is: 'ripple-animation',
44 41
45 behaviors: [ 42 behaviors: [
46 Polymer.NeonSharedElementAnimationBehavior 43 Polymer.NeonSharedElementAnimationBehavior
47 ], 44 ],
48 45
49 configure: function(config, fromPage, toPage) { 46 configure: function(config) {
50 var shared = this.findSharedElements(config, fromPage, toPage); 47 var shared = this.findSharedElements(config);
51 if (!shared) { 48 if (!shared) {
52 return null; 49 return null;
53 } 50 }
54 51
55 var translateX, translateY; 52 var translateX, translateY;
56 var toRect = shared.to.getBoundingClientRect(); 53 var fromRect = shared.from.getBoundingClientRect();
57 if (config.gesture) { 54 if (config.gesture) {
58 translateX = config.gesture.x - (toRect.left + (toRect.width / 2)); 55 translateX = config.gesture.x - (fromRect.left + (fromRect.width / 2));
59 translateY = config.gesture.y - (toRect.left + (toRect.height / 2)); 56 translateY = config.gesture.y - (fromRect.top + (fromRect.height / 2));
60 } else { 57 } else {
61 var fromRect = shared.from.getBoundingClientRect(); 58 var toRect = shared.to.getBoundingClientRect();
62 translateX = (fromRect.left + (fromRect.width / 2)) - (toRect.left + (to Rect.width / 2)); 59 translateX = (toRect.left + (toRect.width / 2)) - (fromRect.left + (from Rect.width / 2));
63 translateY = (fromRect.top + (fromRect.height / 2)) - (toRect.left + (to Rect.height / 2)); 60 translateY = (toRect.top + (toRect.height / 2)) - (fromRect.top + (fromR ect.height / 2));
64 } 61 }
65 var translate = 'translate(' + translateX + 'px,' + translateY + 'px)'; 62 var translate = 'translate(' + translateX + 'px,' + translateY + 'px)';
66 63
67 var size = Math.max(toRect.width + Math.abs(translateX) * 2, toRect.height + Math.abs(translateY) * 2); 64 var size = Math.max(fromRect.width + Math.abs(translateX) * 2, fromRect.he ight + Math.abs(translateY) * 2);
68 var diameter = Math.sqrt(2 * size * size); 65 var diameter = Math.sqrt(2 * size * size);
69 var scaleX = diameter / toRect.width; 66 var scaleX = diameter / fromRect.width;
70 var scaleY = diameter / toRect.height; 67 var scaleY = diameter / fromRect.height;
71 var scale = 'scale(' + scaleX + ',' + scaleY + ')'; 68 var scale = 'scale(' + scaleX + ',' + scaleY + ')';
72 69
73 this.setPrefixedProperty(shared.to, 'transformOrigin', '50% 50%'); 70 this.setPrefixedProperty(shared.from, 'transformOrigin', '50% 50%');
74 shared.to.style.borderRadius = '50%'; 71 shared.from.style.borderRadius = '50%';
75 72
76 this._effect = new KeyframeEffect(shared.to, [ 73 this._effect = new KeyframeEffect(shared.from, [
77 {'transform': translate + ' scale(0)'}, 74 {'transform': translate + ' ' + scale},
78 {'transform': translate + ' ' + scale} 75 {'transform': translate + ' scale(0)'}
79 ], this.timingFromConfig(config)); 76 ], this.timingFromConfig(config));
80 return this._effect; 77 return this._effect;
81 }, 78 },
82 79
83 complete: function() { 80 complete: function() {
84 if (this.sharedElements) { 81 if (this.sharedElements) {
85 this.setPrefixedProperty(this.sharedElements.to, 'transformOrigin', ''); 82 this.setPrefixedProperty(this.sharedElements.from, 'transformOrigin', '' );
86 this.sharedElements.to.style.borderRadius = ''; 83 this.sharedElements.from.style.borderRadius = '';
87 } 84 }
88 } 85 }
89
90 }); 86 });
91
92 </script> 87 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698