@@ -63,15 +63,6 @@ watchDebounced(
6363
6464// Set initial position to bottom center
6565const setInitialPosition = () => {
66- if (x .value !== 0 || y .value !== 0 ) {
67- return
68- }
69- if (storedPosition .value .x !== 0 || storedPosition .value .y !== 0 ) {
70- x .value = storedPosition .value .x
71- y .value = storedPosition .value .y
72- captureLastDragState ()
73- return
74- }
7566 if (panelRef .value ) {
7667 const screenWidth = window .innerWidth
7768 const screenHeight = window .innerHeight
@@ -82,9 +73,25 @@ const setInitialPosition = () => {
8273 return
8374 }
8475
85- x .value = (screenWidth - menuWidth ) / 2
86- y .value = screenHeight - menuHeight - 10 // 10px margin from bottom
87- captureLastDragState ()
76+ // Check if stored position exists and is within bounds
77+ if (storedPosition .value .x !== 0 || storedPosition .value .y !== 0 ) {
78+ // Ensure stored position is within screen bounds
79+ x .value = clamp (storedPosition .value .x , 0 , screenWidth - menuWidth )
80+ y .value = clamp (storedPosition .value .y , 0 , screenHeight - menuHeight )
81+ captureLastDragState ()
82+ return
83+ }
84+
85+ // If no stored position or current position, set to bottom center
86+ if (x .value === 0 && y .value === 0 ) {
87+ x .value = clamp ((screenWidth - menuWidth ) / 2 , 0 , screenWidth - menuWidth )
88+ y .value = clamp (
89+ screenHeight - menuHeight - 10 ,
90+ 0 ,
91+ screenHeight - menuHeight
92+ )
93+ captureLastDragState ()
94+ }
8895 }
8996}
9097onMounted (setInitialPosition )
0 commit comments