fix: floating tool created outside the window when it was on the edge (#222)

This commit is contained in:
josc146
2023-04-21 22:48:52 +08:00
parent 3658d123e0
commit 79f05056d1
2 changed files with 25 additions and 21 deletions
+10 -1
View File
@@ -23,7 +23,16 @@ function FloatingToolbar(props) {
const windowSize = useClampWindowSize([750, 1500], [0, Infinity])
const config = useConfig(() => {
setRender(true)
if (!triggered) props.container.style.position = 'absolute'
if (!triggered) {
props.container.style.position = 'absolute'
setTimeout(() => {
const left = Math.min(
Math.max(0, window.innerWidth - props.container.offsetWidth - 30),
Math.max(0, position.x),
)
props.container.style.left = left + 'px'
})
}
})
useEffect(() => {