Jump to content

How to make Portfolio:Hover background images automatically cycle

Recommended Posts

Hi there,

I'm working on a site for a client and they've asked if we can have the image in the background on the portfolio automatically cycle through as though someone was hovering over the images (but still maintain the ability for a user to hover over the links and stop the rotating effect while they do so). Is there a simple way to do that?

Hoffcg.squarespace.com/projects
PW: HOFFsitedraft2024

 

Link to comment
  • Replies 3
  • Views 828
  • Created
  • Last Reply

Top Posters In This Topic

You try this code to Website > Website Tools > Code Injection > Footer

<!--beyondspace autoplay Hover Portfolio start-->
<script>
  (function(){
    window.addEventListener('load', () => {
      beyAutoPlayPortfolio(3000); // 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-->

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 1 month later...
On 4/30/2024 at 9:23 PM, SWhales said:

Hm, I popped that in the footer code injection but it doesn't seem to work.

This didn't work for me either. Did anyone find a solution for mobile?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.