@zumer/orbit 0.2.2 → 0.2.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.
- package/dist/orbit.css +1255 -810
- package/dist/orbit.js +33 -34
- package/dist/orbit.min.css +1 -1
- package/dist/orbit.min.js +10 -10
- package/package.json +1 -1
package/dist/orbit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
3
|
* orbit
|
|
4
|
-
* v.0.2.
|
|
4
|
+
* v.0.2.4
|
|
5
5
|
* Author Juan Martin Muda - Zumerlab
|
|
6
6
|
* License MIT
|
|
7
7
|
**/
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
<style>
|
|
16
16
|
:host {
|
|
17
17
|
display: block;
|
|
18
|
-
|
|
19
18
|
}
|
|
20
19
|
svg {
|
|
21
20
|
width: 100%;
|
|
@@ -223,7 +222,7 @@
|
|
|
223
222
|
}
|
|
224
223
|
};
|
|
225
224
|
|
|
226
|
-
// src/js/orbit-
|
|
225
|
+
// src/js/orbit-slice.js
|
|
227
226
|
var template = document.createElement("template");
|
|
228
227
|
template.innerHTML = `
|
|
229
228
|
<style>
|
|
@@ -239,22 +238,23 @@
|
|
|
239
238
|
svg * {
|
|
240
239
|
pointer-events: stroke;
|
|
241
240
|
}
|
|
242
|
-
.
|
|
243
|
-
stroke: var(--o-
|
|
241
|
+
.slice {
|
|
242
|
+
stroke: var(--o-slice-color, var(--o-cyan-light));
|
|
243
|
+
stroke-width: calc(var(--o-radius) / var(--o-orbit-number) * var(--o-size-ratio, 1));
|
|
244
244
|
transition: stroke 0.3s;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
:host(:hover) .
|
|
248
|
-
stroke: var(--o-hover-
|
|
247
|
+
:host(:hover) .slice {
|
|
248
|
+
stroke: var(--o-hover-slice-color, var(--o-slice-color));
|
|
249
249
|
|
|
250
250
|
}
|
|
251
251
|
</style>
|
|
252
252
|
<svg viewBox="0 0 100 100">
|
|
253
253
|
<defs></defs>
|
|
254
|
-
<path class="
|
|
254
|
+
<path class="slice" vector-effect="non-scaling-stroke" fill="transparent"></path>
|
|
255
255
|
</svg>
|
|
256
256
|
`;
|
|
257
|
-
var
|
|
257
|
+
var OrbitSlice = class extends HTMLElement {
|
|
258
258
|
constructor() {
|
|
259
259
|
super();
|
|
260
260
|
this.attachShadow({ mode: "open" });
|
|
@@ -281,18 +281,17 @@
|
|
|
281
281
|
path.setAttribute("marker-end", "url(#head)");
|
|
282
282
|
path.setAttribute("marker-start", "url(#tail)");
|
|
283
283
|
}
|
|
284
|
-
const {
|
|
284
|
+
const { realRadius, sliceColor, gap } = this.getAttributes();
|
|
285
285
|
const angle = this.calculateAngle();
|
|
286
286
|
const { d } = this.calculateArcParameters(angle, realRadius, gap);
|
|
287
287
|
path.setAttribute("d", d);
|
|
288
|
-
path.setAttribute("stroke",
|
|
289
|
-
path.setAttribute("stroke-width", strokeWidth);
|
|
288
|
+
path.setAttribute("stroke", sliceColor);
|
|
290
289
|
}
|
|
291
290
|
getAttributes() {
|
|
292
291
|
const orbitRadius = parseFloat(getComputedStyle(this).getPropertyValue("r") || 0);
|
|
293
292
|
const gap = parseFloat(getComputedStyle(this).getPropertyValue("--o-gap") || 1e-3);
|
|
294
293
|
const shape = this.getAttribute("shape") || "none";
|
|
295
|
-
const
|
|
294
|
+
const sliceColor = this.getAttribute("slice-color");
|
|
296
295
|
const rawAngle = getComputedStyle(this).getPropertyValue("--o-angle");
|
|
297
296
|
const strokeWidth = parseFloat(getComputedStyle(this).getPropertyValue("stroke-width") || 1);
|
|
298
297
|
const strokeWithPercentage = strokeWidth / 2 * 100 / orbitRadius / 2;
|
|
@@ -310,22 +309,22 @@
|
|
|
310
309
|
innerOuter = strokeWithPercentage * 0.75;
|
|
311
310
|
}
|
|
312
311
|
const realRadius = 50 + innerOuter - strokeWithPercentage;
|
|
313
|
-
const
|
|
312
|
+
const sliceAngle = calcularExpresionCSS(rawAngle);
|
|
314
313
|
return {
|
|
315
314
|
orbitRadius,
|
|
316
315
|
strokeWidth,
|
|
317
316
|
realRadius,
|
|
318
|
-
|
|
317
|
+
sliceColor,
|
|
319
318
|
gap,
|
|
320
|
-
|
|
319
|
+
sliceAngle,
|
|
321
320
|
shape
|
|
322
321
|
};
|
|
323
322
|
}
|
|
324
323
|
calculateAngle() {
|
|
325
|
-
const {
|
|
326
|
-
return
|
|
324
|
+
const { sliceAngle, gap } = this.getAttributes();
|
|
325
|
+
return sliceAngle - gap;
|
|
327
326
|
}
|
|
328
|
-
calculateArcParameters(angle, realRadius
|
|
327
|
+
calculateArcParameters(angle, realRadius) {
|
|
329
328
|
const radiusX = realRadius / 1;
|
|
330
329
|
const radiusY = realRadius / 1;
|
|
331
330
|
const startX = 50 + radiusX * Math.cos(-Math.PI / 2);
|
|
@@ -387,8 +386,8 @@
|
|
|
387
386
|
}
|
|
388
387
|
}
|
|
389
388
|
|
|
390
|
-
// src/js/orbit-
|
|
391
|
-
var
|
|
389
|
+
// src/js/orbit-text.js
|
|
390
|
+
var OrbitText = class extends HTMLElement {
|
|
392
391
|
constructor() {
|
|
393
392
|
super();
|
|
394
393
|
this.attachShadow({ mode: "open" });
|
|
@@ -418,12 +417,12 @@
|
|
|
418
417
|
|
|
419
418
|
path {
|
|
420
419
|
fill: transparent;
|
|
421
|
-
stroke: var(--o-
|
|
420
|
+
stroke: var(--o-text-color);
|
|
422
421
|
transition: stroke 0.3s;
|
|
423
422
|
}
|
|
424
423
|
|
|
425
424
|
:host(:hover) path {
|
|
426
|
-
stroke: var(--o-hover-
|
|
425
|
+
stroke: var(--o-hover-text-color, var(--o-text-color));
|
|
427
426
|
|
|
428
427
|
}
|
|
429
428
|
|
|
@@ -467,10 +466,10 @@
|
|
|
467
466
|
textPath.textContent = this.textContent.trim();
|
|
468
467
|
}
|
|
469
468
|
getPathAttributes() {
|
|
470
|
-
const { realRadius, gap,
|
|
469
|
+
const { realRadius, gap, textBgColor, flip, lineCap, strokeWidth } = this.getAttributes();
|
|
471
470
|
const angle = this.calculateAngle();
|
|
472
471
|
const { d } = this.calculateArcParameters(angle, realRadius, gap, flip);
|
|
473
|
-
return { d, strokeWidth,
|
|
472
|
+
return { d, strokeWidth, textBgColor, lineCap };
|
|
474
473
|
}
|
|
475
474
|
getTextAttributes() {
|
|
476
475
|
const { length, fontSize, textAnchor, fitRange } = this.getAttributes();
|
|
@@ -482,7 +481,7 @@
|
|
|
482
481
|
const fitRange = this.hasAttribute("fit-range");
|
|
483
482
|
const lineCap = getComputedStyle(this).getPropertyValue("--o-linecap") || "butt";
|
|
484
483
|
const gap = parseFloat(getComputedStyle(this).getPropertyValue("--o-gap") || 1e-3);
|
|
485
|
-
const length = parseFloat(getComputedStyle(this).getPropertyValue("--o-
|
|
484
|
+
const length = parseFloat(getComputedStyle(this).getPropertyValue("--o-force"));
|
|
486
485
|
const textAnchor = this.getAttribute("text-anchor") || "start";
|
|
487
486
|
const fontSize = getComputedStyle(this).getPropertyValue("font-size") || getComputedStyle(this).getPropertyValue("--font-size");
|
|
488
487
|
const rawAngle = getComputedStyle(this).getPropertyValue("--o-angle");
|
|
@@ -502,7 +501,7 @@
|
|
|
502
501
|
innerOuter = strokeWithPercentage * 0.75;
|
|
503
502
|
}
|
|
504
503
|
const realRadius = 50 + innerOuter - strokeWithPercentage;
|
|
505
|
-
const
|
|
504
|
+
const textAngle = calcularExpresionCSS2(rawAngle);
|
|
506
505
|
return {
|
|
507
506
|
orbitRadius,
|
|
508
507
|
strokeWidth,
|
|
@@ -510,7 +509,7 @@
|
|
|
510
509
|
length,
|
|
511
510
|
fontSize,
|
|
512
511
|
gap,
|
|
513
|
-
|
|
512
|
+
textAngle,
|
|
514
513
|
flip,
|
|
515
514
|
textAnchor,
|
|
516
515
|
lineCap,
|
|
@@ -518,8 +517,8 @@
|
|
|
518
517
|
};
|
|
519
518
|
}
|
|
520
519
|
calculateAngle() {
|
|
521
|
-
const {
|
|
522
|
-
return
|
|
520
|
+
const { textAngle, gap } = this.getAttributes();
|
|
521
|
+
return textAngle - gap;
|
|
523
522
|
}
|
|
524
523
|
calculateArcParameters(angle, realRadius, gap, flip) {
|
|
525
524
|
const radiusX = realRadius / 1;
|
|
@@ -566,9 +565,9 @@
|
|
|
566
565
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
567
566
|
for (let entry of entries) {
|
|
568
567
|
const { width } = entry.contentRect;
|
|
569
|
-
const childElement = parentElement.querySelector(".
|
|
568
|
+
const childElement = parentElement.querySelector(".gravity-spot");
|
|
570
569
|
if (childElement) {
|
|
571
|
-
childElement.style.setProperty("--o-
|
|
570
|
+
childElement.style.setProperty("--o-force", `${width}px`);
|
|
572
571
|
} else {
|
|
573
572
|
console.error("No se encontr\xF3 ning\xFAn elemento hijo con la clase .child-element");
|
|
574
573
|
}
|
|
@@ -580,7 +579,7 @@
|
|
|
580
579
|
|
|
581
580
|
// src/orbit.js
|
|
582
581
|
customElements.define("o-progress", OrbitProgress);
|
|
583
|
-
customElements.define("o-
|
|
584
|
-
customElements.define("o-
|
|
582
|
+
customElements.define("o-slice", OrbitSlice);
|
|
583
|
+
customElements.define("o-text", OrbitText);
|
|
585
584
|
window.Orbit = Orbit;
|
|
586
585
|
})();
|