Slideshow in FancyBox Image Gallery?

后端 未结 3 1726
独厮守ぢ
独厮守ぢ 2020-12-12 01:49

I am just starting out learning some HTML and javascript (read: I know practically nothing about this stuff) and would like to have my index.html page open a rotating image

3条回答
  •  无人及你
    2020-12-12 01:55

    Here is how I set up the function. I added the count because when loading a gallery the onStart/onComplete calls will fire everytime a new image loads. I only want the first call to bind the setInterval to the next call.

      function toggleRotating(fromButton) {
          count = count + 1;
          if (fromButton == false) {
            clearInterval(rotatingInterval);
            rotatingInterval = false;
            count = 0;
          } else {
            if(count == 1)
                rotatingInterval = setInterval($.fancybox.next, 10000);
    
          }
       }
    

    And here's my global vars and method of launching fancybox.

    var rotatingInterval = false;
    var count = 0;
    $(function () {
        $("a.slide").attr('rel', 'presentation1').fancybox({'autoDimensions':false,'height':540,'width':720,'autoScale':false,'cyclic':true, 'onStart': function(){ toggleRotating(true); } });
    });
    

    I didn't create a button to stop rotating. I think I will make it so if you click on the next or prev buttons it will toggleRotating to false.

提交回复
热议问题