Jump to content

[Share] Auto Scroll Gallery Grid

Recommended Posts

This code will turn Gallery Section - Grid to Autoscroll Carousel. If you can't make it work, you can comment below or message me.

image.thumb.png.b355fe07571740f0bcffc3f969a7df58.png

Demo: https://tuanphan.squarespace.com/gallery-section-grid-autoscroll?noredirect

Pass: abc

#1. First, you need to add a Gallery Section - Grid

image.png.d26e76037bb9c982df35c76d9f232d1b.png

#2. Install Squarespace ID Finder to find ID of Gallery Grid

https://chromewebstore.google.com/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff?hl=en

In my example, we will have

section[data-section-id="665be33616c8f9735222784d"]

image.png.f09251a314c1cdcf598da3b3f2e14376.png

#3. Use this code to Page Header Code Injection (or Code Injection > Footer)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(() => {
    let addLeft = '<div id="slider-left" class="slider"><div class="slide-track" id="slides-left">'
    const interval = setInterval(() => {
        let imgs = $('section[data-section-id="665be33616c8f9735222784d"] img');
        if (imgs.length > 0) {
            for (let j=0; j<10; j++) {
                for (let i = 0; i<imgs.length; i++) {
                    addLeft += '<div class="slide"><img src="'+ $(imgs[i]).attr('data-src') +'" alt="" /></div>'
                }
            }
            addLeft += '</div></div>'
            $(addLeft).prependTo('section[data-section-id="665be33616c8f9735222784d"]');
            clearInterval(interval);
        }
    }, 100)
})
</script>
<style>
@keyframes scrollLeft {
	0% { transform: translateX(0); }
  100% {transform: translateX(calc(-250px * 30));}
}
.slide img {
    height: 75px;
}

.slider {
	height: 75px;
	margin: auto;
	overflow:hidden;
	position: relative;
	width: 100%;
}
	
#slider-left	.slide-track {
		animation: scrollLeft 150s linear infinite;
		display: flex;

	}	
	.slide {
		height: 75px;
		padding: 0 40px;
	}
section[data-section-id="665be33616c8f9735222784d"] .section-border, section[data-section-id="665be33616c8f9735222784d"] .content-wrapper {
    display: none;
}


div#slider-left {
    margin-top:70px;
    margin-bottom: 70px;
}
  body, html {
    overflow-x: hidden;
}
</style>

#4. Note

In the code, I added same ID to 4 positions. You need to replace these IDs with your Gallery Section ID.

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
  • Replies 0
  • Views 276
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Posted Images

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.