Skip to content

Commit 9003679

Browse files
committed
Fix interactive image on mobile
1 parent 5a2efec commit 9003679

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

_includes/interactive_image.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,13 @@
125125
}
126126
});
127127

128-
// Basic touch support: tap and hold shows clickImg, release shows defaultImg
128+
// Basic touch support: tap and hold shows hoverImg, release shows defaultImg
129129
// This is a simplified interaction for touch.
130-
let touchTimeout;
131130
container.addEventListener('touchstart', (event) => {
132131
event.preventDefault(); // Important to prevent scrolling while interacting
133132
isMouseDown = true; // Use same flag for conceptual "pressed" state
134-
if (hoverImg) hoverImg.style.opacity = '0'; // No hover on touch usually
135-
if (clickImg) clickImg.style.opacity = '1';
133+
if (hoverImg) hoverImg.style.opacity = '1';
134+
if (clickImg) clickImg.style.opacity = '0';
136135
}, { passive: false }); // Need passive:false for preventDefault to work on touchstart
137136

138137
container.addEventListener('touchend', () => {

_sass/interactive_image.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
display: inline-block; // Or 'block' if you want it to take full width
4040
cursor: pointer; // Indicate it's interactive
4141
line-height: 0; // Prevent extra space below inline-block images if any
42+
-webkit-touch-callout: none; // iOS Safari
43+
user-select: none; // Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox
4244

4345
// Ensure the container takes the size of the default image
4446
// and other images overlay it.

0 commit comments

Comments
 (0)