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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-behaviors/paper-ripple-behavior-extracted.js

Issue 1401633002: Update Polymer from 1.1.4 -> 1.1.5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dzhioev@ review Created 5 years, 2 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
(Empty)
1 /**
2 * `Polymer.PaperRippleBehavior` dynamically implements a ripple
3 * when the element has focus via pointer or keyboard.
4 *
5 * NOTE: This behavior is intended to be used in conjunction with and after
6 * `Polymer.IronButtonState` and `Polymer.IronControlState`.
7 *
8 * @polymerBehavior Polymer.PaperRippleBehavior
9 */
10 Polymer.PaperRippleBehavior = {
11
12 properties: {
13 /**
14 * If true, the element will not produce a ripple effect when interacted
15 * with via the pointer.
16 */
17 noink: {
18 type: Boolean,
19 observer: '_noinkChanged'
20 }
21 },
22
23 /**
24 * Ensures a `<paper-ripple>` element is available when the element is
25 * focused.
26 */
27 _buttonStateChanged: function() {
28 if (this.focused) {
29 this.ensureRipple();
30 }
31 },
32
33 /**
34 * In addition to the functionality provided in `IronButtonState`, ensures
35 * a ripple effect is created when the element is in a `pressed` state.
36 */
37 _downHandler: function(event) {
38 Polymer.IronButtonStateImpl._downHandler.call(this, event);
39 if (this.pressed) {
40 this.ensureRipple(event);
41 }
42 },
43
44 /**
45 * Ensures this element contains a ripple effect. For startup efficiency
46 * the ripple effect is dynamically on demand when needed.
47 * @param {event} triggeringEvent (optional) event that triggered the
48 * ripple.
49 */
50 ensureRipple: function(triggeringEvent) {
51 if (!this.hasRipple()) {
52 this._ripple = this._createRipple();
53 this._ripple.noink = this.noink;
54 var rippleContainer = this._rippleContainer || this.root;
55 if (rippleContainer) {
56 Polymer.dom(rippleContainer).appendChild(this._ripple);
57 }
58 var domContainer = rippleContainer === this.shadyRoot ? this :
59 rippleContainer;
60 if (triggeringEvent && domContainer.contains(triggeringEvent.target)) {
61 this._ripple.uiDownAction(triggeringEvent);
62 }
63 }
64 },
65
66 /**
67 * Returns the `<paper-ripple>` element used by this element to create
68 * ripple effects. The element's ripple is created on demand, when
69 * necessary, and calling this method will force the
70 * ripple to be created.
71 */
72 getRipple: function() {
73 this.ensureRipple();
74 return this._ripple;
75 },
76
77 /**
78 * Returns true if this element currently contains a ripple effect.
79 * @return {boolean}
80 */
81 hasRipple: function() {
82 return Boolean(this._ripple);
83 },
84
85 /**
86 * Create the element's ripple effect via creating a `<paper-ripple>`.
87 * Override this method to customize the ripple element.
88 * @return {element} Returns a `<paper-ripple>` element.
89 */
90 _createRipple: function() {
91 return document.createElement('paper-ripple');
92 },
93
94 _noinkChanged: function(noink) {
95 if (this.hasRipple()) {
96 this._ripple.noink = noink;
97 }
98 }
99
100 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698