Compare commits

...

6 Commits

Author SHA1 Message Date
fd98d67b3e lol this was meant to be 10 seconds. 2018-12-07 14:26:45 +00:00
db1db8506e Move early exit for no-rotation. 2018-12-07 14:26:22 +00:00
7389c507fb 1.2.2 2018-12-04 10:57:07 +00:00
68f0f23016 Prevent image becoming misshapen on resize. Fixes #359. (#360) 2018-12-04 10:55:32 +00:00
dc809dde30 1.2.1 2018-11-30 11:44:33 +00:00
80dfa03b94 Avoid wrapping a single button (#357)
* Avoid wrapping a single button

* Making the zoom controls appear on the bottom, when the controls are positioned on the bottom
2018-11-30 11:44:15 +00:00
7 changed files with 38 additions and 22 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "squoosh",
"version": "1.2.0",
"version": "1.2.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,7 +1,7 @@
{
"private": true,
"name": "squoosh",
"version": "1.2.0",
"version": "1.2.2",
"license": "apache-2.0",
"scripts": {
"start": "webpack-dev-server --host 0.0.0.0 --hot",

View File

@ -20,7 +20,7 @@ import * as browserPDF from './browser-pdf/encoder';
type ProcessorWorkerApi = import('./processor-worker').ProcessorWorkerApi;
/** How long the worker should be idle before terminating. */
const workerTimeout = 1000;
const workerTimeout = 10000;
interface ProcessingJobOptions {
needsWorker?: boolean;

View File

@ -4,10 +4,6 @@ const bpp = 4;
export function rotate(data: ImageData, opts: RotateOptions): ImageData {
const { rotate } = opts;
// Early exit if there's no transform.
if (rotate === 0) return data;
const flipDimensions = rotate % 180 !== 0;
const { width: inputWidth, height: inputHeight } = data;
const outputWidth = flipDimensions ? inputHeight : inputWidth;

View File

@ -336,19 +336,21 @@ export default class Output extends Component<Props, State> {
<AddIcon />
</button>
</div>
<button class={style.button} onClick={this.onRotateClick} title="Rotate image">
<RotateIcon />
</button>
<button
class={`${style.button} ${altBackground ? style.active : ''}`}
onClick={this.toggleBackground}
title="Change canvas color"
>
{altBackground
? <ToggleBackgroundActiveIcon />
: <ToggleBackgroundIcon />
}
</button>
<div class={style.buttonsNoWrap}>
<button class={style.button} onClick={this.onRotateClick} title="Rotate image">
<RotateIcon />
</button>
<button
class={`${style.button} ${altBackground ? style.active : ''}`}
onClick={this.toggleBackground}
title="Change canvas color"
>
{altBackground
? <ToggleBackgroundActiveIcon />
: <ToggleBackgroundIcon />
}
</button>
</div>
</div>
</div>
);

View File

@ -36,6 +36,8 @@
// We should try to remove this once the issue is fixed.
// https://bugs.chromium.org/p/chromium/issues/detail?id=870222#c10
will-change: auto;
// Prevent the image becoming misshapen due to default flexbox layout.
flex-shrink: 0;
}
.controls {
@ -62,6 +64,7 @@
left: 320px;
right: 320px;
bottom: 0;
flex-wrap: wrap-reverse;
}
}
@ -152,3 +155,12 @@
left: 0;
padding: 9px;
}
.buttons-no-wrap {
display: flex;
pointer-events: none;
& > * {
pointer-events: auto;
}
}

View File

@ -85,12 +85,18 @@ interface UpdateImageOptions {
skipPreprocessing?: boolean;
}
function processInput(
async function processInput(
data: ImageData,
inputProcessData: InputProcessorState,
processor: Processor,
) {
return processor.rotate(data, inputProcessData.rotate);
let processedData = data;
if (inputProcessData.rotate.rotate !== 0) {
processedData = await processor.rotate(processedData, inputProcessData.rotate);
}
return processedData;
}
async function preprocessImage(