@mingxy/opencode-mascot 0.3.2 → 0.3.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/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;
|
|
@@ -49,16 +48,12 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
49
48
|
});
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
|
-
<box
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
alignItems="center"
|
|
59
|
-
zIndex={100}
|
|
60
|
-
flexDirection="column"
|
|
61
|
-
onMouseDown={(e: any) => {
|
|
51
|
+
<box
|
|
52
|
+
alignItems="center"
|
|
53
|
+
zIndex={100}
|
|
54
|
+
flexDirection="column"
|
|
55
|
+
ref={(node: any) => { boxRef = node; }}
|
|
56
|
+
onMouseDown={(e: any) => {
|
|
62
57
|
const now = Date.now();
|
|
63
58
|
if (now - lastClickTime < 300) {
|
|
64
59
|
switchToNext();
|
|
@@ -67,24 +62,19 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
67
62
|
}
|
|
68
63
|
lastClickTime = now;
|
|
69
64
|
|
|
70
|
-
if (e.modifiers?.alt) {
|
|
65
|
+
if (e.modifiers?.alt && boxRef) {
|
|
71
66
|
dragStartX = e.x;
|
|
72
67
|
dragStartY = e.y;
|
|
73
|
-
dragAnchorX =
|
|
74
|
-
dragAnchorY =
|
|
68
|
+
dragAnchorX = boxRef.translateX || 0;
|
|
69
|
+
dragAnchorY = boxRef.translateY || 0;
|
|
75
70
|
isDragging = true;
|
|
76
71
|
renderers[currentName()].setDragging(true);
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
e.stopPropagation();
|
|
79
|
-
props.api.renderer.clearSelection();
|
|
80
72
|
}
|
|
81
73
|
}}
|
|
82
74
|
onMouseDrag={(e: any) => {
|
|
83
|
-
if (e.modifiers?.alt && isDragging) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
e.preventDefault();
|
|
87
|
-
props.api.renderer.clearSelection();
|
|
75
|
+
if (e.modifiers?.alt && isDragging && boxRef) {
|
|
76
|
+
boxRef.translateX = dragAnchorX + (e.x - dragStartX);
|
|
77
|
+
boxRef.translateY = dragAnchorY + (e.y - dragStartY);
|
|
88
78
|
}
|
|
89
79
|
}}
|
|
90
80
|
onMouseUp={() => {
|
|
@@ -103,7 +93,6 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
103
93
|
}}
|
|
104
94
|
>
|
|
105
95
|
{renderers[currentName()]?.element() ?? null}
|
|
106
|
-
</box>
|
|
107
96
|
</box>
|
|
108
97
|
);
|
|
109
98
|
}
|
|
@@ -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={() => {
|