@dreamworld/dw-ripple 3.1.5 → 3.1.6

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 +9 -6
  2. package/package.json +2 -1
package/dw-ripple.js CHANGED
@@ -3,8 +3,11 @@ import { css } from '@dreamworld/pwa-helpers/lit.js';
3
3
  // These are the mwc element needed by this element.
4
4
  import { Ripple } from "@material/mwc-ripple";
5
5
  import { RippleHandlers } from "@material/mwc-ripple/ripple-handlers";
6
+ import DeviceInfo from '@dreamworld/device-info';
6
7
 
7
8
  let rippleTimeout;
9
+ const isTouch = DeviceInfo.info().touch;
10
+
8
11
  export class DwRipple extends Ripple {
9
12
  static get styles() {
10
13
  return [
@@ -71,8 +74,8 @@ export class DwRipple extends Ripple {
71
74
  parent.addEventListener("blur", this._rippleHander.endFocus);
72
75
  }
73
76
 
74
- parent.addEventListener("mousedown", this.__onMouseDown);
75
- parent.addEventListener("touchstart", this.__onTouchStart, { passive: true });
77
+ !isTouch && parent.addEventListener("mousedown", this.__onMouseDown);
78
+ isTouch && parent.addEventListener("touchstart", this.__onTouchStart, { passive: true });
76
79
  }
77
80
 
78
81
  __onMouseDown(e) {
@@ -117,12 +120,12 @@ export class DwRipple extends Ripple {
117
120
  parent.removeEventListener("blur", this._rippleHander.endFocus);
118
121
  }
119
122
 
120
- parent.removeEventListener("mousedown", this.__onMouseDown);
121
- parent.removeEventListener("touchstart", this.__onTouchStart, { passive: true });
123
+ !isTouch && parent.removeEventListener("mousedown", this.__onMouseDown);
124
+ isTouch && parent.removeEventListener("touchstart", this.__onTouchStart, { passive: true });
122
125
  }
123
126
 
124
- window.removeEventListener("touchend", this.__onTouchEnd);
125
- window.removeEventListener("mouseup", this.__onMouseUp);
127
+ isTouch && window.removeEventListener("touchend", this.__onTouchEnd);
128
+ !isTouch && window.removeEventListener("mouseup", this.__onMouseUp);
126
129
 
127
130
  super.disconnectedCallback();
128
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamworld/dw-ripple",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
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",
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "homepage": "https://github.com/DreamworldSolutions/dw-ripple#readme",
21
21
  "dependencies": {
22
+ "@dreamworld/device-info": "^1.3.2",
22
23
  "@dreamworld/pwa-helpers": "^1.16.5",
23
24
  "@material/mwc-ripple": "0.27.0"
24
25
  },