diegphoto Posted December 5, 2022 Posted December 5, 2022 (edited) Hi! In the homepage of my website www.diegphoto.com, I have code to autoplay portfolio categories. The problem is that the image of the first category is not displayed since the function is executed before the page loads. I would like to set a timeout, or a code so that it does not autoplay until the images are loaded. My site is diegphoto.com and the password is Asturias This is the code: <!--beyondspace autoplay Hover Portfolio start--> <script> (function(){ window.addEventListener('load', () => { beyAutoPlayPortfolio(4000); // change the speed of transition }); })() function beyAutoPlayPortfolio(e){let t=document.querySelectorAll(".portfolio-hover-items-list > li");if(t.length>1){let o=new Event("mouseenter"),l=null,r=function(){let i=document.querySelector('.portfolio-hover-item[data-active="true"]').closest("li").nextElementSibling;i||(i=t[0]),i.querySelector("a").dispatchEvent(o),l=setTimeout(r,e)};r(),t.forEach(e=>{e.querySelector("a").addEventListener("mouseenter",function(e){e.isTrusted&&clearTimeout(l)}),e.querySelector("a").addEventListener("mouseleave",function(e){e.isTrusted&&r()})})}} </script> <!--beyondspace autoplay Hover Portfolio end--> Thank you in advance! Edited December 6, 2022 by diegphoto
creedon Posted December 5, 2022 Posted December 5, 2022 5 hours ago, diegphoto said: I would like to set a timeout, or a code so that it does not autoplay until the images are loaded. When you say loaded do you mean visible in the viewport of your browser? If yes it is possible to write code that won't activate until the images are in the viewport. I know of no such code to handle your specific issue. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
diegphoto Posted December 5, 2022 Author Posted December 5, 2022 1 hour ago, creedon said: When you say loaded do you mean visible in the viewport of your browser? If yes it is possible to write code that won't activate until the images are in the viewport. I know of no such code to handle your specific issue. Hi! Yes, I mean visible for the visitors of the page. Right now the first image changes before being seen.
creedon Posted December 6, 2022 Posted December 6, 2022 It would probably be best if the feature you need was integrated into the code you have. I suggest contacting the author to see if that is something they are willing to add. I doesn't hurt to ask. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment