Skip to content

Commit 6285c65

Browse files
Attempted to Fix the Border Image Issue
1 parent d000ad5 commit 6285c65

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

public/map.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,38 @@ function animateToOffsets(targetOffsetX, targetOffsetY, duration = 300) {
189189

190190
// Show photo view after image loads
191191
function showPhotoView(photo) {
192+
const photoView = document.getElementById('photo-view');
192193
const imgElement = document.getElementById('photo-image');
193194
const img = new Image();
194195

195196
img.onload = () => {
196197
imgElement.src = photo.imageHighRes;
197198
document.body.classList.add('show-photo-view');
199+
if (photo.imageX == 0) {
200+
if (photo.imageY == 0) {
201+
photoView.style.transform = 'translate(0%, 0%)';
202+
photoView.style.top = '0%';
203+
photoView.style.left = '0%';
204+
} else {
205+
photoView.style.transform = 'translate(0%, -50%)';
206+
photoView.style.top = '50%';
207+
photoView.style.left = '0%';
208+
}
209+
} else if (photo.imageX == MAP_COLS - 1) {
210+
if (photo.imageY == MAP_ROWS - 1) {
211+
photoView.style.transform = 'translate(-100%, -100%)';
212+
photoView.style.top = '100%';
213+
photoView.style.left = '100%';
214+
} else {
215+
photoView.style.transform = 'translate(-50%, -100%)';
216+
photoView.style.top = '50%';
217+
photoView.style.left = '100%';
218+
}
219+
} else {
220+
photoView.style.transform = 'translate(-50%, -50%)';
221+
photoView.style.top = '50%';
222+
photoView.style.left = '50%';
223+
}
198224
};
199225

200226
img.onerror = () => {

views/main.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<body>
3333
<canvas id="mapCanvas" width="450" height="540"></canvas>
3434
<div class="title">PIXEL BY PIXEL<br />NYC</div>
35-
<div class="photo-view">
35+
<div class="photo-view" id="photo-view">
3636
<img class="photo-image" id="photo-image" src="" alt="Photo" />
3737
</div>
3838
<div class="pixel-close-button" id="pixel-close-button">

0 commit comments

Comments
 (0)