kitzo 1.1.5 → 1.1.7

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
@@ -21,7 +21,7 @@ npm i kitzo
21
21
  or
22
22
 
23
23
  ```javascript
24
- <script src="https://cdn.jsdelivr.net/npm/kitzo@1.1.5/dist/kitzo.umd.min.js"></script>
24
+ <script src="https://cdn.jsdelivr.net/npm/kitzo@1.1.7/dist/kitzo.umd.min.js"></script>
25
25
  ```
26
26
 
27
27
  > Attach this script tag in the html head tag and you are good to go.
package/dist/kitzo.esm.js CHANGED
@@ -151,12 +151,7 @@ function debounce(fn, delay = 300) {
151
151
  }
152
152
 
153
153
  function rippleStyles() {
154
- return `.kitzo-ripple {
155
- position: relative;
156
- overflow: hidden;
157
- }
158
-
159
- .kitzo-ripples {
154
+ return `.kitzo-ripples {
160
155
  display: block;
161
156
  position: absolute;
162
157
  top: 0;
@@ -191,6 +186,7 @@ function rippleStyles() {
191
186
 
192
187
  //! Ripple effect
193
188
  let rippleListenerAdded = false;
189
+ const rippleConfigMap = new WeakMap();
194
190
 
195
191
  function ripple(element, config = {}) {
196
192
  if (!element) {
@@ -210,22 +206,28 @@ function ripple(element, config = {}) {
210
206
  config
211
207
  );
212
208
 
213
- const { opacity, color, duration, size } = config;
214
-
215
209
  const allButtons = getButtons(element);
216
210
  if (!allButtons) {
217
211
  console.error('[kitzo.ripple] No elements found for kitzoRipple');
218
212
  return;
219
213
  }
220
214
  allButtons.forEach((btn) => {
221
- btn.classList.add('kitzo-ripple');
222
- btn.setAttribute('data-kitzo-ripple', 'true');
215
+ btn.setAttribute('data-kitzo-ripple', true);
216
+ rippleConfigMap.set(btn, config);
217
+ const { position, overflow } = window.getComputedStyle(btn);
218
+ if (position === 'static') {
219
+ btn.style.position = 'relative';
220
+ }
221
+ if (overflow === 'visible') {
222
+ btn.style.overflow = 'hidden';
223
+ }
223
224
  });
224
225
 
225
226
  if (!rippleListenerAdded) {
226
227
  document.addEventListener('mousedown', (e) => {
227
228
  const btn = e.target.closest('[data-kitzo-ripple]');
228
229
  if (btn) {
230
+ const { opacity, duration, color, size } = rippleConfigMap.get(btn);
229
231
  const span = document.createElement('span');
230
232
  span.className = 'kitzo-ripples';
231
233
  btn.appendChild(span);
package/dist/kitzo.umd.js CHANGED
@@ -157,12 +157,7 @@
157
157
  }
158
158
 
159
159
  function rippleStyles() {
160
- return `.kitzo-ripple {
161
- position: relative;
162
- overflow: hidden;
163
- }
164
-
165
- .kitzo-ripples {
160
+ return `.kitzo-ripples {
166
161
  display: block;
167
162
  position: absolute;
168
163
  top: 0;
@@ -197,6 +192,7 @@
197
192
 
198
193
  //! Ripple effect
199
194
  let rippleListenerAdded = false;
195
+ const rippleConfigMap = new WeakMap();
200
196
 
201
197
  function ripple(element, config = {}) {
202
198
  if (!element) {
@@ -216,22 +212,28 @@
216
212
  config
217
213
  );
218
214
 
219
- const { opacity, color, duration, size } = config;
220
-
221
215
  const allButtons = getButtons(element);
222
216
  if (!allButtons) {
223
217
  console.error('[kitzo.ripple] No elements found for kitzoRipple');
224
218
  return;
225
219
  }
226
220
  allButtons.forEach((btn) => {
227
- btn.classList.add('kitzo-ripple');
228
- btn.setAttribute('data-kitzo-ripple', 'true');
221
+ btn.setAttribute('data-kitzo-ripple', true);
222
+ rippleConfigMap.set(btn, config);
223
+ const { position, overflow } = window.getComputedStyle(btn);
224
+ if (position === 'static') {
225
+ btn.style.position = 'relative';
226
+ }
227
+ if (overflow === 'visible') {
228
+ btn.style.overflow = 'hidden';
229
+ }
229
230
  });
230
231
 
231
232
  if (!rippleListenerAdded) {
232
233
  document.addEventListener('mousedown', (e) => {
233
234
  const btn = e.target.closest('[data-kitzo-ripple]');
234
235
  if (btn) {
236
+ const { opacity, duration, color, size } = rippleConfigMap.get(btn);
235
237
  const span = document.createElement('span');
236
238
  span.className = 'kitzo-ripples';
237
239
  btn.appendChild(span);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitzo",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "A lightweight JavaScript UI micro-library.",
5
5
  "type": "module",
6
6
  "main": "./dist/kitzo.umd.js",