Jump to content

Summary Block: How can I set the Carousel to "autoplay"?

Go to solution Solved by clayyount,

Recommended Posts

Mine no longer autoplays on desktop versions, only on mobile... Still can't figure out how to make the same apply to all carousels :(

EDIT: Oh yeah- I see what you mean about the white box at the end, it's doing the same on mine... sigh

Edited by Roppo
Link to comment
  • 2 weeks later...

In response to Paul2009, here's the new code.


<script>
   Y.on('domready', function () {
       var galleries = Y.Squarespace.GalleryManager.getGalleries();
       var duration = 4000;
       var gallery=galleries[0];
       var carousel=gallery["gallery-design"];
       var totalGroups=5;
       var currentGroup=0
       var container=gallery.get("container");
       var nextBtn=Y.one(gallery.get("elements.next")._nodes[0]).on("click",function(e){
           e.preventDefault();
           e.stopPropagation();
           advanceCarousel()
       })
       var prevBtn=Y.one(gallery.get("elements.previous")._nodes[0]).on("click",function(e){
           e.preventDefault();
           e.stopPropagation();
           backupCarousel()
       })
       Y.one(container._node).get('parentNode').on("mouseover",function(){
           clearInterval(myInterval)
       })
       Y.one(container._node).get('parentNode').on("mouseout",function(){
           clearInterval(myInterval)
           setMyInterval()
       })
       var myInterval;
       function setMyInterval(){
           myInterval = setInterval(function(){
               advanceCarousel()
           },duration)
       }
       setMyInterval();
       function advanceCarousel(){
           if(currentGroup==(totalGroups-1)){
               currentGroup=0;
           }else{
               currentGroup++;
           }   
           carousel.goToGroup(currentGroup);
       }
       function backupCarousel(){
           if(currentGroup==0){
               currentGroup=totalGroups-1
           }else{
               currentGroup--;
           }
           carousel.goToGroup(currentGroup);
       }
   });
</script>

Link to comment
  • 2 weeks later...

Hi

Was wondering if you could have a look at my website?www.wekillpirates.com

I've tried to inject this code above to get my carousel to loop on the front page but it doesn't seem to work.

any help would be great

Dane

Link to comment
  • 1 month later...

To get it to suit the number of items in your gallery, change this line:

var totalGroups=5;

to

var totalGroups=carousel.get('totalGroups');

Edited by Guest
Initial Revision
Link to comment
  • 2 weeks later...
  • 4 weeks later...
  • 3 weeks later...

@benf just tried this out, and it looks like you have to do it in the header injection on the page itself. The steps are essentially the same, but listed below:

Settings (gear icon) > Advanced > Page Header Code Injection

Link to comment

IMPORTANT!!!The code works with the carousel but it effects the rest of the page to much.There is a bug in the code, but I can't find it. In Avenue when inserting the code the thumbnails of the index grid disappear and in Marque the image gallery page disappears.

Link to comment

IMPORTANT!!!The code works with the carousel but it effects the rest of the page to much.There is a bug in the code, but I can't find it. In Avenue when inserting the code the thumbnails of the index grid disappear and in Marque the image gallery page disappears.

Link to comment
  • 3 weeks later...
  • 1 month later...

i think you would want to create another gallery variable. In the example above, he/she grabs the gallery using:var gallery = galleries[0];

So if you added another gallery (and it was the second gallery on the page) you might do something like:var gallery2 = galleries[1];

then do everything you did to 'gallery' to 'gallery2'

Link to comment

Does anyone know what the beginning part of the code does?? Y.on('domready', function () { var galleries = Y.Squarespace.GalleryManager.getGalleries();

What does 'Y.on' do? What does 'domready' do? and what does 'Y.Squarespace' do?

For some reason the 'domready' is screwing up my navigation bar when I am in mobile view. When I remove the 'domready' the navigation works fine. What exactly does 'domready' do and why would it cause only my mobile navigation to stop working?
Also the the carousel will not work without 'domready'

Edited by ASAP_aul
Initial Revision
Link to comment

Max . if you think Roy `s blog is amazing, on sunday I bought a new Saab 99 Turbo after having earned $7853 this - 4 weeks past and-a little over, $10k this past-month . it's realy the nicest-job I've had . I began this four months/ago and pretty much straight away began to earn at least $72, per-hour . learn the facts here now

=========== http://goo.gl/sNgdBv

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.