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
  • 4 weeks later...
  • Replies 2
  • Views 464
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

16 hours ago, azaslona123 said:

hi @tuanphan it's all understandable but I have 8 logos and squarespace doesn't let me create more than 6 columns. Do you have any solution for that? 

 

Also, I tried with 6 pictures with this code and following your instruction and it doesn't work. 

the website is: 
www.toleasing.pl 

You mean this section?

#1. Number of Columns is not affected. Whether you choose 3, 6 or 8, the code will convert all to one line scroll.

image.thumb.png.cbd226edf8d07e9fe642aec1864ecaf8.png

#2. I see you used incorrect ID

image.thumb.png.9c886e0723ff2c215f89c073a78040d0.png

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

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.