From 213028cfddc18f9154cfc7660acd4b83d820c254 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Wed, 9 Dec 2020 11:48:10 -0500 Subject: [PATCH 1/8] Changing crop updates and disables resize processor --- src/client/lazy-app/Compress/index.tsx | 45 +++++++++++++++++--------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/client/lazy-app/Compress/index.tsx b/src/client/lazy-app/Compress/index.tsx index 455c7b3e..cb852f5b 100644 --- a/src/client/lazy-app/Compress/index.tsx +++ b/src/client/lazy-app/Compress/index.tsx @@ -11,6 +11,7 @@ import { canDecodeImageType, abortable, assertSignal, + shallowEqual, } from '../util'; import { PreprocessorState, @@ -447,25 +448,39 @@ export default class Compress extends Component { const newRotate = preprocessorState.rotate.rotate; const orientationChanged = oldRotate % 180 !== newRotate % 180; + const { crop } = preprocessorState; + const cropChanged = !shallowEqual(crop, this.state.preprocessorState.crop); + this.setState((state) => ({ loading: true, preprocessorState, // Flip resize values if orientation has changed - sides: !orientationChanged - ? state.sides - : (state.sides.map((side) => { - const currentResizeSettings = - side.latestSettings.processorState.resize; - const resizeSettings: Partial = { - width: currentResizeSettings.height, - height: currentResizeSettings.width, - }; - return cleanMerge( - side, - 'latestSettings.processorState.resize', - resizeSettings, - ); - }) as [Side, Side]), + sides: + !orientationChanged && !cropChanged + ? state.sides + : (state.sides.map((side) => { + const currentResizeSettings = + side.latestSettings.processorState.resize; + let resizeSettings: Partial; + if (cropChanged) { + const img = state.source?.decoded; + resizeSettings = { + enabled: false, + width: img ? img.width - crop.left - crop.right : undefined, + height: img ? img.height - crop.top - crop.bottom : undefined, + }; + } else { + resizeSettings = { + width: currentResizeSettings.height, + height: currentResizeSettings.width, + }; + } + return cleanMerge( + side, + 'latestSettings.processorState.resize', + resizeSettings, + ); + }) as [Side, Side]), })); }; From ed3c79894dc3f416033455982ae5587b1b8f99d6 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Wed, 9 Dec 2020 11:48:28 -0500 Subject: [PATCH 2/8] Remove "Retina" zoom preset --- src/client/lazy-app/Compress/Output/index.tsx | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/client/lazy-app/Compress/Output/index.tsx b/src/client/lazy-app/Compress/Output/index.tsx index 1201edfd..48efd24a 100644 --- a/src/client/lazy-app/Compress/Output/index.tsx +++ b/src/client/lazy-app/Compress/Output/index.tsx @@ -178,12 +178,6 @@ export default class Output extends Component { // this.hideMenu(); }; - private zoomTo2x = () => { - if (!this.pinchZoomLeft) throw Error('Missing pinch-zoom element'); - this.pinchZoomLeft.scaleTo(0.5, scaleToOpts); - this.recenter(); - }; - private recenter = () => { const img = this.props.source?.preprocessed; if (!img || !this.pinchZoomLeft) return; @@ -342,10 +336,7 @@ export default class Output extends Component { -