Skip to content

Commit

Permalink
fix: StarportCraft margin caused errors in the coordinates (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
f820602h authored Sep 7, 2023
1 parent 79ca814 commit 2e713dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/StarportCraft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const StarportCraft = defineComponent({
height: `${rect.height}px`,
margin: rect.margin,
padding: rect.padding,
transform: `translate3d(${rect.left}px,${rect.top}px,0px)`,
transform: `translate3d(calc(${rect.left}px - ${rect.marginLeft}),calc(${rect.top}px - ${rect.marginTop}),0px)`,
}
if (!sp.value.isVisible || !sp.value.el) {
return {
Expand Down
6 changes: 5 additions & 1 deletion src/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function useElementBounding(
update,
listen,
pause,
marginTop: '0px',
marginLeft: '0px',
margin: '0px',
padding: '0px',
})
Expand All @@ -29,9 +31,11 @@ export function useElementBounding(
return
const { height, width, left, top } = el.getBoundingClientRect()
const domStyle = window.getComputedStyle(el)
const marginTop = domStyle.marginTop
const marginLeft = domStyle.marginLeft
const margin = domStyle.margin
const padding = domStyle.padding
Object.assign(rect, { height, width, left, top: root!.scrollTop + top, margin, padding })
Object.assign(rect, { height, width, left, top: root!.scrollTop + top, marginTop, marginLeft, margin, padding })
}
const raf = useRafFn(update, { immediate: false })

Expand Down

0 comments on commit 2e713dc

Please sign in to comment.