From dbd80f15ebbc7fff7d8346cea42593e8b9630faa Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Wed, 9 Dec 2020 11:49:03 -0500 Subject: [PATCH] Fix cropbox background when zoomed --- .../Compress/Transform/Cropper/index.tsx | 113 ++---------------- 1 file changed, 12 insertions(+), 101 deletions(-) diff --git a/src/client/lazy-app/Compress/Transform/Cropper/index.tsx b/src/client/lazy-app/Compress/Transform/Cropper/index.tsx index a50eae86..229108cd 100644 --- a/src/client/lazy-app/Compress/Transform/Cropper/index.tsx +++ b/src/client/lazy-app/Compress/Transform/Cropper/index.tsx @@ -83,10 +83,6 @@ export default class Cropper extends Component { ) { return; } - // crop.left = Math.max(0, crop.left) | 0; - // crop.top = Math.max(0, crop.top) | 0; - // crop.right = Math.max(0, crop.right) | 0; - // crop.bottom = Math.max(0, crop.bottom) | 0; this.setState({ crop }); if (this.props.onChange) { this.props.onChange(crop); @@ -261,10 +257,14 @@ export default class Cropper extends Component { const y = crop.top; const width = size.width - crop.left - crop.right; const height = size.height - crop.top - crop.bottom; - // const x = crop.left.toFixed(2); - // const y = crop.top.toFixed(2); - // const width = (size.width - crop.left - crop.right).toFixed(2); - // const height = (size.height - crop.top - crop.bottom).toFixed(2); + + const s = (x: number) => x / (scale || 1); + + const clip = `polygon(0 0, 0 100%, 100% 100%, 100% 0, 0 0, ${s(x)}px ${s( + y, + )}px, ${s(x + width)}px ${s(y)}px, ${s(x + width)}px ${s( + y + height, + )}px, ${s(x)}px ${s(y + height)}px, ${s(x)}px ${s(y)}px)`; return ( { onPointerMove={this.onPointerMove} onPointerUp={this.onPointerUp} > - - {/* - - - - */} - {/* - - - - - - - */} - @@ -328,7 +294,6 @@ export default class Cropper extends Component { data-edge="left,right,top,bottom" width="100%" height="100%" - // filter="url(#shadow2)" /> @@ -336,71 +301,17 @@ export default class Cropper extends Component { - - + + - + - {/* - - - - - - */} ); }