forked from external-repos/squoosh
Compare commits
1 Commits
android-ta
...
pointer-tr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
008bae62da |
@@ -54,5 +54,4 @@ $horizontalPadding: 15px;
|
||||
.options-scroller {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
@@ -177,17 +177,6 @@ export default class Output extends Component<Props, State> {
|
||||
const clonedEvent = new (event.constructor as typeof Event)(event.type, event);
|
||||
this.retargetedEvents.add(clonedEvent);
|
||||
this.pinchZoomLeft.dispatchEvent(clonedEvent);
|
||||
|
||||
// Unfocus any active element on touchend. This fixes an issue on (at least) Android Chrome,
|
||||
// where the software keyboard is hidden, but the input remains focused, then after interaction
|
||||
// with this element the keyboard reappears for NO GOOD REASON. Thanks Android.
|
||||
if (
|
||||
event.type === 'touchend' &&
|
||||
document.activeElement &&
|
||||
document.activeElement instanceof HTMLElement
|
||||
) {
|
||||
document.activeElement.blur();
|
||||
}
|
||||
}
|
||||
|
||||
render(
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
}
|
||||
|
||||
@media (min-width: 860px) {
|
||||
max-height: calc(100% - 40px);
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
}
|
||||
|
||||
.intro {
|
||||
composes: abs-fill from '../../lib/util.scss';
|
||||
display: grid;
|
||||
grid-template-rows: 1fr min-content;
|
||||
align-items: center;
|
||||
@@ -28,9 +29,6 @@
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow: auto;
|
||||
padding: 20px 0 0;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
|
||||
@@ -57,32 +57,16 @@ export async function canvasEncode(data: ImageData, type: string, quality?: numb
|
||||
return blob;
|
||||
}
|
||||
|
||||
async function decodeImage(url: string): Promise<HTMLImageElement> {
|
||||
const img = new Image();
|
||||
img.decoding = 'async';
|
||||
img.src = url;
|
||||
const loaded = new Promise((resolve, reject) => {
|
||||
img.onload = () => resolve();
|
||||
img.onerror = () => reject(Error('Image loading error'));
|
||||
});
|
||||
|
||||
if (img.decode) {
|
||||
// Nice off-thread way supported in Safari/Chrome.
|
||||
// Safari throws on decode if the source is SVG.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=188347
|
||||
await img.decode().catch(() => null);
|
||||
}
|
||||
|
||||
// Always await loaded, as we may have bailed due to the Safari bug above.
|
||||
await loaded;
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to load the given URL as an image.
|
||||
*/
|
||||
export function canDecodeImage(url: string): Promise<boolean> {
|
||||
return decodeImage(url).then(() => true, () => false);
|
||||
export function canDecodeImage(data: string): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
const img = document.createElement('img');
|
||||
img.src = data;
|
||||
img.onload = _ => resolve(true);
|
||||
img.onerror = _ => resolve(false);
|
||||
});
|
||||
}
|
||||
|
||||
export function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer> {
|
||||
@@ -124,7 +108,24 @@ export async function blobToImg(blob: Blob): Promise<HTMLImageElement> {
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
try {
|
||||
return await decodeImage(url);
|
||||
const img = new Image();
|
||||
img.decoding = 'async';
|
||||
img.src = url;
|
||||
const loaded = new Promise((resolve, reject) => {
|
||||
img.onload = () => resolve();
|
||||
img.onerror = () => reject(Error('Image loading error'));
|
||||
});
|
||||
|
||||
if (img.decode) {
|
||||
// Nice off-thread way supported in Safari/Chrome.
|
||||
// Safari throws on decode if the source is SVG.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=188347
|
||||
await img.decode().catch(() => null);
|
||||
}
|
||||
|
||||
// Always await loaded, as we may have bailed due to the Safari bug above.
|
||||
await loaded;
|
||||
return img;
|
||||
} finally {
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font: 12px/1.3 system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, sans-serif;
|
||||
|
||||
Reference in New Issue
Block a user