Tagged: easy slider swipe
-
AuthorPosts
-
December 14, 2025 at 7:02 pm #1492503
On this page that I created with your very useful help, swiping on mobile devices changes the image, making it out-of-sync with the selected item in the ingredients list. How can I block user swiping? I cannot disable the Easy Slider navigation controls (set it to no user interaction) because the item selection code in the ingredient list needs them to display the corresponding image.
Best regards,
Serge FromentDecember 14, 2025 at 8:57 pm #1492504Hey photographie-tous-azimuts,
Try adding this css:/* Disable touch/swipe on mobile */ @media (max-width: 768px) { .slider-container, .slider-container * { touch-action: none !important; -webkit-user-drag: none !important; user-select: none !important; } }Then clear your cache and check. Unfortunately I can not test this on my end as desktop browser doesn’t show the swipe action, but this will likely work.
If you are using a iPhone you may need to clear the history to fully clear the cache.Best regards,
MikeDecember 14, 2025 at 8:59 pm #1492505Hi,
Or try this css:/* Disable touch/swipe on mobile */ @media (max-width: 768px) { .avia-slideshow, .avia-slideshow * { touch-action: none !important; -webkit-user-drag: none !important; user-select: none !important; } }Best regards,
MikeDecember 15, 2025 at 12:44 am #1492507Hi,
I tried both to no avail. I did use (max-width: 1024px) to include iPad. I cleared the cache on Safari and also used Brave browser, which I never used for that web site on that device.
Best regards,
SergeDecember 15, 2025 at 10:02 pm #1492544Hi,
Thanks for the feedback, I can only test on a Android device, but will need an admin login to apply the code and then test on my device.
Please add the admin login in the private comment below.Best regards,
MikeDecember 16, 2025 at 1:34 am #1492546Here it is.
December 16, 2025 at 9:34 pm #1492578Hi,
Thanks, I added this script to your child theme functions.php file:function remove_slideshow_swipe_script() { ?> <script> document.addEventListener('DOMContentLoaded', function() { if (window.innerWidth <= 768) { var slideshow = document.querySelector('.avia-slideshow'); if (slideshow) { slideshow.style.touchAction = 'none'; ['touchstart', 'touchmove', 'touchend'].forEach(function(event) { slideshow.addEventListener(event, function(e) { e.preventDefault(); e.stopImmediatePropagation(); }, {passive: false, capture: true}); }); } } }); </script> <?php } add_action( 'wp_footer', 'remove_slideshow_swipe_script', 99 );and it is working for my Android device, with the other script still working, as before if you are using a iPhone you may need to clear the history to fully clear the cache.
Best regards,
MikeDecember 16, 2025 at 11:14 pm #1492579Hi,
It does works, but it prevents scrolling the page when touching the image. Not a major problem, but it feels a bit strange (like Google Maps that zooms in/out when we try to scroll). Since the same swiping problem occurs on iPad too, it is more likely someone will try to scroll the page from the (larger) image there.
Maybe we should do it the other way around: allow swiping and update the selected ingredient when that happens.
Best regards,
SergeDecember 17, 2025 at 7:59 am #1492586Hi,
Thank you for the update.
We updated the script in the functions.php file — the page should now be scrollable.
function remove_slideshow_swipe_script() { ?> <script> document.addEventListener('DOMContentLoaded', function() { if (window.innerWidth <= 768) { var slideshow = document.querySelector('.avia-slideshow'); if (!slideshow) return; slideshow.style.touchAction = 'pan-y'; let startX = 0; let startY = 0; slideshow.addEventListener('touchstart', function(e) { startX = e.touches[0].clientX; startY = e.touches[0].clientY; }, {passive: true, capture: true}); slideshow.addEventListener('touchmove', function(e) { const dx = Math.abs(e.touches[0].clientX - startX); const dy = Math.abs(e.touches[0].clientY - startY); if (dx > dy) { e.preventDefault(); e.stopImmediatePropagation(); } }, {passive: false, capture: true}); } }); </script> <?php } add_action( 'wp_footer', 'remove_slideshow_swipe_script', 99 );Best regards,
IsmaelDecember 17, 2025 at 6:16 pm #1492623Hi Ismael,
Thank you so much. It works like a charm. I did up the window width test to 1440px to include all touch devices: iPad, Android tablet and MS Surface. (Do I really need that test? Non-touch devices will not encounter touch events, right?)
Best regards,
SergeDecember 17, 2025 at 9:06 pm #1492633Hi,
Glad that Ismael could help, you are correct that non-touch devices will not encounter touch events, so it should not be an issue. Unless there is anything else with this issue, shall we close this thread? Naturally you can always open a new thread for new issues, but we like to keep each thread on topic. :)Best regards,
MikeDecember 17, 2025 at 10:20 pm #1492637Hi,
Yes, you can close the thread.
Thanks.Best regards,
Serge -
AuthorPosts
- You must be logged in to reply to this topic.
