OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 6 Code distributed by Google as part of the polymer project is also |
| 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 8 --> |
| 9 |
| 10 <!-- |
| 11 `paper-ripple` provides a visual effect that other paper elements can |
| 12 use to simulate a rippling effect emanating from the point of contact. The |
| 13 effect can be visualized as a concentric circle with motion. |
| 14 |
| 15 Example: |
| 16 |
| 17 <paper-ripple></paper-ripple> |
| 18 |
| 19 `paper-ripple` listens to "down" and "up" events so it would display ripple |
| 20 effect when touches on it. You can also defeat the default behavior and |
| 21 manually route the down and up actions to the ripple element. Note that it is |
| 22 important if you call downAction() you will have to make sure to call upAction() |
| 23 so that `paper-ripple` would end the animation loop. |
| 24 |
| 25 Example: |
| 26 |
| 27 <paper-ripple id="ripple" style="pointer-events: none;"></paper-ripple> |
| 28 ... |
| 29 downAction: function(e) { |
| 30 this.$.ripple.downAction({x: e.x, y: e.y}); |
| 31 }, |
| 32 upAction: function(e) { |
| 33 this.$.ripple.upAction(); |
| 34 } |
| 35 |
| 36 Styling ripple effect: |
| 37 |
| 38 Use CSS color property to style the ripple: |
| 39 |
| 40 paper-ripple { |
| 41 color: #4285f4; |
| 42 } |
| 43 |
| 44 Note that CSS color property is inherited so it is not required to set it on |
| 45 the `paper-ripple` element directly. |
| 46 |
| 47 Apply `recenteringTouch` class to make the recentering rippling effect. |
| 48 |
| 49 <paper-ripple class="recenteringTouch"></paper-ripple> |
| 50 |
| 51 Apply `circle` class to make the rippling effect within a circle. |
| 52 |
| 53 <paper-ripple class="circle"></paper-ripple> |
| 54 |
| 55 @group Paper Elements |
| 56 @element paper-ripple |
| 57 @homepage github.io |
| 58 --> |
| 59 |
| 60 <link rel="import" href="../polymer/polymer.html"> |
| 61 |
| 62 <polymer-element name="paper-ripple" attributes="initialOpacity opacityDecayVelo
city" assetpath=""> |
| 63 <template> |
| 64 |
| 65 <style> |
| 66 |
| 67 :host { |
| 68 display: block; |
| 69 position: relative; |
| 70 } |
| 71 |
| 72 #canvas { |
| 73 pointer-events: none; |
| 74 position: absolute; |
| 75 top: 0; |
| 76 left: 0; |
| 77 width: 100%; |
| 78 height: 100%; |
| 79 } |
| 80 |
| 81 :host(.circle) #canvas { |
| 82 border-radius: 50%; |
| 83 } |
| 84 |
| 85 </style> |
| 86 |
| 87 </template> |
| 88 |
| 89 </polymer-element> |
| 90 <script src="paper-ripple-extracted.js"></script> |
OLD | NEW |