From e8c0ddfc7fd4de7f7db802b2095239d6382ad41c Mon Sep 17 00:00:00 2001 From: Surma Date: Tue, 31 Jul 2018 12:41:02 +0100 Subject: [PATCH] Remove lambda from JSX --- src/codecs/imagequant/options.tsx | 1 + src/components/Options/index.tsx | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/codecs/imagequant/options.tsx b/src/codecs/imagequant/options.tsx index 5ea1c0fd..7dc2cb6f 100644 --- a/src/codecs/imagequant/options.tsx +++ b/src/codecs/imagequant/options.tsx @@ -48,6 +48,7 @@ export default class QuantizerOptions extends Component { type="range" min="0" max="1" + step="0.01" value={'' + options.dither} onChange={this.onChange} /> diff --git a/src/components/Options/index.tsx b/src/components/Options/index.tsx index 7ddf5427..22a0f42f 100644 --- a/src/components/Options/index.tsx +++ b/src/components/Options/index.tsx @@ -6,7 +6,7 @@ import BrowserJPEGEncoderOptions from '../../codecs/browser-jpeg/options'; import WebPEncoderOptions from '../../codecs/webp/options'; import BrowserWebPEncoderOptions from '../../codecs/browser-webp/options'; -import QuantizerOptions from '../../codecs/imagequant/options'; +import QuantizerOptionsComponent from '../../codecs/imagequant/options'; import * as identity from '../../codecs/identity/encoder'; import * as mozJPEG from '../../codecs/mozjpeg/encoder'; @@ -28,6 +28,7 @@ import { EncoderSupportMap, PreprocessorState, } from '../../codecs/encoders'; +import { QuantizeOptions } from '../../codecs/imagequant/quantizer'; const encoderOptionsComponentMap = { [identity.type]: undefined, @@ -85,6 +86,17 @@ export default class Options extends Component { this.props.onPreprocessorOptionsChange(preprocessorState); } + @bind + onQuantizerOptionsChange(opts: QuantizeOptions) { + this.props.onPreprocessorOptionsChange({ + ...this.props.preprocessorState, + quantizer: { + ...opts, + enabled: this.props.preprocessorState.quantizer.enabled, + }, + }); + } + render( { class: className, encoderState, preprocessorState, onEncoderOptionsChange }: Props, { encoderSupportMap }: State, @@ -105,16 +117,9 @@ export default class Options extends Component { Enable {preprocessorState.quantizer.enabled ? ( - this.props.onPreprocessorOptionsChange({ - ...preprocessorState, - quantizer: { - ...quantizeOpts, - enabled: preprocessorState.quantizer.enabled, - }, - })} + onChange={this.onQuantizerOptionsChange} /> ) : (