Skip to content

Commit 40fca21

Browse files
committed
fix: image default size
1 parent a8c6a8f commit 40fca21

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "photolisting",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"main": "main.js",
55
"scripts": {
66
"vite-dev": "cross-env NODE_ENV=dev vite",

src/components/Lightbox.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div
3-
class="absolute left-0 top-0 z-20 flex h-full w-screen items-center justify-center overflow-hidden p-5 transition-all"
3+
class="absolute left-0 top-0 z-20 flex h-full min-h-0 w-screen items-center justify-center overflow-hidden p-5 transition-all"
44
:class="formOpen ? '' : 'pointer-events-none opacity-0'"
55
tabindex="0"
66
v-focus="formOpen"
@@ -19,7 +19,7 @@
1919
ref="img"
2020
:src="src"
2121
class="z-10 flex-col overflow-hidden shadow-md transition-all"
22-
:class="formOpen ? '' : 'scale-0'"
22+
:class="[formOpen ? '' : 'scale-0', widthFirst ? 'w-full' : 'h-full']"
2323
:style="{
2424
transform: `scale(${scale}, ${scale}) translate(${movement.x}px, ${movement.y}px)`,
2525
}"
@@ -54,6 +54,7 @@ export default {
5454
x: 0,
5555
y: 0,
5656
},
57+
widthFirst: true,
5758
};
5859
},
5960
mounted() {
@@ -64,14 +65,18 @@ export default {
6465
let src = "";
6566
6667
if (this.index >= 0 && this.index < this.files.length) {
67-
src = this.files[this.index].url;
68+
const f = this.files[this.index];
69+
src = f.url;
70+
71+
console.log(f.height, f.width);
72+
this.widthFirst = f.width >= f.height;
6873
6974
var fr = new FileReader();
7075
fr.onload = () => {
7176
// console.log(fr);
7277
this.src = fr.result;
7378
};
74-
fr.readAsDataURL(this.files[this.index].raw);
79+
fr.readAsDataURL(f.raw);
7580
}
7681
7782
this.src = src;

0 commit comments

Comments
 (0)