+36
-1
src/Components/PhotoViewer.tsx
+36
-1
src/Components/PhotoViewer.tsx
···
150
})
151
}
152
153
onMount(() => {
154
utils.set(photoControls, { translateX: '-50%' });
155
utils.set(photoTrayCloseBtn, { translateX: '-50%', opacity: 0, scale: '0.75', bottom: '10px' });
156
utils.set(photoLayerManager, { translateY: '20px', opacity: 0, display: 'none' });
157
158
window.addEventListener('keyup', switchPhotoWithKey);
159
160
let contextMenuOpen = false;
161
window.CloseAllPopups.push(() => {
···
465
<img draggable="false" src="/icon/x-solid.svg"></img>
466
</div>
467
</div>
468
-
<img class="image-container" ref={( el ) => imageViewer = el} />
469
470
<div class="prev-button" onClick={() => {
471
window.CloseAllPopups.forEach(p => p());
···
150
})
151
}
152
153
+
let resizeImage = () => {
154
+
let dstWidth;
155
+
let dstHeight;
156
+
157
+
let imgHeight = imageViewer.height;
158
+
let imgWidth = imageViewer.width;
159
+
160
+
if(
161
+
imgWidth / window.innerWidth <
162
+
imgHeight / window.innerHeight
163
+
) {
164
+
dstWidth = imgWidth * (window.innerHeight / imgHeight);
165
+
dstHeight = window.innerHeight;
166
+
} else{
167
+
dstWidth = window.innerWidth;
168
+
dstHeight = imgHeight * (window.innerWidth / imgWidth);
169
+
}
170
+
171
+
imageViewer.style.width = dstWidth + 'px';
172
+
imageViewer.style.height = dstHeight + 'px';
173
+
}
174
+
175
onMount(() => {
176
utils.set(photoControls, { translateX: '-50%' });
177
utils.set(photoTrayCloseBtn, { translateX: '-50%', opacity: 0, scale: '0.75', bottom: '10px' });
178
utils.set(photoLayerManager, { translateY: '20px', opacity: 0, display: 'none' });
179
180
window.addEventListener('keyup', switchPhotoWithKey);
181
+
182
+
resizeImage();
183
+
184
+
window.addEventListener('resize', () => resizeImage());
185
186
let contextMenuOpen = false;
187
window.CloseAllPopups.push(() => {
···
491
<img draggable="false" src="/icon/x-solid.svg"></img>
492
</div>
493
</div>
494
+
495
+
<div style={{
496
+
width: '100%',
497
+
height: '100%',
498
+
display: 'flex',
499
+
"justify-content": 'center',
500
+
'align-items': 'center'
501
+
}}>
502
+
<img class="image-container" ref={( el ) => imageViewer = el} />
503
+
</div>
504
505
<div class="prev-button" onClick={() => {
506
window.CloseAllPopups.forEach(p => p());
+2
-1
src/css/viewer.css
+2
-1
src/css/viewer.css