@zumer/orbit 1.4.8 → 1.4.11
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 +125 -111
- package/dist/orbit.css +3 -3
- package/dist/orbit.js +96 -109
- package/dist/orbit.min.css +1 -1
- package/dist/orbit.min.js +4 -4
- package/package.json +2 -2
package/dist/orbit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* orbit
|
|
3
|
-
* v.1.4.
|
|
3
|
+
* v.1.4.11
|
|
4
4
|
* Author Juan Martin Muda - Zumerlab
|
|
5
5
|
* License MIT
|
|
6
6
|
*/
|
|
@@ -9,17 +9,6 @@
|
|
|
9
9
|
var OrbitBase = class extends HTMLElement {
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
12
|
-
this.commonProperties = {
|
|
13
|
-
orbitRadius: 0,
|
|
14
|
-
arcHeight: 0,
|
|
15
|
-
realRadius: 0,
|
|
16
|
-
arcAngle: 0,
|
|
17
|
-
shape: "none",
|
|
18
|
-
arcHeightPercentage: 0,
|
|
19
|
-
orbitNumber: 1,
|
|
20
|
-
size: 1,
|
|
21
|
-
strokeWidth: 1
|
|
22
|
-
};
|
|
23
12
|
}
|
|
24
13
|
getCommonAttributes(element) {
|
|
25
14
|
const orbitRadius = parseFloat(getComputedStyle(element).getPropertyValue("r") || 0);
|
|
@@ -28,7 +17,7 @@
|
|
|
28
17
|
const strokeWidth = parseFloat(getComputedStyle(element).getPropertyValue("--o-stroke-width") || 1);
|
|
29
18
|
const shape = element.getAttribute("shape") || "none";
|
|
30
19
|
const arcHeight = orbitRadius / orbitNumber * size - strokeWidth + 0.3;
|
|
31
|
-
const arcHeightPercentage = arcHeight / 2 * 100 / orbitRadius / 2;
|
|
20
|
+
const arcHeightPercentage = orbitRadius > 0 ? arcHeight / 2 * 100 / orbitRadius / 2 : 0;
|
|
32
21
|
let innerOuter = 0;
|
|
33
22
|
if (element.classList.contains("outer-orbit")) {
|
|
34
23
|
innerOuter = arcHeightPercentage;
|
|
@@ -95,13 +84,19 @@
|
|
|
95
84
|
const upperArcEnd = this.arcPoint(bigRadius, upperAngleEnd);
|
|
96
85
|
const innerArcStart = this.arcPoint(smallRadius, innerAngleStart);
|
|
97
86
|
const innerArcEnd = this.arcPoint(smallRadius, innerAngleEnd);
|
|
98
|
-
const
|
|
87
|
+
const upperSweep = upperAngleEnd - upperAngleStart;
|
|
88
|
+
const innerSweep = innerAngleEnd - innerAngleStart;
|
|
89
|
+
const largeArcFlagUpper = upperSweep > Math.PI ? 1 : 0;
|
|
90
|
+
const largeArcFlagInner = innerSweep > Math.PI ? 1 : 0;
|
|
99
91
|
return {
|
|
100
92
|
upperArcStart,
|
|
101
93
|
upperArcEnd,
|
|
102
94
|
innerArcStart,
|
|
103
95
|
innerArcEnd,
|
|
104
|
-
largeArcFlag,
|
|
96
|
+
largeArcFlag: largeArcFlagUpper,
|
|
97
|
+
// back-compat alias; prefer the two below
|
|
98
|
+
largeArcFlagUpper,
|
|
99
|
+
largeArcFlagInner,
|
|
105
100
|
bigRadius,
|
|
106
101
|
smallRadius,
|
|
107
102
|
radius,
|
|
@@ -141,8 +136,11 @@
|
|
|
141
136
|
return d;
|
|
142
137
|
}
|
|
143
138
|
generateRoundedPath(params, arcHeight, orbitNumber) {
|
|
144
|
-
const {
|
|
139
|
+
const { bigRadius, smallRadius } = params;
|
|
145
140
|
const curve = arcHeight < 10 ? 5 : arcHeight < 5 ? 2.5 : 10;
|
|
141
|
+
const capRad = curve / orbitNumber * Math.PI / 180;
|
|
142
|
+
const flagU = params.upperAngleEnd - params.upperAngleStart - 2 * capRad > Math.PI ? 1 : 0;
|
|
143
|
+
const flagI = params.innerAngleEnd - params.innerAngleStart - 2 * capRad > Math.PI ? 1 : 0;
|
|
146
144
|
const newUpperStart = this.arcPoint(bigRadius, params.upperAngleStart, 0, curve / orbitNumber);
|
|
147
145
|
const newUpperEnd = this.arcPoint(bigRadius, params.upperAngleEnd, 0, -curve / orbitNumber);
|
|
148
146
|
const newInnerStart = this.arcPoint(smallRadius, params.innerAngleStart, 0, curve / orbitNumber);
|
|
@@ -155,81 +153,81 @@
|
|
|
155
153
|
const Q1 = this.getControlPoint(innerPointEnd.x, innerPointEnd.y, newInnerEnd.x, newInnerEnd.y);
|
|
156
154
|
const Q2 = this.getControlPoint(newInnerStart.x, newInnerStart.y, innerPointStart.x, innerPointStart.y);
|
|
157
155
|
const Q3 = this.getControlPoint(upperPointStart.x, upperPointStart.y, newUpperStart.x, newUpperStart.y);
|
|
158
|
-
let d = `M ${newUpperStart.x},${newUpperStart.y} A ${bigRadius},${bigRadius} 0 ${
|
|
159
|
-
d += `Q ${Q.xc}
|
|
160
|
-
d += `
|
|
161
|
-
d += `
|
|
162
|
-
d += `Q ${
|
|
163
|
-
d += `
|
|
164
|
-
d += `Q ${Q2.xc}, ${Q2.yc} ${innerPointStart.x} ${innerPointStart.y} `;
|
|
165
|
-
d += `L ${innerPointStart.x} ${innerPointStart.y}`;
|
|
166
|
-
d += `L ${upperPointStart.x} ${upperPointStart.y}`;
|
|
167
|
-
d += ` Q ${Q3.xc}, ${Q3.yc} ${newUpperStart.x} ${newUpperStart.y} `;
|
|
156
|
+
let d = `M ${newUpperStart.x},${newUpperStart.y} A ${bigRadius},${bigRadius} 0 ${flagU} 1 ${newUpperEnd.x},${newUpperEnd.y}`;
|
|
157
|
+
d += `Q ${Q.xc},${Q.yc} ${upperPointEnd.x},${upperPointEnd.y} L ${innerPointEnd.x},${innerPointEnd.y}`;
|
|
158
|
+
d += `Q ${Q1.xc},${Q1.yc} ${newInnerEnd.x},${newInnerEnd.y}`;
|
|
159
|
+
d += `A ${smallRadius},${smallRadius} 0 ${flagI} 0 ${newInnerStart.x},${newInnerStart.y}`;
|
|
160
|
+
d += `Q ${Q2.xc},${Q2.yc} ${innerPointStart.x},${innerPointStart.y} L ${upperPointStart.x},${upperPointStart.y}`;
|
|
161
|
+
d += ` Q ${Q3.xc},${Q3.yc} ${newUpperStart.x},${newUpperStart.y}`;
|
|
168
162
|
d += ` Z`;
|
|
169
163
|
return d;
|
|
170
164
|
}
|
|
171
165
|
// Dentro de la clase OrbitCommon en orbit-common.js
|
|
172
166
|
generateCirclePath(params, shape) {
|
|
173
|
-
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius,
|
|
174
|
-
let d = `M ${upperArcStart.x},${upperArcStart.y} A ${bigRadius},${bigRadius} 0 ${
|
|
167
|
+
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius, largeArcFlagUpper, largeArcFlagInner } = params;
|
|
168
|
+
let d = `M ${upperArcStart.x},${upperArcStart.y} A ${bigRadius},${bigRadius} 0 ${largeArcFlagUpper} 1 ${upperArcEnd.x},${upperArcEnd.y}`;
|
|
175
169
|
d += ` A 1,1 0 0 1 ${innerArcEnd.x},${innerArcEnd.y} `;
|
|
176
|
-
d += ` A ${smallRadius},${smallRadius} 0 ${
|
|
170
|
+
d += ` A ${smallRadius},${smallRadius} 0 ${largeArcFlagInner} 0 ${innerArcStart.x},${innerArcStart.y}`;
|
|
177
171
|
d += ` A 1,1 0 0 ${shape === "circle" || shape === "circle-a" ? 1 : 0} ${upperArcStart.x},${upperArcStart.y} `;
|
|
178
172
|
d += ` Z`;
|
|
179
173
|
return d;
|
|
180
174
|
}
|
|
181
175
|
generateCircleBPath(params, arcHeight, orbitNumber) {
|
|
182
|
-
const { upperAngleStart, upperAngleEnd, innerAngleStart, innerAngleEnd, bigRadius, smallRadius
|
|
176
|
+
const { upperAngleStart, upperAngleEnd, innerAngleStart, innerAngleEnd, bigRadius, smallRadius } = params;
|
|
183
177
|
const segment = arcHeight * 1.36;
|
|
178
|
+
const capRad = segment / orbitNumber * Math.PI / 180;
|
|
179
|
+
const flagU = upperAngleEnd - upperAngleStart - 2 * capRad > Math.PI ? 1 : 0;
|
|
180
|
+
const flagI = innerAngleEnd - innerAngleStart - 2 * capRad > Math.PI ? 1 : 0;
|
|
184
181
|
const newUpperStart = this.arcPoint(bigRadius, upperAngleStart, 0, segment / orbitNumber);
|
|
185
182
|
const newUpperEnd = this.arcPoint(bigRadius, upperAngleEnd, 0, -segment / orbitNumber);
|
|
186
183
|
const newInnerStart = this.arcPoint(smallRadius, innerAngleStart, 0, segment / orbitNumber);
|
|
187
184
|
const newInnerEnd = this.arcPoint(smallRadius, innerAngleEnd, 0, -segment / orbitNumber);
|
|
188
|
-
let d = `M ${newUpperStart.x},${newUpperStart.y} A ${bigRadius},${bigRadius} 0 ${
|
|
185
|
+
let d = `M ${newUpperStart.x},${newUpperStart.y} A ${bigRadius},${bigRadius} 0 ${flagU} 1 ${newUpperEnd.x},${newUpperEnd.y}`;
|
|
189
186
|
d += ` A 1,1 0 0 1 ${newInnerEnd.x},${newInnerEnd.y} `;
|
|
190
|
-
d += ` A ${smallRadius},${smallRadius} 0 ${
|
|
187
|
+
d += ` A ${smallRadius},${smallRadius} 0 ${flagI} 0 ${newInnerStart.x},${newInnerStart.y}`;
|
|
191
188
|
d += ` A 1,1 0 0 1 ${newUpperStart.x},${newUpperStart.y} `;
|
|
192
189
|
d += ` Z`;
|
|
193
190
|
return d;
|
|
194
191
|
}
|
|
195
192
|
generateArrowPath(params, orbitNumber) {
|
|
196
|
-
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius,
|
|
193
|
+
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius, largeArcFlagUpper, largeArcFlagInner, radius } = params;
|
|
197
194
|
const middleEnd = this.arcPoint(radius, params.upperAngleEnd, 0, 24 / orbitNumber / 2);
|
|
198
195
|
const middleStart = this.arcPoint(radius, params.upperAngleStart, 0, 24 / orbitNumber / 2);
|
|
199
|
-
let d = `M ${upperArcStart.x},${upperArcStart.y} A ${bigRadius},${bigRadius} 0 ${
|
|
196
|
+
let d = `M ${upperArcStart.x},${upperArcStart.y} A ${bigRadius},${bigRadius} 0 ${largeArcFlagUpper} 1 ${upperArcEnd.x},${upperArcEnd.y}`;
|
|
200
197
|
d += `L ${middleEnd.x} ${middleEnd.y}`;
|
|
201
198
|
d += `L ${innerArcEnd.x} ${innerArcEnd.y}`;
|
|
202
|
-
d += `A ${smallRadius},${smallRadius} 0 ${
|
|
199
|
+
d += `A ${smallRadius},${smallRadius} 0 ${largeArcFlagInner} 0 ${innerArcStart.x}, ${innerArcStart.y}`;
|
|
203
200
|
d += `L ${middleStart.x} ${middleStart.y}`;
|
|
204
201
|
d += `Z`;
|
|
205
202
|
return d;
|
|
206
203
|
}
|
|
207
204
|
generateSlashPath(params, shape, orbitNumber) {
|
|
208
|
-
const { upperAngleStart, upperAngleEnd, innerAngleStart, innerAngleEnd, bigRadius, smallRadius,
|
|
205
|
+
const { upperAngleStart, upperAngleEnd, innerAngleStart, innerAngleEnd, bigRadius, smallRadius, largeArcFlagUpper, largeArcFlagInner } = params;
|
|
209
206
|
const newUpperStart = this.arcPoint(bigRadius, upperAngleStart, 0, shape === "backslash" ? 0 : 24 / orbitNumber / 2);
|
|
210
207
|
const newUpperEnd = this.arcPoint(bigRadius, upperAngleEnd, 0, shape === "backslash" ? 0 : 24 / orbitNumber / 2);
|
|
211
208
|
const newInnerStart = this.arcPoint(smallRadius, innerAngleStart, 0, shape === "backslash" ? 24 / orbitNumber / 2 : 0);
|
|
212
209
|
const newInnerEnd = this.arcPoint(smallRadius, innerAngleEnd, 0, shape === "backslash" ? 24 / orbitNumber / 2 : 0);
|
|
213
|
-
let d = `M ${newUpperStart.x},${newUpperStart.y} A ${bigRadius},${bigRadius} 0 ${
|
|
210
|
+
let d = `M ${newUpperStart.x},${newUpperStart.y} A ${bigRadius},${bigRadius} 0 ${largeArcFlagUpper} 1 ${newUpperEnd.x},${newUpperEnd.y}`;
|
|
214
211
|
d += `L ${newInnerEnd.x} ${newInnerEnd.y}`;
|
|
215
|
-
d += `A ${smallRadius},${smallRadius} 0 ${
|
|
212
|
+
d += `A ${smallRadius},${smallRadius} 0 ${largeArcFlagInner} 0 ${newInnerStart.x}, ${newInnerStart.y}`;
|
|
216
213
|
d += `Z`;
|
|
217
214
|
return d;
|
|
218
215
|
}
|
|
219
216
|
generateZigzagPath(params, arcHeight, orbitNumber) {
|
|
220
|
-
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius,
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
|
|
217
|
+
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius, largeArcFlagUpper, largeArcFlagInner, radius } = params;
|
|
218
|
+
const h2 = arcHeight / orbitNumber / 2;
|
|
219
|
+
const s2 = this.arcPoint(radius, params.upperAngleStart, -h2, 3);
|
|
220
|
+
const s3 = this.arcPoint(radius, params.upperAngleStart, 0, 0);
|
|
221
|
+
const s4 = this.arcPoint(radius, params.upperAngleStart, h2, 3);
|
|
222
|
+
const e2 = this.arcPoint(radius, params.innerAngleEnd, h2, 3);
|
|
223
|
+
const e3 = this.arcPoint(radius, params.innerAngleEnd, 0, 0);
|
|
224
|
+
const e4 = this.arcPoint(radius, params.innerAngleEnd, -h2, 3);
|
|
225
|
+
let d = `M ${upperArcStart.x},${upperArcStart.y} A ${bigRadius},${bigRadius} 0 ${largeArcFlagUpper} 1 ${upperArcEnd.x},${upperArcEnd.y}`;
|
|
228
226
|
d += `L ${e2.x} ${e2.y}`;
|
|
229
227
|
d += `L ${e3.x} ${e3.y}`;
|
|
230
228
|
d += `L ${e4.x} ${e4.y}`;
|
|
231
229
|
d += `L ${innerArcEnd.x} ${innerArcEnd.y}`;
|
|
232
|
-
d += `A ${smallRadius},${smallRadius} 0 ${
|
|
230
|
+
d += `A ${smallRadius},${smallRadius} 0 ${largeArcFlagInner} 0 ${innerArcStart.x}, ${innerArcStart.y}`;
|
|
233
231
|
d += `L ${s2.x} ${s2.y}`;
|
|
234
232
|
d += `L ${s3.x} ${s3.y}`;
|
|
235
233
|
d += `L ${s4.x} ${s4.y}`;
|
|
@@ -237,10 +235,10 @@
|
|
|
237
235
|
return d;
|
|
238
236
|
}
|
|
239
237
|
generateDefaultPath(params) {
|
|
240
|
-
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius,
|
|
241
|
-
let d = `M ${upperArcStart.x},${upperArcStart.y} A ${bigRadius},${bigRadius} 0 ${
|
|
238
|
+
const { upperArcStart, upperArcEnd, innerArcStart, innerArcEnd, bigRadius, smallRadius, largeArcFlagUpper, largeArcFlagInner } = params;
|
|
239
|
+
let d = `M ${upperArcStart.x},${upperArcStart.y} A ${bigRadius},${bigRadius} 0 ${largeArcFlagUpper} 1 ${upperArcEnd.x},${upperArcEnd.y}`;
|
|
242
240
|
d += `L ${innerArcEnd.x} ${innerArcEnd.y}`;
|
|
243
|
-
d += `A ${smallRadius},${smallRadius} 0 ${
|
|
241
|
+
d += `A ${smallRadius},${smallRadius} 0 ${largeArcFlagInner} 0 ${innerArcStart.x}, ${innerArcStart.y}`;
|
|
244
242
|
d += `Z`;
|
|
245
243
|
return d;
|
|
246
244
|
}
|
|
@@ -310,14 +308,11 @@
|
|
|
310
308
|
this.observer.observe(this, { attributes: true, childList: true });
|
|
311
309
|
}
|
|
312
310
|
update() {
|
|
313
|
-
const
|
|
314
|
-
const
|
|
315
|
-
this.
|
|
316
|
-
this.
|
|
317
|
-
|
|
318
|
-
updateArc(arc, full) {
|
|
319
|
-
const { d } = this.calculateArcParameters(full);
|
|
320
|
-
arc.setAttribute("d", d);
|
|
311
|
+
const attrs = this.getAttributes();
|
|
312
|
+
const dBg = this.calculateArcParameters(attrs, true);
|
|
313
|
+
const dBar = this.calculateArcParameters(attrs, false);
|
|
314
|
+
this.shadowRoot.querySelector(".progress-bg").setAttribute("d", dBg);
|
|
315
|
+
this.shadowRoot.querySelector(".progress-bar").setAttribute("d", dBar);
|
|
321
316
|
}
|
|
322
317
|
getAttributes() {
|
|
323
318
|
const common = super.getCommonAttributes(this);
|
|
@@ -331,13 +326,13 @@
|
|
|
331
326
|
maxValue
|
|
332
327
|
};
|
|
333
328
|
}
|
|
334
|
-
getProgressAngle(full) {
|
|
335
|
-
const { range, progress, maxValue } =
|
|
329
|
+
getProgressAngle(attrs, full) {
|
|
330
|
+
const { range, progress, maxValue } = attrs;
|
|
336
331
|
return full ? (maxValue - 1e-5) / maxValue * range : progress / maxValue * range;
|
|
337
332
|
}
|
|
338
|
-
calculateArcParameters(full) {
|
|
339
|
-
const { shape, realRadius, arcHeightPercentage, orbitNumber, strokeWidth, arcHeight } =
|
|
340
|
-
const arcAngle = this.getProgressAngle(full);
|
|
333
|
+
calculateArcParameters(attrs, full) {
|
|
334
|
+
const { shape, realRadius, arcHeightPercentage, orbitNumber, strokeWidth, arcHeight } = attrs;
|
|
335
|
+
const arcAngle = this.getProgressAngle(attrs, full);
|
|
341
336
|
const params = super.calculateCommonArcParameters(
|
|
342
337
|
arcAngle,
|
|
343
338
|
realRadius,
|
|
@@ -347,8 +342,7 @@
|
|
|
347
342
|
strokeWidth,
|
|
348
343
|
arcHeight
|
|
349
344
|
);
|
|
350
|
-
|
|
351
|
-
return { d };
|
|
345
|
+
return super.generatePathData(shape, params, arcHeight, orbitNumber);
|
|
352
346
|
}
|
|
353
347
|
};
|
|
354
348
|
|
|
@@ -411,9 +405,8 @@
|
|
|
411
405
|
this.setupObservers();
|
|
412
406
|
}
|
|
413
407
|
disconnectedCallback() {
|
|
414
|
-
|
|
415
|
-
(
|
|
416
|
-
(_b = this.textObserver) == null ? void 0 : _b.disconnect();
|
|
408
|
+
if (this.observer) this.observer.disconnect();
|
|
409
|
+
if (this.textObserver) this.textObserver.disconnect();
|
|
417
410
|
}
|
|
418
411
|
setupObservers() {
|
|
419
412
|
this.observer = new MutationObserver((mutations) => {
|
|
@@ -429,15 +422,13 @@
|
|
|
429
422
|
this.textObserver.observe(this, { characterData: true, subtree: true });
|
|
430
423
|
}
|
|
431
424
|
update() {
|
|
432
|
-
const
|
|
433
|
-
const
|
|
434
|
-
const
|
|
435
|
-
const
|
|
425
|
+
const attrs = this.getAttributes();
|
|
426
|
+
const { length, fontSize, textAnchor, fitRange } = attrs;
|
|
427
|
+
const orbitPath = this.shadowRoot.querySelector("#orbitPath");
|
|
428
|
+
const orbitShape = this.shadowRoot.querySelector("#orbitShape");
|
|
436
429
|
const textPath = this.shadowRoot.querySelector("textPath");
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
orbitShape.setAttribute("d", dShape);
|
|
440
|
-
orbitPath.setAttribute("d", dPath);
|
|
430
|
+
orbitShape.setAttribute("d", this.calculateArcParameters(attrs).dShape);
|
|
431
|
+
orbitPath.setAttribute("d", this.calculateTextArcParameters(attrs).dPath);
|
|
441
432
|
if (textAnchor === "start") {
|
|
442
433
|
textPath.setAttribute("startOffset", "0%");
|
|
443
434
|
textPath.setAttribute("text-anchor", "start");
|
|
@@ -451,7 +442,7 @@
|
|
|
451
442
|
if (fitRange) {
|
|
452
443
|
textPath.parentElement.setAttribute("textLength", orbitPath.getTotalLength());
|
|
453
444
|
}
|
|
454
|
-
|
|
445
|
+
textPath.parentElement.style.fontSize = `calc(${fontSize} * (100 / (${length}) * (12 / var(--o-orbit-number)))`;
|
|
455
446
|
textPath.textContent = this.textContent;
|
|
456
447
|
}
|
|
457
448
|
getAttributes() {
|
|
@@ -459,12 +450,12 @@
|
|
|
459
450
|
let arcAngle;
|
|
460
451
|
const flip = this.hasAttribute("flip") || this.classList.contains("flip");
|
|
461
452
|
const fitRange = this.hasAttribute("fit-range") || this.classList.contains("fit-range") || false;
|
|
462
|
-
const length = parseFloat(getComputedStyle(this).getPropertyValue("--o-force"));
|
|
453
|
+
const length = parseFloat(getComputedStyle(this).getPropertyValue("--o-force")) || 100;
|
|
463
454
|
const textAnchor = this.getAttribute("text-anchor") || "middle";
|
|
464
455
|
const fontSize = getComputedStyle(this).getPropertyValue("font-size") || getComputedStyle(this).getPropertyValue("--font-size");
|
|
465
456
|
const range = parseFloat(getComputedStyle(this).getPropertyValue("--o-range") || 360);
|
|
466
457
|
const value = parseFloat(this.getAttribute("value"));
|
|
467
|
-
const gap = parseFloat(getComputedStyle(this).getPropertyValue("--o-gap"));
|
|
458
|
+
const gap = parseFloat(getComputedStyle(this).getPropertyValue("--o-gap")) || 1;
|
|
468
459
|
if (value) {
|
|
469
460
|
arcAngle = super.getProgressAngle(range, value);
|
|
470
461
|
const prevElement = this.previousElementSibling;
|
|
@@ -491,8 +482,8 @@
|
|
|
491
482
|
textAnchor
|
|
492
483
|
};
|
|
493
484
|
}
|
|
494
|
-
calculateArcParameters() {
|
|
495
|
-
const { arcAngle, realRadius, arcHeightPercentage, orbitNumber, shape, strokeWidth, arcHeight, gap } =
|
|
485
|
+
calculateArcParameters(attrs) {
|
|
486
|
+
const { arcAngle, realRadius, arcHeightPercentage, orbitNumber, shape, strokeWidth, arcHeight, gap } = attrs;
|
|
496
487
|
const params = super.calculateCommonArcParameters(
|
|
497
488
|
arcAngle,
|
|
498
489
|
realRadius,
|
|
@@ -506,8 +497,8 @@
|
|
|
506
497
|
const dShape = super.generatePathData(shape, params, arcHeight, orbitNumber);
|
|
507
498
|
return { dShape };
|
|
508
499
|
}
|
|
509
|
-
calculateTextArcParameters() {
|
|
510
|
-
const { arcAngle, realRadius, gap, flip } =
|
|
500
|
+
calculateTextArcParameters(attrs) {
|
|
501
|
+
const { arcAngle, realRadius, gap, flip } = attrs;
|
|
511
502
|
const adjustedGap = gap * 0.5;
|
|
512
503
|
const sweepFlag = flip ? 0 : 1;
|
|
513
504
|
const largeArcFlag = arcAngle <= 180 ? 0 : 1;
|
|
@@ -533,39 +524,35 @@
|
|
|
533
524
|
};
|
|
534
525
|
|
|
535
526
|
// src/js/orbit-resize.js
|
|
536
|
-
var Orbit = {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
console.error(`Not found: ${parentElementSelector}`);
|
|
527
|
+
var Orbit = {
|
|
528
|
+
resize(parentElementSelector) {
|
|
529
|
+
const parent = document.querySelector(parentElementSelector);
|
|
530
|
+
if (!parent) {
|
|
531
|
+
console.error("Orbit.resize: element not found:", parentElementSelector);
|
|
542
532
|
return;
|
|
543
533
|
}
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
534
|
+
const applyRatio = (width) => {
|
|
535
|
+
parent.querySelectorAll(".gravity-spot").forEach((el) => {
|
|
536
|
+
el.style.setProperty("--o-force-ratio", String(width / 500));
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
let w = parent.offsetWidth || parent.getBoundingClientRect().width;
|
|
540
|
+
if (w > 0) applyRatio(w);
|
|
541
|
+
else requestAnimationFrame(() => {
|
|
542
|
+
w = parent.offsetWidth || parent.getBoundingClientRect().width;
|
|
543
|
+
if (w > 0) applyRatio(w);
|
|
544
|
+
});
|
|
545
|
+
const ro = new ResizeObserver((entries) => {
|
|
546
|
+
for (const e of entries) {
|
|
547
|
+
if (e.contentRect.width > 0) applyRatio(e.contentRect.width);
|
|
557
548
|
}
|
|
558
549
|
});
|
|
559
|
-
|
|
550
|
+
ro.observe(parent);
|
|
560
551
|
}
|
|
561
552
|
};
|
|
562
553
|
|
|
563
554
|
// src/orbit.js
|
|
564
|
-
if (!customElements.get("o-progress"))
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
if (!customElements.get("o-arc")) {
|
|
568
|
-
customElements.define("o-arc", OrbitArc);
|
|
569
|
-
}
|
|
555
|
+
if (!customElements.get("o-progress")) customElements.define("o-progress", OrbitProgress);
|
|
556
|
+
if (!customElements.get("o-arc")) customElements.define("o-arc", OrbitArc);
|
|
570
557
|
window.Orbit = Orbit;
|
|
571
558
|
})();
|