@@ -4,7 +4,7 @@ import type { CSSProperties } from 'vue'
44import type { NuxtDevtoolsHostClient } from ' ../../../types'
55import { settings } from ' ../../settings'
66import { state } from ' ./state'
7- import { millisecondToHumanreadable , useEventListener , useScreenSafeArea } from ' ./utils'
7+ import { millisecondToHumanreadable , useElementBounding , useEventListener , useScreenSafeArea } from ' ./utils'
88import FrameBox from ' ./FrameBox.vue'
99
1010const props = defineProps <{
@@ -47,7 +47,7 @@ const vars = computed(() => {
4747 }
4848})
4949
50- const frameBox = ref <InstanceType < typeof FrameBox > >()
50+ const frameBox = ref <HTMLDivElement >()
5151const panelEl = ref <HTMLDivElement >()
5252const anchorEl = ref <HTMLDivElement >()
5353
@@ -235,6 +235,8 @@ const panelStyle = computed(() => {
235235 return style
236236})
237237
238+ const { width : frameWidth, height : frameHeight } = useElementBounding (frameBox )
239+
238240const iframeStyle = computed (() => {
239241 // eslint-disable-next-line no-unused-expressions, no-sequences
240242 mousePosition .x , mousePosition .y
@@ -255,8 +257,9 @@ const iframeStyle = computed(() => {
255257 const maxHeight = windowSize .height - marginVertical
256258
257259 const style: CSSProperties = {
260+ position: ' fixed' ,
258261 zIndex: - 1 ,
259- pointerEvents: isDragging .value ? ' none' : ' auto' ,
262+ pointerEvents: isDragging .value || ! state . value . open ? ' none' : ' auto' ,
260263 width: ` min(${state .value .width }vw, calc(100vw - ${marginHorizontal }px)) ` ,
261264 height: ` min(${state .value .height }vh, calc(100vh - ${marginVertical }px)) ` ,
262265 }
@@ -271,21 +274,21 @@ const iframeStyle = computed(() => {
271274 switch (state .value .position ) {
272275 case ' top' :
273276 case ' bottom' :
274- style .left = 0
275- style .transform = ' translate(-50% , 0)'
277+ style .left = ` ${ - frameWidth . value / 2 }px `
278+ style .transform = ' translate(0 , 0)'
276279 if ((anchorX - frameMargin .left ) < width / 2 )
277- style .left = ` ${width / 2 - anchorX + frameMargin .left }px `
280+ style .left = ` ${width / 2 - anchorX + frameMargin .left - frameWidth . value / 2 }px `
278281 else if ((windowSize .width - anchorX - frameMargin .right ) < width / 2 )
279- style .left = ` ${windowSize .width - anchorX - width / 2 - frameMargin .right }px `
282+ style .left = ` ${windowSize .width - anchorX - width / 2 - frameMargin .right - frameWidth . value / 2 }px `
280283 break
281284 case ' right' :
282285 case ' left' :
283- style .top = 0
284- style .transform = ' translate(0, -50% )'
286+ style .top = ` ${ - frameHeight . value / 2 }px `
287+ style .transform = ' translate(0, 0 )'
285288 if ((anchorY - frameMargin .top ) < height / 2 )
286- style .top = ` ${height / 2 - anchorY + frameMargin .top }px `
289+ style .top = ` ${height / 2 - anchorY + frameMargin .top - frameHeight . value / 2 }px `
287290 else if ((windowSize .height - anchorY - frameMargin .bottom ) < height / 2 )
288- style .top = ` ${windowSize .height - anchorY - height / 2 - frameMargin .bottom }px `
291+ style .top = ` ${windowSize .height - anchorY - height / 2 - frameMargin .bottom - frameHeight . value / 2 }px `
289292 break
290293 }
291294
@@ -398,12 +401,13 @@ onMounted(() => {
398401 </button >
399402 </template >
400403 </div >
401- <FrameBox
402- ref =" frameBox"
403- :client =" client"
404- :style =" iframeStyle"
405- :is-dragging =" isDragging"
406- />
404+
405+ <div ref =" frameBox" :style =" iframeStyle" >
406+ <FrameBox
407+ :client =" client"
408+ :is-dragging =" isDragging"
409+ />
410+ </div >
407411 </div >
408412</template >
409413
0 commit comments