@dreamworld/dw-ripple 3.1.3 → 3.1.4-perf-issue.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/dw-ripple.js +12 -26
- package/package.json +1 -1
package/dw-ripple.js
CHANGED
|
@@ -4,6 +4,7 @@ import { css } from '@dreamworld/pwa-helpers/lit.js';
|
|
|
4
4
|
import { Ripple } from "@material/mwc-ripple";
|
|
5
5
|
import { RippleHandlers } from "@material/mwc-ripple/ripple-handlers";
|
|
6
6
|
|
|
7
|
+
let rippleTimeout;
|
|
7
8
|
export class DwRipple extends Ripple {
|
|
8
9
|
static get styles() {
|
|
9
10
|
return [
|
|
@@ -62,8 +63,6 @@ export class DwRipple extends Ripple {
|
|
|
62
63
|
this.__onTouchStart = this.__onTouchStart.bind(this);
|
|
63
64
|
this.__onMouseUp = this.__onMouseUp.bind(this);
|
|
64
65
|
this.__onTouchEnd = this.__onTouchEnd.bind(this);
|
|
65
|
-
this.__onPointerMove = this.__onPointerMove.bind(this);
|
|
66
|
-
this.__onTouchMove = this.__onTouchMove.bind(this);
|
|
67
66
|
|
|
68
67
|
if (!this.disableHover) {
|
|
69
68
|
parent.addEventListener("mouseenter", this._rippleHander.startHover);
|
|
@@ -74,42 +73,22 @@ export class DwRipple extends Ripple {
|
|
|
74
73
|
|
|
75
74
|
parent.addEventListener("mousedown", this.__onMouseDown);
|
|
76
75
|
parent.addEventListener("touchstart", this.__onTouchStart);
|
|
77
|
-
window.addEventListener("pointermove", this.__onPointerMove);
|
|
78
|
-
window.addEventListener("touchmove", this.__onTouchMove);
|
|
79
76
|
}
|
|
80
77
|
|
|
81
78
|
__onMouseDown(e) {
|
|
82
|
-
|
|
79
|
+
rippleTimeout = setTimeout(() => {
|
|
83
80
|
window.addEventListener("mouseup", this.__onMouseUp);
|
|
84
81
|
this._rippleHander.startPress(e);
|
|
85
82
|
}, 50);
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
__onTouchStart(e) {
|
|
89
|
-
|
|
86
|
+
rippleTimeout = setTimeout(() => {
|
|
90
87
|
window.addEventListener("touchend", this.__onTouchEnd);
|
|
91
88
|
this._rippleHander.startPress(e);
|
|
92
89
|
}, 50);
|
|
93
90
|
}
|
|
94
91
|
|
|
95
|
-
__onPointerMove() {
|
|
96
|
-
if (this._timeoutRippleOnMouseDown) {
|
|
97
|
-
clearTimeout(this._timeoutRippleOnMouseDown);
|
|
98
|
-
}
|
|
99
|
-
if (this._timeoutRippleOnTouchStart) {
|
|
100
|
-
clearTimeout(this._timeoutRippleOnTouchStart);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
__onTouchMove() {
|
|
105
|
-
if (this._timeoutRippleOnTouchStart) {
|
|
106
|
-
clearTimeout(this._timeoutRippleOnTouchStart);
|
|
107
|
-
}
|
|
108
|
-
if (this._timeoutRippleOnMouseDown) {
|
|
109
|
-
clearTimeout(this._timeoutRippleOnMouseDown);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
92
|
__onMouseUp() {
|
|
114
93
|
window.removeEventListener("mouseup", this.__onMouseUp);
|
|
115
94
|
this._rippleHander.endPress();
|
|
@@ -144,11 +123,18 @@ export class DwRipple extends Ripple {
|
|
|
144
123
|
|
|
145
124
|
window.removeEventListener("touchend", this.__onTouchEnd);
|
|
146
125
|
window.removeEventListener("mouseup", this.__onMouseUp);
|
|
147
|
-
window.removeEventListener("pointermove", this.__onPointerMove);
|
|
148
|
-
window.removeEventListener("touchmove", this.__onTouchMove);
|
|
149
126
|
|
|
150
127
|
super.disconnectedCallback();
|
|
151
128
|
}
|
|
152
129
|
}
|
|
153
130
|
|
|
154
131
|
customElements.define("dw-ripple", DwRipple);
|
|
132
|
+
|
|
133
|
+
// Its prevent ripple in touch device while user is scrolling list.
|
|
134
|
+
const _onTouchMove = () => {
|
|
135
|
+
if (rippleTimeout) {
|
|
136
|
+
clearTimeout(rippleTimeout);
|
|
137
|
+
rippleTimeout = null;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
window.addEventListener("touchmove", _onTouchMove);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamworld/dw-ripple",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4-perf-issue.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
|
"type": "module",
|