Skip to content

Commit c45c9aa

Browse files
chore: improve panel position
1 parent 4f95995 commit c45c9aa

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

entrypoints/injected/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { motion, useDragControls } from 'framer-motion'
22
import { useEffect, useRef, useState } from 'react'
33

4+
import { roundTranslateValues } from '../utils/style'
45
import { CodeArea } from './components/Code'
56
import { Colors } from './components/Colors'
67
import { Download } from './components/Download'
@@ -33,8 +34,12 @@ export default () => {
3334
dragPropagation={false}
3435
dragListener={false}
3536
dragControls={controls}
36-
className={`fixed top-10 right-20 text-xs text-$color-text bg-$color-bg rounded border-1 border-$color-border border-solid shadow-md z-10 antialiased h-auto transition-width !font-['Inter'] js-fullscreen-prevent-event-capture ${minimized ? 'w-50' : 'w-80'} max-h-[calc(100vh-50px)] overflow-y-scroll scrollbar-hide select-none`}
37+
className={`fubukicss-panel fixed top-10 right-20 text-xs text-$color-text bg-$color-bg rounded border-1 border-$color-border border-solid shadow-md z-10 antialiased h-auto transition-width !font-['Inter'] js-fullscreen-prevent-event-capture ${minimized ? 'w-50' : 'w-80'} max-h-[calc(100vh-50px)] overflow-y-scroll scrollbar-hide select-none`}
3738
tabIndex={-1}
39+
onDragEnd={() => {
40+
const dom = document.querySelector('.fubukicss-panel') as HTMLDivElement
41+
roundTranslateValues(dom)
42+
}}
3843
>
3944
<Header startDrag={startDrag} ref={header} minimized={minimized} onToggleSize={handleToggleSize} />
4045
<CodeArea minimized={minimized} />

entrypoints/utils/style.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export function roundTranslateValues(element: HTMLDivElement) {
2+
const transform = element.style.transform
3+
if (!transform) return
4+
5+
const newTransform = transform.replace(
6+
/(translate[XY])\s*\(\s*(-?\d+\.?\d*)/g,
7+
(_, prop, value) => `${prop}(${Math.round(parseFloat(value))}`,
8+
)
9+
10+
if (newTransform !== transform) {
11+
element.style.transform = newTransform
12+
}
13+
}

0 commit comments

Comments
 (0)