File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { motion , useDragControls } from 'framer-motion'
2
2
import { useEffect , useRef , useState } from 'react'
3
3
4
+ import { roundTranslateValues } from '../utils/style'
4
5
import { CodeArea } from './components/Code'
5
6
import { Colors } from './components/Colors'
6
7
import { Download } from './components/Download'
@@ -33,8 +34,12 @@ export default () => {
33
34
dragPropagation = { false }
34
35
dragListener = { false }
35
36
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` }
37
38
tabIndex = { - 1 }
39
+ onDragEnd = { ( ) => {
40
+ const dom = document . querySelector ( '.fubukicss-panel' ) as HTMLDivElement
41
+ roundTranslateValues ( dom )
42
+ } }
38
43
>
39
44
< Header startDrag = { startDrag } ref = { header } minimized = { minimized } onToggleSize = { handleToggleSize } />
40
45
< CodeArea minimized = { minimized } />
Original file line number Diff line number Diff line change
1
+ export function roundTranslateValues ( element : HTMLDivElement ) {
2
+ const transform = element . style . transform
3
+ if ( ! transform ) return
4
+
5
+ const newTransform = transform . replace (
6
+ / ( t r a n s l a t e [ X Y ] ) \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
+ }
You can’t perform that action at this time.
0 commit comments