11// @flow
22
33import React , { useState , useEffect , useMemo } from "react"
4-
5- export default ( { imageData, maskVersion, opacity = 0.5 } ) => {
4+ // videoPlaying={videoPlaying}
5+ // imagePosition={imagePosition}
6+ // mouse-events -> none
7+ export default ( { imageData, imagePosition, videoPlaying, maskVersion, opacity = 0.5 , zIndex = 999 , position = 'absolute' } ) => {
68 const [ canvasRef , setCanvasRef ] = useState ( null )
79
810 useEffect ( ( ) => {
@@ -11,7 +13,25 @@ export default ({ imageData, maskVersion, opacity = 0.5 }) => {
1113 context . putImageData ( imageData , 0 , 0 )
1214 } , [ canvasRef , imageData , maskVersion ] )
1315
14- const style = useMemo ( ( ) => ( { opacity } ) , [ opacity ] )
16+ const style = useMemo ( ( ) => {
17+ let width = imagePosition . bottomRight . x - imagePosition . topLeft . x
18+ let height = imagePosition . bottomRight . y - imagePosition . topLeft . y
19+ return {
20+ left : imagePosition . topLeft . x ,
21+ top : imagePosition . topLeft . y ,
22+ width : isNaN ( width ) ? 0 : width ,
23+ height : isNaN ( height ) ? 0 : height ,
24+ zIndex,
25+ position
26+ }
27+ } , [
28+ imagePosition . topLeft . x ,
29+ imagePosition . topLeft . y ,
30+ imagePosition . bottomRight . x ,
31+ imagePosition . bottomRight . y ,
32+ zIndex ,
33+ position
34+ ] )
1535
1636 return (
1737 < canvas
0 commit comments