Skip to content

fix: StarportCraft margin caused errors in the coordinates #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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