@dreamworld/dw-ripple 2.2.3-development.1 → 2.4.0-development.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/demo/dw-ripple-demo.js +26 -0
- package/dw-ripple.js +20 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ theming variables.
|
|
|
41
41
|
- `unbounded` Boolean. By defualt ripple effect are shown from the point where user clicks. If we want to show ripple
|
|
42
42
|
always from the center (irrespective of the click position) then set to `true`. When this is set, ripple is shown in
|
|
43
43
|
circular shape always.
|
|
44
|
+
- `enableHover` Boolean. Set to enable hover and focuse for ripple.
|
|
44
45
|
|
|
45
46
|
## Theming
|
|
46
47
|
By default ripple is shown in `--mdc-theme-on-surface`. That should be ok for most places. When need to change it at
|
package/demo/dw-ripple-demo.js
CHANGED
|
@@ -68,6 +68,32 @@ export class DwRippleDemo extends LitElement {
|
|
|
68
68
|
</mwc-formfield>
|
|
69
69
|
|
|
70
70
|
<h2>Ripple</h2>
|
|
71
|
+
<div class="demo-box">
|
|
72
|
+
Default
|
|
73
|
+
<dw-ripple enableHover></dw-ripple>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="demo-box">
|
|
76
|
+
Primary
|
|
77
|
+
<dw-ripple primary enableHover></dw-ripple>
|
|
78
|
+
</div>
|
|
79
|
+
<div class="demo-box">
|
|
80
|
+
Secondary
|
|
81
|
+
<dw-ripple secondary enableHover tabindex="1"></dw-ripple>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="demo-box custom">
|
|
84
|
+
Custom
|
|
85
|
+
<dw-ripple enableHover></dw-ripple>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="demo-box">
|
|
88
|
+
unbounded
|
|
89
|
+
<dw-ripple unbounded enableHover></dw-ripple>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="demo-box">
|
|
92
|
+
disabled
|
|
93
|
+
<dw-ripple disabled enableHover></dw-ripple>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<h2>Ripple without hover and focuse</h2>
|
|
71
97
|
<div class="demo-box">
|
|
72
98
|
Default
|
|
73
99
|
<dw-ripple></dw-ripple>
|
package/dw-ripple.js
CHANGED
|
@@ -45,7 +45,12 @@ export class DwRipple extends Ripple {
|
|
|
45
45
|
/**
|
|
46
46
|
* Set to `true` if ripple should not be shown
|
|
47
47
|
*/
|
|
48
|
-
disabled: { type: Boolean, reflect: true }
|
|
48
|
+
disabled: { type: Boolean, reflect: true },
|
|
49
|
+
|
|
50
|
+
/**Set to `true` to show hover or focuse in ripple
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
enableHover: { type: Boolean, reflect: true }
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
|
|
@@ -69,12 +74,15 @@ export class DwRipple extends Ripple {
|
|
|
69
74
|
this.__onMouseUp = this.__onMouseUp.bind(this);
|
|
70
75
|
this.__onTouchEnd = this.__onTouchEnd.bind(this);
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
if(this.enableHover) {
|
|
78
|
+
parent.addEventListener('mouseenter', this._rippleHander.startHover);
|
|
79
|
+
parent.addEventListener('mouseleave', this._rippleHander.endHover);
|
|
80
|
+
parent.addEventListener('focus', this._rippleHander.startFocus);
|
|
81
|
+
parent.addEventListener('blur', this._rippleHander.endFocus);
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
parent.addEventListener('mousedown', this.__onMouseDown);
|
|
75
85
|
parent.addEventListener('touchstart', this.__onTouchStart);
|
|
76
|
-
parent.addEventListener('focus', this._rippleHander.startFocus);
|
|
77
|
-
parent.addEventListener('blur', this._rippleHander.endFocus);
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
__onMouseDown(e) {
|
|
@@ -108,13 +116,16 @@ export class DwRipple extends Ripple {
|
|
|
108
116
|
disconnectedCallback() {
|
|
109
117
|
const parent = this.__getParentNode();
|
|
110
118
|
if (parent) {
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
|
|
120
|
+
if(this.enableHover) {
|
|
121
|
+
parent.removeEventListener('mouseenter', this._rippleHander.startHover);
|
|
122
|
+
parent.removeEventListener('mouseleave', this._rippleHander.endHover);
|
|
123
|
+
parent.removeEventListener('focus', this._rippleHander.startFocus);
|
|
124
|
+
parent.removeEventListener('blur', this._rippleHander.endFocus);
|
|
125
|
+
}
|
|
113
126
|
|
|
114
127
|
parent.removeEventListener('mousedown', this.__onMouseDown);
|
|
115
128
|
parent.removeEventListener('touchstart', this.__onTouchStart);
|
|
116
|
-
parent.removeEventListener('focus', this._rippleHander.startFocus);
|
|
117
|
-
parent.removeEventListener('blur', this._rippleHander.endFocus);
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
window.removeEventListener('touchend', this.__onTouchEnd);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamworld/dw-ripple",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-development.1",
|
|
4
4
|
"description": "Ripple element created as child-class of [`mwc-ripple`] (https://github.com/material-components/material-components-web-components/tree/master/packages/ripple)",
|
|
5
5
|
"main": "dw-ripple.js",
|
|
6
6
|
"scripts": {
|