@mingxy/opencode-mascot 0.4.28 → 0.4.30
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,12 +20,15 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
20
20
|
const initialName = names[Math.floor(Math.random() * names.length)];
|
|
21
21
|
|
|
22
22
|
const cw = (typeof process !== "undefined" && process.stdout?.columns) || 80;
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
const initX = Math.floor((Math.random() - 0.5) * Math.max(0, cw - 20));
|
|
25
|
+
const initY = -(Math.floor(Math.random() * 8) + 2);
|
|
24
26
|
|
|
25
27
|
const [currentName, setCurrentName] = createSignal(initialName);
|
|
26
|
-
const [posX, setPosX] = createSignal(Math.floor(Math.random() * Math.max(0, cw - 12)));
|
|
27
|
-
const [posY, setPosY] = createSignal(-(Math.floor(Math.random() * Math.min(ch - 8, 15)) + 3));
|
|
28
28
|
const [zBoost, setZBoost] = createSignal(false);
|
|
29
|
+
let boxRef: any = null;
|
|
30
|
+
let curX = initX;
|
|
31
|
+
let curY = initY;
|
|
29
32
|
let dragStartX = 0;
|
|
30
33
|
let dragStartY = 0;
|
|
31
34
|
let dragAnchorX = 0;
|
|
@@ -44,6 +47,13 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
44
47
|
setCurrentName(names[(idx + 1) % names.length]);
|
|
45
48
|
};
|
|
46
49
|
|
|
50
|
+
const applyPos = () => {
|
|
51
|
+
if (boxRef) {
|
|
52
|
+
boxRef.translateX = curX;
|
|
53
|
+
boxRef.translateY = curY;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
47
57
|
onCelebrate((newVersion) => {
|
|
48
58
|
setZBoost(true);
|
|
49
59
|
renderers[currentName()].celebrateUpdate(newVersion);
|
|
@@ -67,11 +77,12 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
67
77
|
|
|
68
78
|
return (
|
|
69
79
|
<box
|
|
70
|
-
position="absolute"
|
|
71
|
-
left={posX()}
|
|
72
|
-
top={posY()}
|
|
73
80
|
zIndex={zBoost() ? 9999 : 100}
|
|
74
81
|
flexDirection="column"
|
|
82
|
+
ref={(node: any) => {
|
|
83
|
+
boxRef = node;
|
|
84
|
+
applyPos();
|
|
85
|
+
}}
|
|
75
86
|
onMouseDown={(e: any) => {
|
|
76
87
|
const now = Date.now();
|
|
77
88
|
if (now - lastClickTime < 300) {
|
|
@@ -84,8 +95,8 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
84
95
|
if (e.modifiers?.alt) {
|
|
85
96
|
dragStartX = e.x;
|
|
86
97
|
dragStartY = e.y;
|
|
87
|
-
dragAnchorX =
|
|
88
|
-
dragAnchorY =
|
|
98
|
+
dragAnchorX = curX;
|
|
99
|
+
dragAnchorY = curY;
|
|
89
100
|
isDragging = true;
|
|
90
101
|
renderers[currentName()].setDragging(true);
|
|
91
102
|
props.api.renderer.clearSelection();
|
|
@@ -93,8 +104,9 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
93
104
|
}}
|
|
94
105
|
onMouseDrag={(e: any) => {
|
|
95
106
|
if (e.modifiers?.alt && isDragging) {
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
curX = dragAnchorX + (e.x - dragStartX);
|
|
108
|
+
curY = dragAnchorY + (e.y - dragStartY);
|
|
109
|
+
applyPos();
|
|
98
110
|
}
|
|
99
111
|
}}
|
|
100
112
|
onMouseUp={() => { stopDrag(); }}
|