I have a feed that I follow (https://spacebiff.com) where there are images in each article that have helpful/humorous alt text while also being wrapped in a link (the image in the RSS feed is compressed, so it is sometimes helpful to view the full image to see details). On iOS, the first two times I tap the image it opens in the in-app web view. The third time I tap, it opens the native image viewer to show the alt text. Three taps seemed a bit odd to me, maybe a bug.
I ran this question through Claude Code and gave me the following:
In main_ios.js, the click handler is registered on window:
window.onclick = function(event) {
if (event.target.matches("img") && !event.target.classList.contains("nnw-nozoom")) {
if (activeImageViewer && activeImageViewer.img === event.target) {
cancelImageLoad();
} else {
cancelImageLoad();
activeImageViewer = new ImageViewer(event.target);
activeImageViewer.clicked();
}
}
}
The click event bubbles up through the DOM: img → <a> → ... → window. By the time the window handler runs, the anchor tag has already "seen" the click. Without event.preventDefault(), WebKit proceeds with navigating to the anchor's href. Since there's no event.preventDefault() anywhere, every tap on an anchored image also triggers link navigation.
Why specifically 3 taps?
Tap 1: Image not yet loaded (nnwLoaded class not present yet) → clicked() starts a 100ms polling interval to wait for load, but never sends imageWasClicked. Click propagates → anchor navigation fires → in-app web view opens.
Tap 2: activeImageViewer is still set from tap 1 (still polling). activeImageViewer.img === event.target is true, so it hits the cancel branch (cancelImageLoad() → sets activeImageViewer = null). Still no imageWasClicked. Click propagates → anchor → in-app web view again.
Tap 3: activeImageViewer is now null (cancelled on tap 2). Creates a new ImageViewer. By now the image has loaded (it finished loading in the background). isLoaded() is true → showViewer() fires → imageWasClicked sent to Swift → native image viewer appears. The anchor navigation also fires, but the image viewer presentation wins from the user's perspective.
Hopefully that's helpful. I don't have a product opinion on whether to prioritize the native image view or a link, but it would be great to have the alternate behavior be one tap away instead of two. Thanks!
I have a feed that I follow (https://spacebiff.com) where there are images in each article that have helpful/humorous alt text while also being wrapped in a link (the image in the RSS feed is compressed, so it is sometimes helpful to view the full image to see details). On iOS, the first two times I tap the image it opens in the in-app web view. The third time I tap, it opens the native image viewer to show the alt text. Three taps seemed a bit odd to me, maybe a bug.
I ran this question through Claude Code and gave me the following:
Hopefully that's helpful. I don't have a product opinion on whether to prioritize the native image view or a link, but it would be great to have the alternate behavior be one tap away instead of two. Thanks!