@rogieking/figui3 6.4.3 → 6.4.5
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 +11 -3
- 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="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(%23filter0_d_20089_234507)"><path d="M21.9392 13.4383C23.0416 12.3365 24.8073 12.3025 25.951 13.3347L26.0594 13.4383L26.1629 13.5476C27.1956 14.6911 27.1633 16.4583 26.0603 17.5613L25.118 18.5027C25.9194 19.3681 25.9023 20.7185 25.0613 21.5603L25.0603 21.5613C24.2185 22.4021 22.8681 22.4194 22.0027 21.618L18.1668 25.4549C17.8885 25.7327 17.5329 25.9242 17.1453 26.0017L15.5291 26.325C14.1302 26.6042 12.8971 25.3697 13.1756 23.9715L13.4988 22.3553C13.5763 21.9677 13.7679 21.6121 14.0457 21.3338L17.8806 17.4969C17.0787 16.6304 17.1 15.2789 17.9402 14.4383C18.7815 13.598 20.1303 13.58 20.9959 14.3806L21.9392 13.4383ZM17.4597 24.7469C17.3202 24.8861 17.1423 24.9816 16.949 25.0203L15.3328 25.3435C15.2891 25.3522 15.2458 25.359 15.2029 25.3621C15.2458 25.3593 15.2892 25.3532 15.3328 25.3445L16.949 25.0213C16.9976 25.0116 17.0453 24.998 17.0916 24.9812C17.1376 24.9647 17.1824 24.9447 17.2254 24.9217C17.2681 24.8987 17.3094 24.8725 17.3484 24.8435L17.4597 24.7478L21.9998 20.2078L22.6463 20.8543C22.6738 20.8817 22.7028 20.9072 22.7322 20.9314C22.7028 20.9071 22.6738 20.8808 22.6463 20.8533L21.9998 20.2068L17.4597 24.7469ZM14.156 24.1678C14.1474 24.2113 14.1414 24.2549 14.1385 24.2976C14.1355 24.3404 14.135 24.383 14.1375 24.4246C14.1425 24.5086 14.1584 24.5903 14.1834 24.6678V24.6658C14.1342 24.5118 14.1212 24.3417 14.156 24.1668V24.1678ZM15.4597 22.7469L15.1375 24.3631L15.4597 22.7478L19.9988 18.2078L21.2918 19.4998H21.2928L19.9988 18.2068L15.4597 22.7469ZM24.3533 20.8533C24.3257 20.8809 24.2969 20.9071 24.2674 20.9314L24.3533 20.8543C24.3827 20.8248 24.4105 20.7941 24.4363 20.7625C24.4106 20.7938 24.3826 20.824 24.3533 20.8533ZM22.2928 18.5008L23.6463 19.8543C23.6562 19.8643 23.6652 19.8752 23.6726 19.8865L23.6463 19.8533L22.2928 18.4998V18.5008ZM25.3533 16.8533L23.7068 18.4998L25.3533 16.8543C25.3991 16.8085 25.4411 16.7598 25.4812 16.7107C25.4412 16.7596 25.3989 16.8077 25.3533 16.8533ZM18.5232 16.7097C18.5597 16.7602 18.6 16.809 18.6453 16.8543L19.2908 17.4998H19.2918L18.6453 16.8533C18.6002 16.8081 18.5596 16.7598 18.5232 16.7097ZM23.3533 14.8523L20.9998 17.2058L19.6463 15.8523C19.5654 15.772 19.4341 15.7719 19.3533 15.8523C19.3404 15.8653 19.3299 15.8801 19.3211 15.8953C19.3298 15.8803 19.3406 15.8661 19.3533 15.8533C19.4342 15.7725 19.5654 15.7727 19.6463 15.8533L20.9998 17.2068L23.3533 14.8533C23.3756 14.831 23.3987 14.8093 23.4226 14.7898L23.3533 14.8523ZM3.43924 2.93924C3.85511 2.52338 4.47546 2.3891 5.02616 2.59549L16.0262 6.72049C16.6409 6.95101 17.035 7.55433 16.9978 8.20975C16.9605 8.86518 16.5009 9.42047 15.864 9.57987L11.2371 10.7371L10.0799 15.364C9.92047 16.0009 9.36518 16.4605 8.70975 16.4978C8.05433 16.535 7.45101 16.1409 7.22049 15.5262L3.09549 4.52616C2.8891 3.97546 3.02338 3.35511 3.43924 2.93924ZM18.4959 15.3279C18.4915 15.3345 18.4875 15.3417 18.4832 15.3484C18.5076 15.3103 18.5341 15.2728 18.5633 15.2371L18.4959 15.3279ZM24.6453 14.8533C24.682 14.8901 24.7147 14.9296 24.7439 14.9705C24.7147 14.9294 24.6821 14.8892 24.6453 14.8523C24.637 14.844 24.6275 14.8367 24.6189 14.8289C24.6276 14.837 24.6368 14.8449 24.6453 14.8533ZM25.5974 14.4461C25.631 14.4969 25.662 14.5492 25.6902 14.6023C25.6326 14.4937 25.5642 14.389 25.4842 14.2908L25.5974 14.4461ZM24.1668 13.5935C24.157 13.5927 24.1473 13.5913 24.1375 13.5906L23.9998 13.5857C24.0555 13.5857 24.1112 13.5887 24.1668 13.5935Z" fill="white"/></g><path d="M22.6472 14.1463C23.3946 13.3992 24.6058 13.3992 25.3532 14.1463C26.1005 14.8938 26.1005 16.1059 25.3532 16.8533L23.7077 18.4988L24.3542 19.1453C24.8254 19.6168 24.8253 20.3809 24.3542 20.8524C23.8828 21.3237 23.1186 21.3236 22.6472 20.8524L22.0007 20.2069L17.4606 24.7459C17.3211 24.8853 17.1433 24.9806 16.9499 25.0194L15.3337 25.3426C14.6341 25.4823 14.0172 24.8654 14.1569 24.1658L14.4802 22.5506C14.5189 22.3572 14.6142 22.1784 14.7536 22.0389L19.2927 17.4988L18.6462 16.8524C18.1752 16.3809 18.1759 15.6157 18.6472 15.1444C19.1185 14.6737 19.8829 14.6736 20.3542 15.1444L21.0007 15.7908L22.6472 14.1463ZM15.4606 22.7459L15.1374 24.3621L16.7536 24.0389L21.2936 19.4998L19.9997 18.2059L15.4606 22.7459ZM4.14618 3.64631C4.28483 3.50767 4.49189 3.46321 4.67548 3.53205L15.6755 7.65705C15.8803 7.73388 16.011 7.93474 15.9987 8.15315C15.9863 8.37167 15.8331 8.55709 15.6208 8.61018L10.4118 9.91194L9.11005 15.1209C9.05696 15.3333 8.87154 15.4864 8.65302 15.4988C8.43465 15.5111 8.23375 15.3804 8.15692 15.1756L4.03192 4.17561C3.96308 3.99203 4.00756 3.78495 4.14618 3.64631Z" fill="black"/><defs><filter id="filter0_d_20089_234507" x="0" y="0.5" width="29.9133" height="29.8647" 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_20089_234507"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_20089_234507" result="shape"/></filter></defs></svg>') 3 3, 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