OLD | NEW |
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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 <script> | 39 <script> |
40 | 40 |
41 Polymer({ | 41 Polymer({ |
42 | 42 |
43 is: 'ripple-animation', | 43 is: 'ripple-animation', |
44 | 44 |
45 behaviors: [ | 45 behaviors: [ |
46 Polymer.NeonSharedElementAnimationBehavior | 46 Polymer.NeonSharedElementAnimationBehavior |
47 ], | 47 ], |
48 | 48 |
49 configure: function(config, fromPage, toPage) { | 49 configure: function(config) { |
50 var shared = this.findSharedElements(config, fromPage, toPage); | 50 var shared = this.findSharedElements(config); |
51 if (!shared) { | 51 if (!shared) { |
52 return null; | 52 return null; |
53 } | 53 } |
54 | 54 |
55 var translateX, translateY; | 55 var translateX, translateY; |
56 var toRect = shared.to.getBoundingClientRect(); | 56 var toRect = shared.to.getBoundingClientRect(); |
57 if (config.gesture) { | 57 if (config.gesture) { |
58 translateX = config.gesture.x - (toRect.left + (toRect.width / 2)); | 58 translateX = config.gesture.x - (toRect.left + (toRect.width / 2)); |
59 translateY = config.gesture.y - (toRect.left + (toRect.height / 2)); | 59 translateY = config.gesture.y - (toRect.top + (toRect.height / 2)); |
60 } else { | 60 } else { |
61 var fromRect = shared.from.getBoundingClientRect(); | 61 var fromRect = shared.from.getBoundingClientRect(); |
62 translateX = (fromRect.left + (fromRect.width / 2)) - (toRect.left + (to
Rect.width / 2)); | 62 translateX = (fromRect.left + (fromRect.width / 2)) - (toRect.left + (to
Rect.width / 2)); |
63 translateY = (fromRect.top + (fromRect.height / 2)) - (toRect.left + (to
Rect.height / 2)); | 63 translateY = (fromRect.top + (fromRect.height / 2)) - (toRect.top + (toR
ect.height / 2)); |
64 } | 64 } |
65 var translate = 'translate(' + translateX + 'px,' + translateY + 'px)'; | 65 var translate = 'translate(' + translateX + 'px,' + translateY + 'px)'; |
66 | 66 |
67 var size = Math.max(toRect.width + Math.abs(translateX) * 2, toRect.height
+ Math.abs(translateY) * 2); | 67 var size = Math.max(toRect.width + Math.abs(translateX) * 2, toRect.height
+ Math.abs(translateY) * 2); |
68 var diameter = Math.sqrt(2 * size * size); | 68 var diameter = Math.sqrt(2 * size * size); |
69 var scaleX = diameter / toRect.width; | 69 var scaleX = diameter / toRect.width; |
70 var scaleY = diameter / toRect.height; | 70 var scaleY = diameter / toRect.height; |
71 var scale = 'scale(' + scaleX + ',' + scaleY + ')'; | 71 var scale = 'scale(' + scaleX + ',' + scaleY + ')'; |
72 | 72 |
73 this.setPrefixedProperty(shared.to, 'transformOrigin', '50% 50%'); | 73 this.setPrefixedProperty(shared.to, 'transformOrigin', '50% 50%'); |
74 shared.to.style.borderRadius = '50%'; | 74 shared.to.style.borderRadius = '50%'; |
75 | 75 |
76 this._effect = new KeyframeEffect(shared.to, [ | 76 this._effect = new KeyframeEffect(shared.to, [ |
77 {'transform': translate + ' scale(0)'}, | 77 {'transform': translate + ' scale(0)'}, |
78 {'transform': translate + ' ' + scale} | 78 {'transform': translate + ' ' + scale} |
79 ], this.timingFromConfig(config)); | 79 ], this.timingFromConfig(config)); |
80 return this._effect; | 80 return this._effect; |
81 }, | 81 }, |
82 | 82 |
83 complete: function() { | 83 complete: function() { |
84 if (this.sharedElements) { | 84 if (this.sharedElements) { |
85 this.setPrefixedProperty(this.sharedElements.to, 'transformOrigin', ''); | 85 this.setPrefixedProperty(this.sharedElements.to, 'transformOrigin', ''); |
86 this.sharedElements.to.style.borderRadius = ''; | 86 this.sharedElements.to.style.borderRadius = ''; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 }); | 90 }); |
91 | 91 |
92 </script> | 92 </script> |
OLD | NEW |