@mingxy/opencode-mascot 0.3.1 → 0.3.3
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/package.json
CHANGED
|
@@ -20,8 +20,7 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
20
20
|
const initialName = names[Math.floor(Math.random() * names.length)];
|
|
21
21
|
|
|
22
22
|
const [currentName, setCurrentName] = createSignal(initialName);
|
|
23
|
-
|
|
24
|
-
const [posY, setPosY] = createSignal(0);
|
|
23
|
+
let boxRef: any = null;
|
|
25
24
|
let dragStartX = 0;
|
|
26
25
|
let dragStartY = 0;
|
|
27
26
|
let dragAnchorX = 0;
|
|
@@ -50,11 +49,10 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
51
|
<box
|
|
53
|
-
left={posX()}
|
|
54
|
-
top={posY()}
|
|
55
52
|
alignItems="center"
|
|
56
53
|
zIndex={100}
|
|
57
54
|
flexDirection="column"
|
|
55
|
+
ref={(node: any) => { boxRef = node; }}
|
|
58
56
|
onMouseDown={(e: any) => {
|
|
59
57
|
const now = Date.now();
|
|
60
58
|
if (now - lastClickTime < 300) {
|
|
@@ -64,11 +62,11 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
64
62
|
}
|
|
65
63
|
lastClickTime = now;
|
|
66
64
|
|
|
67
|
-
if (e.modifiers?.alt) {
|
|
65
|
+
if (e.modifiers?.alt && boxRef) {
|
|
68
66
|
dragStartX = e.x;
|
|
69
67
|
dragStartY = e.y;
|
|
70
|
-
dragAnchorX =
|
|
71
|
-
dragAnchorY =
|
|
68
|
+
dragAnchorX = boxRef.translateX || 0;
|
|
69
|
+
dragAnchorY = boxRef.translateY || 0;
|
|
72
70
|
isDragging = true;
|
|
73
71
|
renderers[currentName()].setDragging(true);
|
|
74
72
|
e.preventDefault();
|
|
@@ -77,11 +75,9 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
77
75
|
}
|
|
78
76
|
}}
|
|
79
77
|
onMouseDrag={(e: any) => {
|
|
80
|
-
if (e.modifiers?.alt && isDragging) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
e.preventDefault();
|
|
84
|
-
props.api.renderer.clearSelection();
|
|
78
|
+
if (e.modifiers?.alt && isDragging && boxRef) {
|
|
79
|
+
boxRef.translateX = dragAnchorX + (e.x - dragStartX);
|
|
80
|
+
boxRef.translateY = dragAnchorY + (e.y - dragStartY);
|
|
85
81
|
}
|
|
86
82
|
}}
|
|
87
83
|
onMouseUp={() => {
|
|
@@ -225,8 +225,6 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
|
|
|
225
225
|
if (e.modifiers?.alt && isDragging) {
|
|
226
226
|
setPosX(clampX(dragAnchorX + (e.x - dragStartX)));
|
|
227
227
|
setPosY(clampY(dragAnchorY + (e.y - dragStartY)));
|
|
228
|
-
e.preventDefault();
|
|
229
|
-
props.api.renderer.clearSelection();
|
|
230
228
|
}
|
|
231
229
|
}}
|
|
232
230
|
onMouseUp={() => {
|