@dreamworld/dw-ripple 2.3.0 → 2.4.0-development.2

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 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
@@ -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
+ /**
51
+ * Set to `true` to show hover or focuse in ripple
52
+ */
53
+ enableHover: { type: Boolean }
49
54
  }
50
55
  }
51
56
 
@@ -54,6 +59,7 @@ export class DwRipple extends Ripple {
54
59
  this.primary = false;
55
60
  this.secondary = false;
56
61
  this.disabled = false;
62
+ this.enableHover = false;
57
63
  }
58
64
 
59
65
  connectedCallback() {
@@ -69,12 +75,15 @@ export class DwRipple extends Ripple {
69
75
  this.__onMouseUp = this.__onMouseUp.bind(this);
70
76
  this.__onTouchEnd = this.__onTouchEnd.bind(this);
71
77
 
72
- parent.addEventListener('mouseenter', this._rippleHander.startHover);
73
- parent.addEventListener('mouseleave', this._rippleHander.endHover);
78
+ if(this.enableHover) {
79
+ parent.addEventListener('mouseenter', this._rippleHander.startHover);
80
+ parent.addEventListener('mouseleave', this._rippleHander.endHover);
81
+ parent.addEventListener('focus', this._rippleHander.startFocus);
82
+ parent.addEventListener('blur', this._rippleHander.endFocus);
83
+ }
84
+
74
85
  parent.addEventListener('mousedown', this.__onMouseDown);
75
86
  parent.addEventListener('touchstart', this.__onTouchStart);
76
- parent.addEventListener('focus', this._rippleHander.startFocus);
77
- parent.addEventListener('blur', this._rippleHander.endFocus);
78
87
  }
79
88
 
80
89
  __onMouseDown(e) {
@@ -108,13 +117,16 @@ export class DwRipple extends Ripple {
108
117
  disconnectedCallback() {
109
118
  const parent = this.__getParentNode();
110
119
  if (parent) {
111
- parent.removeEventListener('mouseenter', this._rippleHander.startHover);
112
- parent.removeEventListener('mouseleave', this._rippleHander.endHover);
120
+
121
+ if(this.enableHover) {
122
+ parent.removeEventListener('mouseenter', this._rippleHander.startHover);
123
+ parent.removeEventListener('mouseleave', this._rippleHander.endHover);
124
+ parent.removeEventListener('focus', this._rippleHander.startFocus);
125
+ parent.removeEventListener('blur', this._rippleHander.endFocus);
126
+ }
113
127
 
114
128
  parent.removeEventListener('mousedown', this.__onMouseDown);
115
129
  parent.removeEventListener('touchstart', this.__onTouchStart);
116
- parent.removeEventListener('focus', this._rippleHander.startFocus);
117
- parent.removeEventListener('blur', this._rippleHander.endFocus);
118
130
  }
119
131
 
120
132
  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.0",
3
+ "version": "2.4.0-development.2",
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": {