forked from sleepy-zone/fabritor-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff47437
commit 1ef3a8d
Showing
4 changed files
with
97 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { GloablStateContext } from '@/context'; | ||
import { useState, useContext, useEffect } from 'react'; | ||
|
||
function ObjectRotateAngleTip () { | ||
const [pos, setPos] = useState({ left: 0, top: 0 }); | ||
const [content, setContent] = useState(''); | ||
const [open, setOpen] = useState(false); | ||
const { editor } = useContext(GloablStateContext); | ||
|
||
const rotateHandler = (opt) => { | ||
const { target, e } = opt; | ||
setPos({ | ||
left: e.pageX + 16, | ||
top: e.pageY | ||
}); | ||
setContent(`${Math.round(target.angle)}°`); | ||
setOpen(true); | ||
} | ||
|
||
const mouseupHandler = () => { | ||
setOpen(false); | ||
} | ||
|
||
useEffect(() => { | ||
if (editor) { | ||
editor.canvas.on('object:rotating', rotateHandler); | ||
editor.canvas.on('mouse:up', mouseupHandler); | ||
} | ||
}, [editor]); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
fontSize: 12, | ||
position: 'fixed', | ||
zIndex: 9999, | ||
width: 'max-content', | ||
display: open ? 'block' : 'none', | ||
...pos | ||
}} | ||
> | ||
<div | ||
style={{ | ||
padding: '6px 6px', | ||
color: '#fff', | ||
backgroundColor: 'rgba(0, 0, 0, 0.85)', | ||
borderRadius: 6 | ||
}} | ||
role="tooltip" | ||
> | ||
{content} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ObjectRotateAngleTip; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters