@rogieking/figui3 6.4.3 → 6.4.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/components.css +3 -1
- package/dist/base.css +1 -1
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +3 -3
- package/dist/fig.css +1 -1
- package/fig-editor.css +5 -0
- package/fig-lab.css +30 -0
- package/fig-lab.js +89 -51
- package/package.json +1 -1
package/fig-editor.css
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
:root,
|
|
2
|
+
:host {
|
|
3
|
+
--icon-24-eyedropper: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15.1592 5.65801C16.0376 4.78045 17.4621 4.78055 18.3408 5.65899L18.4951 5.82989C19.1671 6.65442 19.168 7.84476 18.4951 8.66973L18.3408 8.84063L16.6455 10.533C17.1104 11.083 17.1181 11.889 16.6641 12.4461L16.5605 12.5604C16.0111 13.1097 15.1425 13.1428 14.5537 12.6629L14.5342 12.6453L10.0908 17.0916C9.6188 17.5633 8.98876 17.7764 8.375 17.742L7.56055 18.5574C6.97441 19.1432 6.02451 19.1422 5.43945 18.5584V18.5574C4.8538 17.9718 4.85405 17.0221 5.43945 16.4363L6.25586 15.618C6.22412 15.0058 6.44026 14.3794 6.90918 13.91L11.3516 9.46367C10.856 8.87434 10.885 7.99381 11.4395 7.43926L11.5537 7.33574C12.1094 6.88283 12.9136 6.88854 13.4639 7.35137L15.1592 5.65801ZM7.61621 14.617C7.33755 14.8961 7.21782 15.2747 7.25781 15.6385C7.27925 15.8351 7.24419 16.0445 7.10449 16.1844L6.14648 17.1434C5.9516 17.3387 5.95135 17.6553 6.14648 17.8504C6.34167 18.0449 6.65842 18.0451 6.85352 17.8504L7.80859 16.8943C7.94931 16.7536 8.16065 16.7184 8.3584 16.741C8.72329 16.7828 9.10374 16.6643 9.38379 16.3846L13.8223 11.9432L12.0547 10.1756L7.61621 14.617ZM17.6338 6.36602C17.1458 5.87828 16.3544 5.8783 15.8662 6.36602L14.084 8.14629L14.0186 8.20586C13.6767 8.48476 13.1722 8.46484 12.8535 8.14629C12.6583 7.95131 12.3417 7.95119 12.1465 8.14629C11.9514 8.34148 11.9515 8.65808 12.1465 8.85332L15.1465 11.8533C15.3175 12.024 15.5814 12.0451 15.7754 11.9168L15.8535 11.8533C16.0486 11.6582 16.0484 11.3416 15.8535 11.1463V11.1453C15.8524 11.1443 15.8507 11.1434 15.8496 11.1424C15.5128 10.8013 15.514 10.2513 15.8535 9.91192L17.6338 8.1336C18.1216 7.6457 18.1213 6.85425 17.6338 6.36602Z' fill='black' fill-opacity='0.9'/%3E%3C/svg%3E");
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
/* Fill Picker */
|
|
2
7
|
fig-fill-picker {
|
|
3
8
|
display: contents;
|
package/fig-lab.css
CHANGED
|
@@ -185,6 +185,17 @@ fig-field-slider {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
/* Canvas Control */
|
|
188
|
+
body {
|
|
189
|
+
--fig-lab-cursor: url('data:image/svg+xml,<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23clip0_20065_231516)"><g filter="url(%23filter0_d_20065_231516)"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.93938 2.93938C3.35531 2.52345 3.97597 2.38901 4.52673 2.59555L15.5267 6.72055C16.1416 6.95111 16.535 7.55477 16.4976 8.21034C16.4603 8.86592 16.0009 9.421 15.3638 9.58026L10.737 10.737L9.58026 15.3638C9.421 16.0009 8.86592 16.4603 8.21034 16.4976C7.55477 16.535 6.95111 16.1416 6.72055 15.5267L2.59555 4.52673C2.38901 3.97597 2.52345 3.35531 2.93938 2.93938Z" fill="white"/></g><path fill-rule="evenodd" clip-rule="evenodd" d="M4.17558 3.53185C3.99199 3.463 3.7851 3.50782 3.64646 3.64646C3.50782 3.7851 3.463 3.99199 3.53185 4.17558L7.65685 15.1756C7.7337 15.3805 7.93492 15.5117 8.15345 15.4992C8.37197 15.4868 8.557 15.3336 8.61009 15.1213L9.91232 9.91232L15.1213 8.61009C15.3336 8.557 15.4868 8.37197 15.4992 8.15345C15.5117 7.93492 15.3805 7.7337 15.1756 7.65685L4.17558 3.53185Z" fill="black"/></g><defs><filter id="filter0_d_20065_231516" x="-0.5" y="0.5" width="20" height="20" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="1"/><feGaussianBlur stdDeviation="1.5"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_20065_231516"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_20065_231516" result="shape"/></filter><clipPath id="clip0_20065_231516"><rect width="32" height="32" fill="white"/></clipPath></defs></svg>') 3 3, default;
|
|
190
|
+
--fig-lab-cursor-eyedropper: url('data:image/svg+xml,<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(%23filter0_d_20065_164959)"><path fill-rule="evenodd" clip-rule="evenodd" d="M17.0262 19.5947L11.287 25.3339C10.9185 25.7023 10.4442 25.9465 9.93021 26.0321L8.62726 26.2493C6.93521 26.5313 5.46827 25.0644 5.75028 23.3723L5.96744 22.0694C6.0531 21.5554 6.29721 21.081 6.66565 20.7126L12.4049 14.9733C11.7004 13.974 11.7951 12.5833 12.6891 11.6893C13.5832 10.7952 14.974 10.7005 15.9733 11.4051L18.1891 9.18929C19.4653 7.91315 21.5343 7.91314 22.8105 9.18928C24.0866 10.4654 24.0866 12.5345 22.8105 13.8106L20.5946 16.0265C21.2993 17.0258 21.2045 18.4165 20.3104 19.3106C19.4163 20.2047 18.0255 20.2994 17.0262 19.5947Z" fill="white"/></g><path fill-rule="evenodd" clip-rule="evenodd" d="M13.3963 14.6035L13.7926 14.9999L7.37288 21.4197C7.15181 21.6408 7.00534 21.9254 6.95395 22.2338L6.73679 23.5367C6.56758 24.5519 7.44775 25.4321 8.46298 25.2629L9.76592 25.0457C10.0743 24.9943 10.3589 24.8479 10.58 24.6268L16.9997 18.2071L17.3962 18.6035C18.0057 19.213 18.9939 19.213 19.6034 18.6035C20.2129 17.994 20.213 17.0059 19.6035 16.3963L19.2071 15.9999L22.1035 13.1035C22.9891 12.2179 22.9891 10.782 22.1035 9.89639C21.2179 9.01077 19.782 9.01077 18.8964 9.8964L16 12.7928L15.6035 12.3963C14.994 11.7869 14.0058 11.7869 13.3964 12.3964C12.7869 13.0059 12.7869 13.994 13.3963 14.6035ZM14.4997 15.7071L16.2926 17.5L9.87288 23.9197C9.79919 23.9934 9.70432 24.0422 9.60152 24.0593L8.29858 24.2765C7.96017 24.3329 7.66678 24.0395 7.72318 23.7011L7.94034 22.3982C7.95747 22.2954 8.00629 22.2005 8.07998 22.1268L14.4997 15.7071Z" fill="black"/><defs><filter id="filter0_d_20065_164959" x="2.71533" y="6.23218" width="24.0522" height="24.052" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="1"/><feGaussianBlur stdDeviation="1.5"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_20065_164959"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_20065_164959" result="shape"/></filter></defs></svg>') 8 24, crosshair;
|
|
191
|
+
--fig-lab-cursor-move: url('data:image/svg+xml,<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23clip0_20065_165164)"><g filter="url(%23filter0_d_20065_165164)"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.93938 2.93938C3.35531 2.52345 3.97597 2.38901 4.52673 2.59555L15.5267 6.72055C16.1416 6.95111 16.535 7.55477 16.4976 8.21034C16.4603 8.86592 16.0009 9.421 15.3638 9.58026L10.737 10.737L9.58026 15.3638C9.421 16.0009 8.86592 16.4603 8.21034 16.4976C7.55477 16.535 6.95111 16.1416 6.72055 15.5267L2.59555 4.52673C2.38901 3.97597 2.52345 3.35531 2.93938 2.93938Z" fill="white"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.4394 12.9394C19.0252 12.3536 19.9749 12.3536 20.5607 12.9394L26.0607 18.4394C26.6465 19.0252 26.6465 19.9749 26.0607 20.5607L20.5607 26.0607C19.9749 26.6465 19.0252 26.6465 18.4394 26.0607L12.9394 20.5607C12.3536 19.9749 12.3536 19.0252 12.9394 18.4394L18.4394 12.9394Z" fill="white"/></g><path fill-rule="evenodd" clip-rule="evenodd" d="M4.17558 3.53185C3.99199 3.463 3.7851 3.50782 3.64646 3.64646C3.50782 3.7851 3.463 3.99199 3.53185 4.17558L7.65685 15.1756C7.7337 15.3805 7.93492 15.5117 8.15345 15.4992C8.37197 15.4868 8.557 15.3336 8.61009 15.1213L9.91232 9.91232L15.1213 8.61009C15.3336 8.557 15.4868 8.37197 15.4992 8.15345C15.5117 7.93492 15.3805 7.7337 15.1756 7.65685L4.17558 3.53185Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.1464 13.6464C19.3417 13.4512 19.6583 13.4512 19.8536 13.6464L21.8536 15.6464C22.0488 15.8417 22.0488 16.1583 21.8536 16.3536C21.6583 16.5488 21.3417 16.5488 21.1464 16.3536L20 15.2071V19H23.7929L22.6464 17.8536C22.4512 17.6583 22.4512 17.3417 22.6464 17.1464C22.8417 16.9512 23.1583 16.9512 23.3536 17.1464L25.3536 19.1464C25.5488 19.3417 25.5488 19.6583 25.3536 19.8536L23.3536 21.8536C23.1583 22.0488 22.8417 22.0488 22.6464 21.8536C22.4512 21.6583 22.4512 21.3417 22.6464 21.1464L23.7929 20H20V23.7929L21.1464 22.6464C21.3417 22.4512 21.6583 22.4512 21.8536 22.6464C22.0488 22.8417 22.0488 23.1583 21.8536 23.3536L19.8536 25.3536C19.6583 25.5488 19.3417 25.5488 19.1464 25.3536L17.1464 23.3536C16.9512 23.1583 16.9512 22.8417 17.1464 22.6464C17.3417 22.4512 17.6583 22.4512 17.8536 22.6464L19 23.7929V20H15.2071L16.3536 21.1464C16.5488 21.3417 16.5488 21.6583 16.3536 21.8536C16.1583 22.0488 15.8417 22.0488 15.6464 21.8536L13.6464 19.8536C13.4512 19.6583 13.4512 19.3417 13.6464 19.1464L15.6464 17.1464C15.8417 16.9512 16.1583 16.9512 16.3536 17.1464C16.5488 17.3417 16.5488 17.6583 16.3536 17.8536L15.2071 19H19V15.2071L17.8536 16.3536C17.6583 16.5488 17.3417 16.5488 17.1464 16.3536C16.9512 16.1583 16.9512 15.8417 17.1464 15.6464L19.1464 13.6464Z" fill="black"/></g><defs><filter id="filter0_d_20065_165164" x="-0.5" y="0.5" width="30" height="30" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="1"/><feGaussianBlur stdDeviation="1.5"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_20065_165164"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_20065_165164" result="shape"/></filter><clipPath id="clip0_20065_165164"><rect width="32" height="32" fill="white"/></clipPath></defs></svg>') 3 3, move;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
body.fig-lab-move-active,
|
|
195
|
+
body.fig-lab-move-active * {
|
|
196
|
+
cursor: var(--fig-lab-cursor-move) !important;
|
|
197
|
+
}
|
|
198
|
+
|
|
188
199
|
fig-canvas-control {
|
|
189
200
|
display: contents;
|
|
190
201
|
--fig-canvas-control-line-stroke: light-dark(
|
|
@@ -207,6 +218,25 @@ fig-canvas-control {
|
|
|
207
218
|
z-index: 1;
|
|
208
219
|
}
|
|
209
220
|
|
|
221
|
+
fig-handle:hover,
|
|
222
|
+
fig-handle:hover .fig-handle-hit-area {
|
|
223
|
+
cursor: var(--fig-lab-cursor) !important;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&[type="color"] fig-handle[type="color"]:hover:not(:active, .active, .dragging),
|
|
227
|
+
&[type="color"] fig-handle[type="color"]:hover:not(:active, .active, .dragging) .fig-handle-hit-area {
|
|
228
|
+
cursor: var(--fig-lab-cursor-eyedropper) !important;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
fig-handle:is(:active, .active, .dragging),
|
|
232
|
+
fig-handle:is(:active, .active, .dragging) .fig-handle-hit-area {
|
|
233
|
+
cursor: var(--fig-lab-cursor-move) !important;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.fig-canvas-control-angle-line-hit {
|
|
237
|
+
cursor: var(--fig-lab-cursor-move);
|
|
238
|
+
}
|
|
239
|
+
|
|
210
240
|
.fig-canvas-control-radius {
|
|
211
241
|
position: absolute;
|
|
212
242
|
pointer-events: none;
|
package/fig-lab.js
CHANGED
|
@@ -303,7 +303,10 @@ class FigCanvasControl extends HTMLElement {
|
|
|
303
303
|
#isSecondDragging = false;
|
|
304
304
|
#isRadiusDragging = false;
|
|
305
305
|
#isAngleDragging = false;
|
|
306
|
-
#
|
|
306
|
+
#moveCursorPointerId = null;
|
|
307
|
+
#moveCursorPrevBodyCursor = "";
|
|
308
|
+
#moveCursorPrevBodyCursorPriority = "";
|
|
309
|
+
#boundMoveCursorEnd = null;
|
|
307
310
|
|
|
308
311
|
get #type() {
|
|
309
312
|
return this.getAttribute("type") || "point";
|
|
@@ -403,6 +406,8 @@ class FigCanvasControl extends HTMLElement {
|
|
|
403
406
|
|
|
404
407
|
disconnectedCallback() {
|
|
405
408
|
this.#teardownRadiusDrag();
|
|
409
|
+
this.#deactivateMoveCursor();
|
|
410
|
+
document.body.classList.remove("fig-lab-move-active");
|
|
406
411
|
}
|
|
407
412
|
|
|
408
413
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
@@ -564,11 +569,87 @@ class FigCanvasControl extends HTMLElement {
|
|
|
564
569
|
this.#createSecondHandle(disabled, tooltips, handleSurface);
|
|
565
570
|
}
|
|
566
571
|
|
|
572
|
+
this.#setupHandleMoveCursor(this.#pointHandle);
|
|
573
|
+
this.#setupHandleMoveCursor(this.#angleHandle);
|
|
574
|
+
this.#setupHandleMoveCursor(this.#secondHandle);
|
|
567
575
|
this.#setupEventListeners();
|
|
568
576
|
this.#wireHoverTooltips();
|
|
569
577
|
requestAnimationFrame(() => this.#syncPositions());
|
|
570
578
|
}
|
|
571
579
|
|
|
580
|
+
#setupHandleMoveCursor(handle) {
|
|
581
|
+
if (!handle) return;
|
|
582
|
+
handle.addEventListener(
|
|
583
|
+
"pointerdown",
|
|
584
|
+
(e) => this.#activateMoveCursor(e),
|
|
585
|
+
{ capture: true },
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
#activateMoveCursor(e) {
|
|
590
|
+
if (this.hasAttribute("disabled")) return;
|
|
591
|
+
if (e?.button !== undefined && e.button !== 0) return;
|
|
592
|
+
if (e?.isPrimary === false) return;
|
|
593
|
+
|
|
594
|
+
if (this.#moveCursorPointerId === null) {
|
|
595
|
+
this.#moveCursorPrevBodyCursor =
|
|
596
|
+
document.body.style.getPropertyValue("cursor");
|
|
597
|
+
this.#moveCursorPrevBodyCursorPriority =
|
|
598
|
+
document.body.style.getPropertyPriority("cursor");
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
this.#moveCursorPointerId = e?.pointerId ?? -1;
|
|
602
|
+
document.body.classList.add("fig-lab-move-active");
|
|
603
|
+
document.body.style.setProperty(
|
|
604
|
+
"cursor",
|
|
605
|
+
"var(--fig-lab-cursor-move)",
|
|
606
|
+
"important",
|
|
607
|
+
);
|
|
608
|
+
|
|
609
|
+
if (!this.#boundMoveCursorEnd) {
|
|
610
|
+
this.#boundMoveCursorEnd = (event) => {
|
|
611
|
+
if (
|
|
612
|
+
event?.pointerId !== undefined &&
|
|
613
|
+
this.#moveCursorPointerId !== null &&
|
|
614
|
+
event.pointerId !== this.#moveCursorPointerId
|
|
615
|
+
) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (event?.type === "blur") {
|
|
619
|
+
this.#deactivateMoveCursor();
|
|
620
|
+
} else {
|
|
621
|
+
requestAnimationFrame(() => this.#deactivateMoveCursor());
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
window.addEventListener("pointerup", this.#boundMoveCursorEnd);
|
|
627
|
+
window.addEventListener("pointercancel", this.#boundMoveCursorEnd);
|
|
628
|
+
window.addEventListener("blur", this.#boundMoveCursorEnd);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
#deactivateMoveCursor() {
|
|
632
|
+
if (this.#moveCursorPointerId === null) return;
|
|
633
|
+
document.body.classList.remove("fig-lab-move-active");
|
|
634
|
+
if (this.#moveCursorPrevBodyCursor) {
|
|
635
|
+
document.body.style.setProperty(
|
|
636
|
+
"cursor",
|
|
637
|
+
this.#moveCursorPrevBodyCursor,
|
|
638
|
+
this.#moveCursorPrevBodyCursorPriority,
|
|
639
|
+
);
|
|
640
|
+
} else {
|
|
641
|
+
document.body.style.removeProperty("cursor");
|
|
642
|
+
}
|
|
643
|
+
this.#moveCursorPointerId = null;
|
|
644
|
+
this.#moveCursorPrevBodyCursor = "";
|
|
645
|
+
this.#moveCursorPrevBodyCursorPriority = "";
|
|
646
|
+
if (this.#boundMoveCursorEnd) {
|
|
647
|
+
window.removeEventListener("pointerup", this.#boundMoveCursorEnd);
|
|
648
|
+
window.removeEventListener("pointercancel", this.#boundMoveCursorEnd);
|
|
649
|
+
window.removeEventListener("blur", this.#boundMoveCursorEnd);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
572
653
|
#wireHoverTooltip(target, getTooltip, getText, isDraggingRef) {
|
|
573
654
|
if (!target) return;
|
|
574
655
|
const shouldSuppress = () => !!isDraggingRef?.();
|
|
@@ -736,7 +817,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
736
817
|
hitLine.setAttribute("stroke-width", "12");
|
|
737
818
|
hitLine.setAttribute("stroke-linecap", "round");
|
|
738
819
|
hitLine.style.pointerEvents = "stroke";
|
|
739
|
-
hitLine.style.cursor = "move";
|
|
740
820
|
svg.appendChild(hitLine);
|
|
741
821
|
this.#setupLineDrag(hitLine);
|
|
742
822
|
}
|
|
@@ -766,8 +846,7 @@ class FigCanvasControl extends HTMLElement {
|
|
|
766
846
|
const y20 = this.#y2;
|
|
767
847
|
this.#isDragging = true;
|
|
768
848
|
this.#isSecondDragging = true;
|
|
769
|
-
|
|
770
|
-
document.body.style.cursor = "move";
|
|
849
|
+
document.body.classList.add("fig-lab-move-active");
|
|
771
850
|
hitLine.style.pointerEvents = "none";
|
|
772
851
|
|
|
773
852
|
const onMove = (ev) => {
|
|
@@ -791,7 +870,7 @@ class FigCanvasControl extends HTMLElement {
|
|
|
791
870
|
};
|
|
792
871
|
|
|
793
872
|
const onUp = () => {
|
|
794
|
-
document.body.
|
|
873
|
+
document.body.classList.remove("fig-lab-move-active");
|
|
795
874
|
hitLine.style.pointerEvents = "stroke";
|
|
796
875
|
this.#syncValueAttribute();
|
|
797
876
|
this.#emitChange();
|
|
@@ -1004,9 +1083,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1004
1083
|
this.#emitInput();
|
|
1005
1084
|
return;
|
|
1006
1085
|
}
|
|
1007
|
-
if (!this.#isDragging && this.#hasSecondPoint) {
|
|
1008
|
-
this.#prevBodyCursor = document.body.style.cursor;
|
|
1009
|
-
}
|
|
1010
1086
|
this.#isDragging = true;
|
|
1011
1087
|
const px = e.detail?.px ?? this.#x / 100;
|
|
1012
1088
|
const py = e.detail?.py ?? this.#y / 100;
|
|
@@ -1017,11 +1093,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1017
1093
|
this.#pointTooltip.hidePopup?.();
|
|
1018
1094
|
}
|
|
1019
1095
|
this.#syncPositions();
|
|
1020
|
-
if (this.#hasSecondPoint) {
|
|
1021
|
-
document.body.style.cursor = this.#resizeCursorSvg(
|
|
1022
|
-
this.#pointPointLineDeg(),
|
|
1023
|
-
);
|
|
1024
|
-
}
|
|
1025
1096
|
this.#emitInput();
|
|
1026
1097
|
});
|
|
1027
1098
|
|
|
@@ -1037,9 +1108,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1037
1108
|
this.#x = Math.round(Math.max(0, Math.min(100, px * 100)));
|
|
1038
1109
|
this.#y = Math.round(Math.max(0, Math.min(100, py * 100)));
|
|
1039
1110
|
if (this.#pointTooltip) this.#pointTooltip.removeAttribute("show");
|
|
1040
|
-
if (this.#hasSecondPoint) {
|
|
1041
|
-
document.body.style.cursor = this.#prevBodyCursor ?? "";
|
|
1042
|
-
}
|
|
1043
1111
|
this.#syncPositions();
|
|
1044
1112
|
this.#syncValueAttribute();
|
|
1045
1113
|
this.#emitChange();
|
|
@@ -1051,10 +1119,10 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1051
1119
|
if (this.#angleHandle) {
|
|
1052
1120
|
this.#angleHandle.addEventListener("input", (e) => {
|
|
1053
1121
|
e.stopPropagation();
|
|
1054
|
-
this.#isAngleDragging = true;
|
|
1055
|
-
this.classList.add("fig-canvas-control-ring-active");
|
|
1056
1122
|
const container = this.#container;
|
|
1057
1123
|
if (!container) return;
|
|
1124
|
+
this.#isAngleDragging = true;
|
|
1125
|
+
this.classList.add("fig-canvas-control-ring-active");
|
|
1058
1126
|
const rect = container.getBoundingClientRect();
|
|
1059
1127
|
const cx = (this.#x / 100) * rect.width;
|
|
1060
1128
|
const cy = (this.#y / 100) * rect.height;
|
|
@@ -1116,21 +1184,17 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1116
1184
|
const origEvent = e.detail?.originalEvent;
|
|
1117
1185
|
if (!origEvent) return;
|
|
1118
1186
|
origEvent.preventDefault();
|
|
1187
|
+
const container = this.#container;
|
|
1188
|
+
if (!container) return;
|
|
1119
1189
|
this.#isAngleDragging = true;
|
|
1120
1190
|
this.classList.add("fig-canvas-control-ring-active");
|
|
1121
1191
|
this.#angleHandle.setAttribute("selected", "");
|
|
1122
|
-
const container = this.#container;
|
|
1123
|
-
if (!container) return;
|
|
1124
1192
|
|
|
1125
1193
|
if (this.#angleTooltip) {
|
|
1126
1194
|
this.#angleTooltip.setAttribute("show", "true");
|
|
1127
1195
|
this.#angleTooltip.showPopup?.();
|
|
1128
1196
|
}
|
|
1129
1197
|
|
|
1130
|
-
const prevBodyCursor = document.body.style.cursor;
|
|
1131
|
-
let lastCursorDeg = Math.round(this.#angle);
|
|
1132
|
-
document.body.style.cursor = this.#rotateCursorSvg(lastCursorDeg);
|
|
1133
|
-
|
|
1134
1198
|
const onMove = (ev) => {
|
|
1135
1199
|
const rect = container.getBoundingClientRect();
|
|
1136
1200
|
const cx = (this.#x / 100) * rect.width;
|
|
@@ -1148,11 +1212,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1148
1212
|
`Angle ${Math.round(angle)}°`,
|
|
1149
1213
|
);
|
|
1150
1214
|
this.#syncPositions();
|
|
1151
|
-
const curDeg = Math.round(angle);
|
|
1152
|
-
if (curDeg !== lastCursorDeg) {
|
|
1153
|
-
lastCursorDeg = curDeg;
|
|
1154
|
-
document.body.style.cursor = this.#rotateCursorSvg(curDeg);
|
|
1155
|
-
}
|
|
1156
1215
|
this.#emitInput();
|
|
1157
1216
|
};
|
|
1158
1217
|
|
|
@@ -1160,7 +1219,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1160
1219
|
this.#isAngleDragging = false;
|
|
1161
1220
|
this.classList.remove("fig-canvas-control-ring-active");
|
|
1162
1221
|
this.#angleHandle.removeAttribute("selected");
|
|
1163
|
-
document.body.style.cursor = prevBodyCursor;
|
|
1164
1222
|
if (this.#angleTooltip) this.#angleTooltip.removeAttribute("show");
|
|
1165
1223
|
this.#syncValueAttribute();
|
|
1166
1224
|
this.#emitChange();
|
|
@@ -1176,9 +1234,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1176
1234
|
if (this.#secondHandle) {
|
|
1177
1235
|
this.#secondHandle.addEventListener("input", (e) => {
|
|
1178
1236
|
e.stopPropagation();
|
|
1179
|
-
if (!this.#isSecondDragging) {
|
|
1180
|
-
this.#prevBodyCursor = document.body.style.cursor;
|
|
1181
|
-
}
|
|
1182
1237
|
this.#isSecondDragging = true;
|
|
1183
1238
|
const px = e.detail?.px ?? this.#x2 / 100;
|
|
1184
1239
|
const py = e.detail?.py ?? this.#y2 / 100;
|
|
@@ -1189,15 +1244,11 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1189
1244
|
this.#secondTooltip.hidePopup?.();
|
|
1190
1245
|
}
|
|
1191
1246
|
this.#syncPositions();
|
|
1192
|
-
document.body.style.cursor = this.#resizeCursorSvg(
|
|
1193
|
-
this.#pointPointLineDeg(),
|
|
1194
|
-
);
|
|
1195
1247
|
this.#emitInput();
|
|
1196
1248
|
});
|
|
1197
1249
|
|
|
1198
1250
|
this.#secondHandle.addEventListener("change", (e) => {
|
|
1199
1251
|
e.stopPropagation();
|
|
1200
|
-
document.body.style.cursor = this.#prevBodyCursor ?? "";
|
|
1201
1252
|
if (this.#secondTooltip) this.#secondTooltip.removeAttribute("show");
|
|
1202
1253
|
this.#syncPositions();
|
|
1203
1254
|
this.#syncValueAttribute();
|
|
@@ -1219,9 +1270,9 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1219
1270
|
const origEvent = e.detail?.originalEvent;
|
|
1220
1271
|
if (!origEvent) return;
|
|
1221
1272
|
origEvent.preventDefault();
|
|
1222
|
-
this.#isDragging = true;
|
|
1223
1273
|
const container = this.#container;
|
|
1224
1274
|
if (!container) return;
|
|
1275
|
+
this.#isDragging = true;
|
|
1225
1276
|
const rect = container.getBoundingClientRect();
|
|
1226
1277
|
|
|
1227
1278
|
const pivotX = isFirst ? this.#x2 : this.#x;
|
|
@@ -1240,11 +1291,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1240
1291
|
tooltip.hidePopup?.();
|
|
1241
1292
|
}
|
|
1242
1293
|
|
|
1243
|
-
const prevBodyCursor = document.body.style.cursor;
|
|
1244
|
-
const initDeg = this.#pointPointLineDeg();
|
|
1245
|
-
let lastCursorDeg = Math.round(isFirst ? initDeg + 180 : initDeg);
|
|
1246
|
-
document.body.style.cursor = this.#rotateCursorSvg(lastCursorDeg);
|
|
1247
|
-
|
|
1248
1294
|
const onMove = (ev) => {
|
|
1249
1295
|
const r = container.getBoundingClientRect();
|
|
1250
1296
|
const px = (pivotX / 100) * r.width;
|
|
@@ -1268,19 +1314,11 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1268
1314
|
this.#y2 = newPctY;
|
|
1269
1315
|
}
|
|
1270
1316
|
this.#syncPositions();
|
|
1271
|
-
const curDeg = Math.round(
|
|
1272
|
-
isFirst ? this.#pointPointLineDeg() + 180 : this.#pointPointLineDeg(),
|
|
1273
|
-
);
|
|
1274
|
-
if (curDeg !== lastCursorDeg) {
|
|
1275
|
-
lastCursorDeg = curDeg;
|
|
1276
|
-
document.body.style.cursor = this.#rotateCursorSvg(curDeg);
|
|
1277
|
-
}
|
|
1278
1317
|
this.#emitInput();
|
|
1279
1318
|
};
|
|
1280
1319
|
|
|
1281
1320
|
const onUp = () => {
|
|
1282
1321
|
this.#isDragging = false;
|
|
1283
|
-
document.body.style.cursor = prevBodyCursor;
|
|
1284
1322
|
if (tooltip) tooltip.removeAttribute("show");
|
|
1285
1323
|
this.#syncValueAttribute();
|
|
1286
1324
|
this.#emitChange();
|
package/package.json
CHANGED