2424// inline styles regardless of render timing, avoiding the race condition that
2525// JS-based inline overrides suffer from.
2626//
27- // The 960px threshold covers all current phones including large flagships in
28- // landscape (e.g. iPhone 16 Pro Max: 932px, Galaxy S24 Ultra: 915px) while
29- // excluding tablets (iPad mini landscape: 1024px). The resize listener ensures
30- // the fix is applied/removed correctly on orientation change.
27+ // Device targeting uses `pointer: coarse` (touchscreens) rather than a pixel
28+ // width threshold. A width-only check (e.g. <= 960px) also triggers on narrow
29+ // desktop windows; pointer coarseness correctly identifies touch devices
30+ // regardless of window size, and CSS media queries re-evaluate automatically on
31+ // any relevant change — no JS resize listener needed.
3132
3233var _imagesStyleTag = null ;
3334
3435// Uses !important throughout so these rules win over react-photo-gallery's
3536// inline `style="position:absolute; top:Xpx; left:Ypx"` attributes.
37+ // Wrapped in a pointer:coarse media query so the rules are inert on desktop.
3638var _IMAGES_CSS = [
37- 'div.react-photo-gallery--gallery {' ,
38- ' display: block !important;' ,
39- '}' ,
40- '.wall-item {' ,
41- ' position: relative !important;' , /* pull items back into normal flow */
42- ' width: 100% !important;' ,
43- ' height: auto !important;' ,
44- ' top: auto !important;' , /* neutralise calculated pixel offsets */
45- ' left: auto !important;' ,
46- ' display: block !important;' ,
47- ' margin-bottom: 10px !important;' ,
48- '}' ,
49- '.wall-item img, .wall-item video {' ,
50- ' width: 100% !important;' ,
51- ' height: auto !important;' ,
52- ' object-fit: contain !important;' ,
39+ '@media (pointer: coarse) {' ,
40+ ' div.react-photo-gallery--gallery {' ,
41+ ' display: block !important;' ,
42+ ' }' ,
43+ ' .wall-item {' ,
44+ ' position: relative !important;' , /* pull items back into normal flow */
45+ ' width: 100% !important;' ,
46+ ' height: auto !important;' ,
47+ ' top: auto !important;' , /* neutralise calculated pixel offsets */
48+ ' left: auto !important;' ,
49+ ' display: block !important;' ,
50+ ' margin-bottom: 10px !important;' ,
51+ ' }' ,
52+ ' .wall-item img, .wall-item video {' ,
53+ ' width: 100% !important;' ,
54+ ' height: auto !important;' ,
55+ ' object-fit: contain !important;' ,
56+ ' }' ,
5357 '}'
5458] . join ( '\n' ) ;
5559
5660function updateImagesPageFix ( ) {
5761 var href = window . location . href ;
58- var onTargetPage = ( href . includes ( '/images' ) || href . includes ( 'scenes/markers' ) )
59- && window . innerWidth <= 960 ;
62+ var onTargetPage = href . includes ( '/images' ) || href . includes ( 'scenes/markers' ) ;
6063
6164 if ( onTargetPage && ! _imagesStyleTag ) {
6265 // Entering images or markers page — inject the fix
@@ -79,8 +82,5 @@ function updateImagesPageFix() {
7982var observer = new MutationObserver ( updateImagesPageFix ) ;
8083observer . observe ( document . body , { childList : true , subtree : true } ) ;
8184
82- // Re-evaluate on orientation change (portrait ↔ landscape)
83- window . addEventListener ( 'resize' , updateImagesPageFix ) ;
84-
8585// Run immediately for whichever page is loaded first
8686updateImagesPageFix ( ) ;
0 commit comments