@dreamworld/dw-ripple 2.4.0-development.3 → 2.4.0-development.4

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.
Files changed (2) hide show
  1. package/dw-ripple.js +26 -4
  2. package/package.json +1 -1
package/dw-ripple.js CHANGED
@@ -49,6 +49,8 @@ export class DwRipple extends Ripple {
49
49
  this.__onTouchStart = this.__onTouchStart.bind(this);
50
50
  this.__onMouseUp = this.__onMouseUp.bind(this);
51
51
  this.__onTouchEnd = this.__onTouchEnd.bind(this);
52
+ this.__onPointerMove = this.__onPointerMove.bind(this);
53
+ this.__onTouchMove = this.__onTouchMove.bind(this);
52
54
 
53
55
  if (!this.disableHover) {
54
56
  parent.addEventListener("mouseenter", this._rippleHander.startHover);
@@ -59,16 +61,34 @@ export class DwRipple extends Ripple {
59
61
 
60
62
  parent.addEventListener("mousedown", this.__onMouseDown);
61
63
  parent.addEventListener("touchstart", this.__onTouchStart);
64
+ window.addEventListener("pointermove", this.__onPointerMove);
65
+ window.addEventListener("touchmove", this.__onTouchMove);
62
66
  }
63
67
 
64
68
  __onMouseDown(e) {
65
- window.addEventListener("mouseup", this.__onMouseUp);
66
- this._rippleHander.startPress(e);
69
+ this.delayMouseDown = setTimeout(() => {
70
+ window.addEventListener("mouseup", this.__onMouseUp);
71
+ this._rippleHander.startPress(e);
72
+ }, 50);
67
73
  }
68
74
 
69
75
  __onTouchStart(e) {
70
- window.addEventListener("touchend", this.__onTouchEnd);
71
- this._rippleHander.startPress(e);
76
+ this.delayTouchStart = setTimeout(() => {
77
+ window.addEventListener("touchend", this.__onTouchEnd);
78
+ this._rippleHander.startPress(e);
79
+ }, 50);
80
+ }
81
+
82
+ __onPointerMove() {
83
+ if (this.delayMouseDown) {
84
+ clearTimeout(this.delayMouseDown);
85
+ }
86
+ }
87
+
88
+ __onTouchMove() {
89
+ if (this.delayTouchStart) {
90
+ clearTimeout(this.delayTouchStart);
91
+ }
72
92
  }
73
93
 
74
94
  __onMouseUp() {
@@ -105,6 +125,8 @@ export class DwRipple extends Ripple {
105
125
 
106
126
  window.removeEventListener("touchend", this.__onTouchEnd);
107
127
  window.removeEventListener("mouseup", this.__onMouseUp);
128
+ window.removeEventListener("pointermove", this.__onPointerMove);
129
+ window.removeEventListener("touchmove", this.__onTouchMove);
108
130
 
109
131
  super.disconnectedCallback();
110
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamworld/dw-ripple",
3
- "version": "2.4.0-development.3",
3
+ "version": "2.4.0-development.4",
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": {