@rogieking/figui3 6.4.2 → 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 +21 -6
- 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 +41 -13
- package/fig-lab.js +115 -59
- 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(
|
|
@@ -195,14 +206,37 @@ fig-canvas-control {
|
|
|
195
206
|
--fig-canvas-control-radius-stroke-halo: #FFFFFF;
|
|
196
207
|
--fig-canvas-control-line-stroke-hover: #0D99FF;
|
|
197
208
|
--fig-canvas-control-line-stroke-active: #0D99FF;
|
|
198
|
-
--fig-canvas-control-line-stroke-width:
|
|
199
|
-
--fig-canvas-control-line-stroke-width-hover:
|
|
209
|
+
--fig-canvas-control-line-stroke-width: 1px;
|
|
210
|
+
--fig-canvas-control-line-stroke-width-hover: 2px;
|
|
211
|
+
|
|
212
|
+
&:has(.fig-canvas-control-radius-hit:hover) {
|
|
213
|
+
--fig-canvas-control-line-stroke-width: var(--fig-canvas-control-line-stroke-width-hover);
|
|
214
|
+
}
|
|
200
215
|
|
|
201
216
|
& > fig-handle,
|
|
202
217
|
& > fig-tooltip:has(fig-handle:not([size="small"])) {
|
|
203
218
|
z-index: 1;
|
|
204
219
|
}
|
|
205
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
|
+
|
|
206
240
|
.fig-canvas-control-radius {
|
|
207
241
|
position: absolute;
|
|
208
242
|
pointer-events: none;
|
|
@@ -217,7 +251,7 @@ fig-canvas-control {
|
|
|
217
251
|
|
|
218
252
|
.fig-canvas-control-radius-halo {
|
|
219
253
|
stroke: var(--fig-canvas-control-radius-stroke-halo);
|
|
220
|
-
stroke-width: calc(var(--fig-canvas-control-line-stroke-width)
|
|
254
|
+
stroke-width: calc(var(--fig-canvas-control-line-stroke-width) + 2px);
|
|
221
255
|
filter: none;
|
|
222
256
|
}
|
|
223
257
|
|
|
@@ -226,18 +260,12 @@ fig-canvas-control {
|
|
|
226
260
|
stroke-width: 12px;
|
|
227
261
|
pointer-events: stroke;
|
|
228
262
|
filter: none;
|
|
229
|
-
|
|
230
|
-
&:hover ~ circle:not(.fig-canvas-control-radius-halo) {
|
|
231
|
-
stroke-width: var(--fig-canvas-control-line-stroke-width-hover);
|
|
232
|
-
}
|
|
263
|
+
|
|
233
264
|
}
|
|
234
265
|
}
|
|
235
266
|
|
|
236
|
-
&.fig-canvas-control-ring-active
|
|
237
|
-
|
|
238
|
-
circle:not(.fig-canvas-control-radius-hit):not(.fig-canvas-control-radius-halo) {
|
|
239
|
-
stroke: var(--fig-canvas-control-line-stroke-active);
|
|
240
|
-
stroke-width: var(--fig-canvas-control-line-stroke-width-hover);
|
|
267
|
+
&.fig-canvas-control-ring-active{
|
|
268
|
+
--fig-canvas-control-line-stroke-width: var(--fig-canvas-control-line-stroke-width-hover);
|
|
241
269
|
}
|
|
242
270
|
|
|
243
271
|
.fig-canvas-control-angle-svg {
|
|
@@ -254,7 +282,7 @@ fig-canvas-control {
|
|
|
254
282
|
|
|
255
283
|
.fig-canvas-control-angle-line-halo {
|
|
256
284
|
stroke: var(--fig-canvas-control-radius-stroke-halo);
|
|
257
|
-
stroke-width: calc(var(--fig-canvas-control-line-stroke-width)
|
|
285
|
+
stroke-width: calc(var(--fig-canvas-control-line-stroke-width) + 2px);
|
|
258
286
|
stroke-linecap: butt;
|
|
259
287
|
filter: none;
|
|
260
288
|
}
|
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,15 +569,101 @@ 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;
|
|
655
|
+
const shouldSuppress = () => !!isDraggingRef?.();
|
|
656
|
+
const hideTooltip = () => {
|
|
657
|
+
const tip = getTooltip();
|
|
658
|
+
if (!tip) return;
|
|
659
|
+
tip.removeAttribute("show");
|
|
660
|
+
tip.hidePopup?.();
|
|
661
|
+
};
|
|
574
662
|
const show = () => {
|
|
575
|
-
if (
|
|
663
|
+
if (shouldSuppress()) {
|
|
664
|
+
hideTooltip();
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
576
667
|
const tip = getTooltip();
|
|
577
668
|
if (!tip) return;
|
|
578
669
|
if (getText) tip.setAttribute("text", getText());
|
|
@@ -580,15 +671,21 @@ class FigCanvasControl extends HTMLElement {
|
|
|
580
671
|
tip.showPopup?.();
|
|
581
672
|
};
|
|
582
673
|
const hide = () => {
|
|
583
|
-
|
|
584
|
-
const tip = getTooltip();
|
|
585
|
-
if (!tip) return;
|
|
586
|
-
tip.removeAttribute("show");
|
|
674
|
+
hideTooltip();
|
|
587
675
|
};
|
|
588
676
|
target.addEventListener("pointerenter", show);
|
|
589
677
|
target.addEventListener("pointerleave", hide);
|
|
590
678
|
}
|
|
591
679
|
|
|
680
|
+
#hasActiveInteraction() {
|
|
681
|
+
return (
|
|
682
|
+
this.#isDragging ||
|
|
683
|
+
this.#isSecondDragging ||
|
|
684
|
+
this.#isRadiusDragging ||
|
|
685
|
+
this.#isAngleDragging
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
|
|
592
689
|
#wireHoverTooltips() {
|
|
593
690
|
if (this.#pointHandle) {
|
|
594
691
|
this.#wireHoverTooltip(
|
|
@@ -596,7 +693,7 @@ class FigCanvasControl extends HTMLElement {
|
|
|
596
693
|
() => this.#pointTooltip,
|
|
597
694
|
() => this.#pointTipText,
|
|
598
695
|
() =>
|
|
599
|
-
this.#
|
|
696
|
+
this.#hasActiveInteraction() ||
|
|
600
697
|
!!this.#pointHandle?.querySelector("fig-color-tip"),
|
|
601
698
|
);
|
|
602
699
|
}
|
|
@@ -605,7 +702,7 @@ class FigCanvasControl extends HTMLElement {
|
|
|
605
702
|
this.#angleHandle,
|
|
606
703
|
() => this.#angleTooltip,
|
|
607
704
|
() => `Angle ${Math.round(this.#angle)}°`,
|
|
608
|
-
() => this.#
|
|
705
|
+
() => this.#hasActiveInteraction(),
|
|
609
706
|
);
|
|
610
707
|
}
|
|
611
708
|
if (this.#secondHandle) {
|
|
@@ -613,7 +710,7 @@ class FigCanvasControl extends HTMLElement {
|
|
|
613
710
|
this.#secondHandle,
|
|
614
711
|
() => this.#secondTooltip,
|
|
615
712
|
() => this.#secondTipText,
|
|
616
|
-
() => this.#
|
|
713
|
+
() => this.#hasActiveInteraction(),
|
|
617
714
|
);
|
|
618
715
|
}
|
|
619
716
|
if (this.#radiusSvg) {
|
|
@@ -720,7 +817,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
720
817
|
hitLine.setAttribute("stroke-width", "12");
|
|
721
818
|
hitLine.setAttribute("stroke-linecap", "round");
|
|
722
819
|
hitLine.style.pointerEvents = "stroke";
|
|
723
|
-
hitLine.style.cursor = "move";
|
|
724
820
|
svg.appendChild(hitLine);
|
|
725
821
|
this.#setupLineDrag(hitLine);
|
|
726
822
|
}
|
|
@@ -750,8 +846,7 @@ class FigCanvasControl extends HTMLElement {
|
|
|
750
846
|
const y20 = this.#y2;
|
|
751
847
|
this.#isDragging = true;
|
|
752
848
|
this.#isSecondDragging = true;
|
|
753
|
-
|
|
754
|
-
document.body.style.cursor = "move";
|
|
849
|
+
document.body.classList.add("fig-lab-move-active");
|
|
755
850
|
hitLine.style.pointerEvents = "none";
|
|
756
851
|
|
|
757
852
|
const onMove = (ev) => {
|
|
@@ -775,7 +870,7 @@ class FigCanvasControl extends HTMLElement {
|
|
|
775
870
|
};
|
|
776
871
|
|
|
777
872
|
const onUp = () => {
|
|
778
|
-
document.body.
|
|
873
|
+
document.body.classList.remove("fig-lab-move-active");
|
|
779
874
|
hitLine.style.pointerEvents = "stroke";
|
|
780
875
|
this.#syncValueAttribute();
|
|
781
876
|
this.#emitChange();
|
|
@@ -988,9 +1083,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
988
1083
|
this.#emitInput();
|
|
989
1084
|
return;
|
|
990
1085
|
}
|
|
991
|
-
if (!this.#isDragging && this.#hasSecondPoint) {
|
|
992
|
-
this.#prevBodyCursor = document.body.style.cursor;
|
|
993
|
-
}
|
|
994
1086
|
this.#isDragging = true;
|
|
995
1087
|
const px = e.detail?.px ?? this.#x / 100;
|
|
996
1088
|
const py = e.detail?.py ?? this.#y / 100;
|
|
@@ -1001,11 +1093,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1001
1093
|
this.#pointTooltip.hidePopup?.();
|
|
1002
1094
|
}
|
|
1003
1095
|
this.#syncPositions();
|
|
1004
|
-
if (this.#hasSecondPoint) {
|
|
1005
|
-
document.body.style.cursor = this.#resizeCursorSvg(
|
|
1006
|
-
this.#pointPointLineDeg(),
|
|
1007
|
-
);
|
|
1008
|
-
}
|
|
1009
1096
|
this.#emitInput();
|
|
1010
1097
|
});
|
|
1011
1098
|
|
|
@@ -1021,9 +1108,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1021
1108
|
this.#x = Math.round(Math.max(0, Math.min(100, px * 100)));
|
|
1022
1109
|
this.#y = Math.round(Math.max(0, Math.min(100, py * 100)));
|
|
1023
1110
|
if (this.#pointTooltip) this.#pointTooltip.removeAttribute("show");
|
|
1024
|
-
if (this.#hasSecondPoint) {
|
|
1025
|
-
document.body.style.cursor = this.#prevBodyCursor ?? "";
|
|
1026
|
-
}
|
|
1027
1111
|
this.#syncPositions();
|
|
1028
1112
|
this.#syncValueAttribute();
|
|
1029
1113
|
this.#emitChange();
|
|
@@ -1035,10 +1119,10 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1035
1119
|
if (this.#angleHandle) {
|
|
1036
1120
|
this.#angleHandle.addEventListener("input", (e) => {
|
|
1037
1121
|
e.stopPropagation();
|
|
1038
|
-
this.#isAngleDragging = true;
|
|
1039
|
-
this.classList.add("fig-canvas-control-ring-active");
|
|
1040
1122
|
const container = this.#container;
|
|
1041
1123
|
if (!container) return;
|
|
1124
|
+
this.#isAngleDragging = true;
|
|
1125
|
+
this.classList.add("fig-canvas-control-ring-active");
|
|
1042
1126
|
const rect = container.getBoundingClientRect();
|
|
1043
1127
|
const cx = (this.#x / 100) * rect.width;
|
|
1044
1128
|
const cy = (this.#y / 100) * rect.height;
|
|
@@ -1100,20 +1184,17 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1100
1184
|
const origEvent = e.detail?.originalEvent;
|
|
1101
1185
|
if (!origEvent) return;
|
|
1102
1186
|
origEvent.preventDefault();
|
|
1103
|
-
this.#isAngleDragging = true;
|
|
1104
|
-
this.classList.add("fig-canvas-control-ring-active");
|
|
1105
1187
|
const container = this.#container;
|
|
1106
1188
|
if (!container) return;
|
|
1189
|
+
this.#isAngleDragging = true;
|
|
1190
|
+
this.classList.add("fig-canvas-control-ring-active");
|
|
1191
|
+
this.#angleHandle.setAttribute("selected", "");
|
|
1107
1192
|
|
|
1108
1193
|
if (this.#angleTooltip) {
|
|
1109
1194
|
this.#angleTooltip.setAttribute("show", "true");
|
|
1110
1195
|
this.#angleTooltip.showPopup?.();
|
|
1111
1196
|
}
|
|
1112
1197
|
|
|
1113
|
-
const prevBodyCursor = document.body.style.cursor;
|
|
1114
|
-
let lastCursorDeg = Math.round(this.#angle);
|
|
1115
|
-
document.body.style.cursor = this.#rotateCursorSvg(lastCursorDeg);
|
|
1116
|
-
|
|
1117
1198
|
const onMove = (ev) => {
|
|
1118
1199
|
const rect = container.getBoundingClientRect();
|
|
1119
1200
|
const cx = (this.#x / 100) * rect.width;
|
|
@@ -1131,18 +1212,13 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1131
1212
|
`Angle ${Math.round(angle)}°`,
|
|
1132
1213
|
);
|
|
1133
1214
|
this.#syncPositions();
|
|
1134
|
-
const curDeg = Math.round(angle);
|
|
1135
|
-
if (curDeg !== lastCursorDeg) {
|
|
1136
|
-
lastCursorDeg = curDeg;
|
|
1137
|
-
document.body.style.cursor = this.#rotateCursorSvg(curDeg);
|
|
1138
|
-
}
|
|
1139
1215
|
this.#emitInput();
|
|
1140
1216
|
};
|
|
1141
1217
|
|
|
1142
1218
|
const onUp = () => {
|
|
1143
1219
|
this.#isAngleDragging = false;
|
|
1144
1220
|
this.classList.remove("fig-canvas-control-ring-active");
|
|
1145
|
-
|
|
1221
|
+
this.#angleHandle.removeAttribute("selected");
|
|
1146
1222
|
if (this.#angleTooltip) this.#angleTooltip.removeAttribute("show");
|
|
1147
1223
|
this.#syncValueAttribute();
|
|
1148
1224
|
this.#emitChange();
|
|
@@ -1158,9 +1234,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1158
1234
|
if (this.#secondHandle) {
|
|
1159
1235
|
this.#secondHandle.addEventListener("input", (e) => {
|
|
1160
1236
|
e.stopPropagation();
|
|
1161
|
-
if (!this.#isSecondDragging) {
|
|
1162
|
-
this.#prevBodyCursor = document.body.style.cursor;
|
|
1163
|
-
}
|
|
1164
1237
|
this.#isSecondDragging = true;
|
|
1165
1238
|
const px = e.detail?.px ?? this.#x2 / 100;
|
|
1166
1239
|
const py = e.detail?.py ?? this.#y2 / 100;
|
|
@@ -1171,15 +1244,11 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1171
1244
|
this.#secondTooltip.hidePopup?.();
|
|
1172
1245
|
}
|
|
1173
1246
|
this.#syncPositions();
|
|
1174
|
-
document.body.style.cursor = this.#resizeCursorSvg(
|
|
1175
|
-
this.#pointPointLineDeg(),
|
|
1176
|
-
);
|
|
1177
1247
|
this.#emitInput();
|
|
1178
1248
|
});
|
|
1179
1249
|
|
|
1180
1250
|
this.#secondHandle.addEventListener("change", (e) => {
|
|
1181
1251
|
e.stopPropagation();
|
|
1182
|
-
document.body.style.cursor = this.#prevBodyCursor ?? "";
|
|
1183
1252
|
if (this.#secondTooltip) this.#secondTooltip.removeAttribute("show");
|
|
1184
1253
|
this.#syncPositions();
|
|
1185
1254
|
this.#syncValueAttribute();
|
|
@@ -1201,9 +1270,9 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1201
1270
|
const origEvent = e.detail?.originalEvent;
|
|
1202
1271
|
if (!origEvent) return;
|
|
1203
1272
|
origEvent.preventDefault();
|
|
1204
|
-
this.#isDragging = true;
|
|
1205
1273
|
const container = this.#container;
|
|
1206
1274
|
if (!container) return;
|
|
1275
|
+
this.#isDragging = true;
|
|
1207
1276
|
const rect = container.getBoundingClientRect();
|
|
1208
1277
|
|
|
1209
1278
|
const pivotX = isFirst ? this.#x2 : this.#x;
|
|
@@ -1222,11 +1291,6 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1222
1291
|
tooltip.hidePopup?.();
|
|
1223
1292
|
}
|
|
1224
1293
|
|
|
1225
|
-
const prevBodyCursor = document.body.style.cursor;
|
|
1226
|
-
const initDeg = this.#pointPointLineDeg();
|
|
1227
|
-
let lastCursorDeg = Math.round(isFirst ? initDeg + 180 : initDeg);
|
|
1228
|
-
document.body.style.cursor = this.#rotateCursorSvg(lastCursorDeg);
|
|
1229
|
-
|
|
1230
1294
|
const onMove = (ev) => {
|
|
1231
1295
|
const r = container.getBoundingClientRect();
|
|
1232
1296
|
const px = (pivotX / 100) * r.width;
|
|
@@ -1250,19 +1314,11 @@ class FigCanvasControl extends HTMLElement {
|
|
|
1250
1314
|
this.#y2 = newPctY;
|
|
1251
1315
|
}
|
|
1252
1316
|
this.#syncPositions();
|
|
1253
|
-
const curDeg = Math.round(
|
|
1254
|
-
isFirst ? this.#pointPointLineDeg() + 180 : this.#pointPointLineDeg(),
|
|
1255
|
-
);
|
|
1256
|
-
if (curDeg !== lastCursorDeg) {
|
|
1257
|
-
lastCursorDeg = curDeg;
|
|
1258
|
-
document.body.style.cursor = this.#rotateCursorSvg(curDeg);
|
|
1259
|
-
}
|
|
1260
1317
|
this.#emitInput();
|
|
1261
1318
|
};
|
|
1262
1319
|
|
|
1263
1320
|
const onUp = () => {
|
|
1264
1321
|
this.#isDragging = false;
|
|
1265
|
-
document.body.style.cursor = prevBodyCursor;
|
|
1266
1322
|
if (tooltip) tooltip.removeAttribute("show");
|
|
1267
1323
|
this.#syncValueAttribute();
|
|
1268
1324
|
this.#emitChange();
|
package/package.json
CHANGED