mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
fix #204
This commit is contained in:
parent
1c4818cf1d
commit
a9a27133b9
@ -44,8 +44,8 @@ export class ImageHandle {
|
|||||||
async scale(maxDimension) {
|
async scale(maxDimension) {
|
||||||
const aspectRatio = this.width / this.height;
|
const aspectRatio = this.width / this.height;
|
||||||
const scaleFactor = Math.min(1, maxDimension / (aspectRatio >= 1 ? this.width : this.height));
|
const scaleFactor = Math.min(1, maxDimension / (aspectRatio >= 1 ? this.width : this.height));
|
||||||
const scaledWidth = this.width * scaleFactor;
|
const scaledWidth = Math.round(this.width * scaleFactor);
|
||||||
const scaledHeight = this.height * scaleFactor;
|
const scaledHeight = Math.round(this.height * scaleFactor);
|
||||||
|
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
canvas.width = scaledWidth;
|
canvas.width = scaledWidth;
|
||||||
|
Loading…
Reference in New Issue
Block a user