kitzo 2.0.19 → 2.0.21
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 +1 -1
- package/dist/kitzo.d.ts +7 -1
- package/dist/kitzo.esm.js +35 -40
- package/dist/kitzo.umd.js +35 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ npm i kitzo
|
|
|
25
25
|
or
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.21/dist/kitzo.umd.min.js"></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
> Attach this script tag in the html head tag and you are good to go.
|
package/dist/kitzo.d.ts
CHANGED
|
@@ -63,7 +63,13 @@ export type clippath = (
|
|
|
63
63
|
element: string | Element | NodeListOf<Element>,
|
|
64
64
|
config?: {
|
|
65
65
|
/** Optional text inside the clippath element */
|
|
66
|
-
|
|
66
|
+
textOption?: {
|
|
67
|
+
selector: string;
|
|
68
|
+
value: string | number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Custom class to clip-path element */
|
|
72
|
+
class?: string;
|
|
67
73
|
|
|
68
74
|
/** Size of the clippath circle (px or %). Default: '20%' */
|
|
69
75
|
clippathSize?: string | number;
|
package/dist/kitzo.esm.js
CHANGED
|
@@ -404,10 +404,12 @@ function clippathStyles() {
|
|
|
404
404
|
clip-path: circle(0 at var(--kitzo-clippath-pos-x) var(--kitzo-clippath-pos-y));
|
|
405
405
|
transition: var(--kitzo-clippath-transition);
|
|
406
406
|
}
|
|
407
|
-
|
|
408
407
|
.kitzo-clippath-div.show {
|
|
409
408
|
opacity: 1;
|
|
410
409
|
clip-path: circle(var(--kitzo-clippath-size) at var(--kitzo-clippath-pos-x) var(--kitzo-clippath-pos-y));
|
|
410
|
+
}
|
|
411
|
+
[data-kitzo-clippath] * {
|
|
412
|
+
pointer-events: none !important;
|
|
411
413
|
}`;
|
|
412
414
|
}
|
|
413
415
|
|
|
@@ -445,9 +447,10 @@ function clippath(element, config = {}) {
|
|
|
445
447
|
|
|
446
448
|
config = Object.assign(
|
|
447
449
|
{
|
|
448
|
-
|
|
450
|
+
textOption: null,
|
|
449
451
|
clippathSize: '20%',
|
|
450
452
|
smooth: true,
|
|
453
|
+
class: '',
|
|
451
454
|
style: {},
|
|
452
455
|
},
|
|
453
456
|
config
|
|
@@ -483,69 +486,61 @@ function clippath(element, config = {}) {
|
|
|
483
486
|
|
|
484
487
|
document.addEventListener('mouseover', (e) => {
|
|
485
488
|
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
486
|
-
|
|
487
489
|
if (btn) {
|
|
488
490
|
isHovering = true;
|
|
489
|
-
const { text, style, clippathSize, smooth } = clippathConfigMap.get(btn);
|
|
490
|
-
const { width, height, top, left } = btn.getBoundingClientRect();
|
|
491
|
-
|
|
492
491
|
clippathDiv.removeAttribute('style');
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
} else {
|
|
502
|
-
clippathDiv.innerHTML = text;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
clippathDiv.style.setProperty('--kitzo-clippath-transition', smooth ? 'clip-path 150ms ease-out, opacity 150ms' : 'none');
|
|
506
|
-
clippathDiv.style.setProperty('--kitzo-clippath-size', getClippathSize(clippathSize));
|
|
507
|
-
|
|
508
|
-
const { borderRadius, font, letterSpacing, lineHeight, border, boxSizing, padding } = window.getComputedStyle(btn);
|
|
509
|
-
|
|
510
|
-
Object.assign(clippathDiv.style, {
|
|
492
|
+
const { textOption, clippathSize, smooth, style } = clippathConfigMap.get(btn);
|
|
493
|
+
|
|
494
|
+
const { top, left, width, height } = btn.getBoundingClientRect();
|
|
495
|
+
const cloned = btn.cloneNode(true);
|
|
496
|
+
cloned.className = cloned.className + ` ${clippathConfigMap.get(btn).class}`;
|
|
497
|
+
cloned.removeAttribute('data-kitzo-clippath');
|
|
498
|
+
cloned.setAttribute('data-temp-clippath-el', true);
|
|
499
|
+
Object.assign(cloned.style, {
|
|
511
500
|
backgroundColor: '#01c2b8',
|
|
512
501
|
color: 'white',
|
|
513
|
-
borderRadius,
|
|
514
|
-
font,
|
|
515
|
-
letterSpacing,
|
|
516
|
-
lineHeight,
|
|
517
|
-
border,
|
|
518
|
-
boxSizing,
|
|
519
|
-
padding,
|
|
520
502
|
...style,
|
|
521
503
|
});
|
|
522
504
|
|
|
505
|
+
if (textOption && textOption instanceof Object) {
|
|
506
|
+
const target = cloned.querySelector(textOption.selector);
|
|
507
|
+
if (target && (typeof textOption.value === 'string' || typeof textOption.value === 'number')) {
|
|
508
|
+
target.textContent = textOption.value;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
clippathDiv.style.width = `${width}px`;
|
|
513
|
+
clippathDiv.style.height = `${height}px`;
|
|
514
|
+
clippathDiv.style.translate = `${left}px ${top}px`;
|
|
515
|
+
clippathDiv.style.setProperty('--kitzo-clippath-size', getClippathSize(clippathSize));
|
|
516
|
+
clippathDiv.style.setProperty('--kitzo-clippath-transition', smooth ? 'clip-path 150ms ease-out, opacity 150ms' : 'none');
|
|
517
|
+
clippathDiv.appendChild(cloned);
|
|
523
518
|
requestAnimationFrame(() => {
|
|
524
519
|
clippathDiv.classList.add('show');
|
|
525
520
|
});
|
|
526
521
|
}
|
|
527
522
|
});
|
|
528
|
-
|
|
529
523
|
document.addEventListener('mouseout', (e) => {
|
|
530
524
|
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
531
|
-
|
|
532
525
|
if (btn) {
|
|
533
526
|
clippathDiv.classList.remove('show');
|
|
534
|
-
|
|
527
|
+
setTimeout(() => {
|
|
528
|
+
clippathDiv.querySelectorAll('[data-temp-clippath-el]').forEach((el) => el.remove());
|
|
529
|
+
}, 150);
|
|
535
530
|
}
|
|
536
531
|
});
|
|
537
532
|
|
|
538
533
|
document.addEventListener('mousemove', (e) => {
|
|
539
534
|
if (!isHovering) return;
|
|
540
|
-
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
541
535
|
|
|
536
|
+
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
542
537
|
if (btn) {
|
|
543
|
-
const {
|
|
544
|
-
const
|
|
545
|
-
const
|
|
538
|
+
const { left, top } = btn.getBoundingClientRect();
|
|
539
|
+
const x = e.clientX - left;
|
|
540
|
+
const y = e.clientY - top;
|
|
546
541
|
|
|
547
|
-
clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${
|
|
548
|
-
clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${
|
|
542
|
+
clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${x}px`);
|
|
543
|
+
clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${y}px`);
|
|
549
544
|
}
|
|
550
545
|
});
|
|
551
546
|
|
package/dist/kitzo.umd.js
CHANGED
|
@@ -410,10 +410,12 @@
|
|
|
410
410
|
clip-path: circle(0 at var(--kitzo-clippath-pos-x) var(--kitzo-clippath-pos-y));
|
|
411
411
|
transition: var(--kitzo-clippath-transition);
|
|
412
412
|
}
|
|
413
|
-
|
|
414
413
|
.kitzo-clippath-div.show {
|
|
415
414
|
opacity: 1;
|
|
416
415
|
clip-path: circle(var(--kitzo-clippath-size) at var(--kitzo-clippath-pos-x) var(--kitzo-clippath-pos-y));
|
|
416
|
+
}
|
|
417
|
+
[data-kitzo-clippath] * {
|
|
418
|
+
pointer-events: none !important;
|
|
417
419
|
}`;
|
|
418
420
|
}
|
|
419
421
|
|
|
@@ -451,9 +453,10 @@
|
|
|
451
453
|
|
|
452
454
|
config = Object.assign(
|
|
453
455
|
{
|
|
454
|
-
|
|
456
|
+
textOption: null,
|
|
455
457
|
clippathSize: '20%',
|
|
456
458
|
smooth: true,
|
|
459
|
+
class: '',
|
|
457
460
|
style: {},
|
|
458
461
|
},
|
|
459
462
|
config
|
|
@@ -489,69 +492,61 @@
|
|
|
489
492
|
|
|
490
493
|
document.addEventListener('mouseover', (e) => {
|
|
491
494
|
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
492
|
-
|
|
493
495
|
if (btn) {
|
|
494
496
|
isHovering = true;
|
|
495
|
-
const { text, style, clippathSize, smooth } = clippathConfigMap.get(btn);
|
|
496
|
-
const { width, height, top, left } = btn.getBoundingClientRect();
|
|
497
|
-
|
|
498
497
|
clippathDiv.removeAttribute('style');
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
} else {
|
|
508
|
-
clippathDiv.innerHTML = text;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
clippathDiv.style.setProperty('--kitzo-clippath-transition', smooth ? 'clip-path 150ms ease-out, opacity 150ms' : 'none');
|
|
512
|
-
clippathDiv.style.setProperty('--kitzo-clippath-size', getClippathSize(clippathSize));
|
|
513
|
-
|
|
514
|
-
const { borderRadius, font, letterSpacing, lineHeight, border, boxSizing, padding } = window.getComputedStyle(btn);
|
|
515
|
-
|
|
516
|
-
Object.assign(clippathDiv.style, {
|
|
498
|
+
const { textOption, clippathSize, smooth, style } = clippathConfigMap.get(btn);
|
|
499
|
+
|
|
500
|
+
const { top, left, width, height } = btn.getBoundingClientRect();
|
|
501
|
+
const cloned = btn.cloneNode(true);
|
|
502
|
+
cloned.className = cloned.className + ` ${clippathConfigMap.get(btn).class}`;
|
|
503
|
+
cloned.removeAttribute('data-kitzo-clippath');
|
|
504
|
+
cloned.setAttribute('data-temp-clippath-el', true);
|
|
505
|
+
Object.assign(cloned.style, {
|
|
517
506
|
backgroundColor: '#01c2b8',
|
|
518
507
|
color: 'white',
|
|
519
|
-
borderRadius,
|
|
520
|
-
font,
|
|
521
|
-
letterSpacing,
|
|
522
|
-
lineHeight,
|
|
523
|
-
border,
|
|
524
|
-
boxSizing,
|
|
525
|
-
padding,
|
|
526
508
|
...style,
|
|
527
509
|
});
|
|
528
510
|
|
|
511
|
+
if (textOption && textOption instanceof Object) {
|
|
512
|
+
const target = cloned.querySelector(textOption.selector);
|
|
513
|
+
if (target && (typeof textOption.value === 'string' || typeof textOption.value === 'number')) {
|
|
514
|
+
target.textContent = textOption.value;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
clippathDiv.style.width = `${width}px`;
|
|
519
|
+
clippathDiv.style.height = `${height}px`;
|
|
520
|
+
clippathDiv.style.translate = `${left}px ${top}px`;
|
|
521
|
+
clippathDiv.style.setProperty('--kitzo-clippath-size', getClippathSize(clippathSize));
|
|
522
|
+
clippathDiv.style.setProperty('--kitzo-clippath-transition', smooth ? 'clip-path 150ms ease-out, opacity 150ms' : 'none');
|
|
523
|
+
clippathDiv.appendChild(cloned);
|
|
529
524
|
requestAnimationFrame(() => {
|
|
530
525
|
clippathDiv.classList.add('show');
|
|
531
526
|
});
|
|
532
527
|
}
|
|
533
528
|
});
|
|
534
|
-
|
|
535
529
|
document.addEventListener('mouseout', (e) => {
|
|
536
530
|
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
537
|
-
|
|
538
531
|
if (btn) {
|
|
539
532
|
clippathDiv.classList.remove('show');
|
|
540
|
-
|
|
533
|
+
setTimeout(() => {
|
|
534
|
+
clippathDiv.querySelectorAll('[data-temp-clippath-el]').forEach((el) => el.remove());
|
|
535
|
+
}, 150);
|
|
541
536
|
}
|
|
542
537
|
});
|
|
543
538
|
|
|
544
539
|
document.addEventListener('mousemove', (e) => {
|
|
545
540
|
if (!isHovering) return;
|
|
546
|
-
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
547
541
|
|
|
542
|
+
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
548
543
|
if (btn) {
|
|
549
|
-
const {
|
|
550
|
-
const
|
|
551
|
-
const
|
|
544
|
+
const { left, top } = btn.getBoundingClientRect();
|
|
545
|
+
const x = e.clientX - left;
|
|
546
|
+
const y = e.clientY - top;
|
|
552
547
|
|
|
553
|
-
clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${
|
|
554
|
-
clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${
|
|
548
|
+
clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${x}px`);
|
|
549
|
+
clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${y}px`);
|
|
555
550
|
}
|
|
556
551
|
});
|
|
557
552
|
|