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

Side by Side Diff: third_party/polymer/components/paper-ripple/paper-ripple.html

Issue 2113853002: Run bower update (Closed) Base URL: https://github.com/catapult-project/catapult@polymer10-migration
Patch Set: Created 4 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 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 3 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 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 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 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 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 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
8 --> 9 -->
9 10
10 <link rel="import" href="../polymer/polymer.html"> 11 <link rel="import" href="../polymer/polymer.html">
11 <link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html "> 12 <link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html ">
(...skipping 18 matching lines...) Expand all
30 effect when touches on it. You can also defeat the default behavior and 31 effect when touches on it. You can also defeat the default behavior and
31 manually route the down and up actions to the ripple element. Note that it is 32 manually route the down and up actions to the ripple element. Note that it is
32 important if you call `downAction()` you will have to make sure to call 33 important if you call `downAction()` you will have to make sure to call
33 `upAction()` so that `paper-ripple` would end the animation loop. 34 `upAction()` so that `paper-ripple` would end the animation loop.
34 35
35 Example: 36 Example:
36 37
37 <paper-ripple id="ripple" style="pointer-events: none;"></paper-ripple> 38 <paper-ripple id="ripple" style="pointer-events: none;"></paper-ripple>
38 ... 39 ...
39 downAction: function(e) { 40 downAction: function(e) {
40 this.$.ripple.downAction({x: e.x, y: e.y}); 41 this.$.ripple.downAction({detail: {x: e.x, y: e.y}});
41 }, 42 },
42 upAction: function(e) { 43 upAction: function(e) {
43 this.$.ripple.upAction(); 44 this.$.ripple.upAction();
44 } 45 }
45 46
46 Styling ripple effect: 47 Styling ripple effect:
47 48
48 Use CSS color property to style the ripple: 49 Use CSS color property to style the ripple:
49 50
50 paper-ripple { 51 paper-ripple {
(...skipping 17 matching lines...) Expand all
68 <paper-ripple class="circle"></paper-ripple> 69 <paper-ripple class="circle"></paper-ripple>
69 70
70 @group Paper Elements 71 @group Paper Elements
71 @element paper-ripple 72 @element paper-ripple
72 @hero hero.svg 73 @hero hero.svg
73 @demo demo/index.html 74 @demo demo/index.html
74 --> 75 -->
75 76
76 <dom-module id="paper-ripple"> 77 <dom-module id="paper-ripple">
77 78
78 <!--
79 Fired when the animation finishes. This is useful if you want to wait until th e ripple
80 animation finishes to perform some action.
81
82 @event transitionend
83 @param {Object} detail
84 @param {Object} detail.node The animated node
85 -->
86
87 <template> 79 <template>
88 <style> 80 <style>
89 :host { 81 :host {
90 display: block; 82 display: block;
91 position: absolute; 83 position: absolute;
92 border-radius: inherit; 84 border-radius: inherit;
93 overflow: hidden; 85 overflow: hidden;
94 top: 0; 86 top: 0;
95 left: 0; 87 left: 0;
96 right: 0; 88 right: 0;
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 544
553 _boundAnimate: { 545 _boundAnimate: {
554 type: Function, 546 type: Function,
555 value: function() { 547 value: function() {
556 return this.animate.bind(this); 548 return this.animate.bind(this);
557 } 549 }
558 } 550 }
559 }, 551 },
560 552
561 get target () { 553 get target () {
562 var ownerRoot = Polymer.dom(this).getOwnerRoot(); 554 return this.keyEventTarget;
563 var target;
564
565 if (this.parentNode.nodeType == 11) { // DOCUMENT_FRAGMENT_NODE
566 target = ownerRoot.host;
567 } else {
568 target = this.parentNode;
569 }
570
571 return target;
572 }, 555 },
573 556
574 keyBindings: { 557 keyBindings: {
575 'enter:keydown': '_onEnterKeydown', 558 'enter:keydown': '_onEnterKeydown',
576 'space:keydown': '_onSpaceKeydown', 559 'space:keydown': '_onSpaceKeydown',
577 'space:keyup': '_onSpaceKeyup' 560 'space:keyup': '_onSpaceKeyup'
578 }, 561 },
579 562
580 attached: function() { 563 attached: function() {
581 // Set up a11yKeysBehavior to listen to key events on the target, 564 // Set up a11yKeysBehavior to listen to key events on the target,
582 // so that space and enter activate the ripple even if the target doesn' t 565 // so that space and enter activate the ripple even if the target doesn' t
583 // handle key events. The key handlers deal with `noink` themselves. 566 // handle key events. The key handlers deal with `noink` themselves.
584 this.keyEventTarget = this.target; 567 if (this.parentNode.nodeType == 11) { // DOCUMENT_FRAGMENT_NODE
585 this.listen(this.target, 'up', 'uiUpAction'); 568 this.keyEventTarget = Polymer.dom(this).getOwnerRoot().host;
586 this.listen(this.target, 'down', 'uiDownAction'); 569 } else {
570 this.keyEventTarget = this.parentNode;
571 }
572 var keyEventTarget = /** @type {!EventTarget} */ (this.keyEventTarget);
573 this.listen(keyEventTarget, 'up', 'uiUpAction');
574 this.listen(keyEventTarget, 'down', 'uiDownAction');
587 }, 575 },
588 576
589 detached: function() { 577 detached: function() {
590 this.unlisten(this.target, 'up', 'uiUpAction'); 578 this.unlisten(this.keyEventTarget, 'up', 'uiUpAction');
591 this.unlisten(this.target, 'down', 'uiDownAction'); 579 this.unlisten(this.keyEventTarget, 'down', 'uiDownAction');
580 this.keyEventTarget = null;
592 }, 581 },
593 582
594 get shouldKeepAnimating () { 583 get shouldKeepAnimating () {
595 for (var index = 0; index < this.ripples.length; ++index) { 584 for (var index = 0; index < this.ripples.length; ++index) {
596 if (!this.ripples[index].isAnimationComplete) { 585 if (!this.ripples[index].isAnimationComplete) {
597 return true; 586 return true;
598 } 587 }
599 } 588 }
600 589
601 return false; 590 return false;
(...skipping 27 matching lines...) Expand all
629 downAction: function(event) { 618 downAction: function(event) {
630 if (this.holdDown && this.ripples.length > 0) { 619 if (this.holdDown && this.ripples.length > 0) {
631 return; 620 return;
632 } 621 }
633 622
634 var ripple = this.addRipple(); 623 var ripple = this.addRipple();
635 624
636 ripple.downAction(event); 625 ripple.downAction(event);
637 626
638 if (!this._animating) { 627 if (!this._animating) {
628 this._animating = true;
639 this.animate(); 629 this.animate();
640 } 630 }
641 }, 631 },
642 632
643 /** 633 /**
644 * Provokes a ripple up effect via a UI event, 634 * Provokes a ripple up effect via a UI event,
645 * respecting the `noink` property. 635 * respecting the `noink` property.
646 * @param {Event=} event 636 * @param {Event=} event
647 */ 637 */
648 uiUpAction: function(event) { 638 uiUpAction: function(event) {
649 if (!this.noink) { 639 if (!this.noink) {
650 this.upAction(event); 640 this.upAction(event);
651 } 641 }
652 }, 642 },
653 643
654 /** 644 /**
655 * Provokes a ripple up effect via a UI event, 645 * Provokes a ripple up effect via a UI event,
656 * *not* respecting the `noink` property. 646 * *not* respecting the `noink` property.
657 * @param {Event=} event 647 * @param {Event=} event
658 */ 648 */
659 upAction: function(event) { 649 upAction: function(event) {
660 if (this.holdDown) { 650 if (this.holdDown) {
661 return; 651 return;
662 } 652 }
663 653
664 this.ripples.forEach(function(ripple) { 654 this.ripples.forEach(function(ripple) {
665 ripple.upAction(event); 655 ripple.upAction(event);
666 }); 656 });
667 657
658 this._animating = true;
668 this.animate(); 659 this.animate();
669 }, 660 },
670 661
671 onAnimationComplete: function() { 662 onAnimationComplete: function() {
672 this._animating = false; 663 this._animating = false;
673 this.$.background.style.backgroundColor = null; 664 this.$.background.style.backgroundColor = null;
674 this.fire('transitionend'); 665 this.fire('transitionend');
675 }, 666 },
676 667
677 addRipple: function() { 668 addRipple: function() {
(...skipping 18 matching lines...) Expand all
696 this.ripples.splice(rippleIndex, 1); 687 this.ripples.splice(rippleIndex, 1);
697 688
698 ripple.remove(); 689 ripple.remove();
699 690
700 if (!this.ripples.length) { 691 if (!this.ripples.length) {
701 this._setAnimating(false); 692 this._setAnimating(false);
702 } 693 }
703 }, 694 },
704 695
705 animate: function() { 696 animate: function() {
697 if (!this._animating) {
698 return;
699 }
706 var index; 700 var index;
707 var ripple; 701 var ripple;
708 702
709 this._animating = true;
710
711 for (index = 0; index < this.ripples.length; ++index) { 703 for (index = 0; index < this.ripples.length; ++index) {
712 ripple = this.ripples[index]; 704 ripple = this.ripples[index];
713 705
714 ripple.draw(); 706 ripple.draw();
715 707
716 this.$.background.style.opacity = ripple.outerOpacity; 708 this.$.background.style.opacity = ripple.outerOpacity;
717 709
718 if (ripple.isOpacityFullyDecayed && !ripple.isRestingAtMaxRadius) { 710 if (ripple.isOpacityFullyDecayed && !ripple.isRestingAtMaxRadius) {
719 this.removeRipple(ripple); 711 this.removeRipple(ripple);
720 } 712 }
(...skipping 24 matching lines...) Expand all
745 _holdDownChanged: function(newVal, oldVal) { 737 _holdDownChanged: function(newVal, oldVal) {
746 if (oldVal === undefined) { 738 if (oldVal === undefined) {
747 return; 739 return;
748 } 740 }
749 if (newVal) { 741 if (newVal) {
750 this.downAction(); 742 this.downAction();
751 } else { 743 } else {
752 this.upAction(); 744 this.upAction();
753 } 745 }
754 } 746 }
747
748 /**
749 Fired when the animation finishes.
750 This is useful if you want to wait until
751 the ripple animation finishes to perform some action.
752
753 @event transitionend
754 @param {{node: Object}} detail Contains the animated node.
755 */
755 }); 756 });
756 })(); 757 })();
757 </script> 758 </script>
OLDNEW
« no previous file with comments | « third_party/polymer/components/paper-ripple/bower.json ('k') | third_party/polymer/components/paper-ripple/test/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698