Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How/where to define fancybox defaults?

Let's say this is my fancybox config:

   $(".fancybox").fancybox({
      'transitionIn':'fade',
      'transitionOut':'fade',
      'speedIn':150,
      'speedOut':150,
      'changeSpeed':150,
      'changeFade':150,
      'overlayOpacity':0.1,
      'overlayColor':'#000000',
      'padding':0,
      'margin':20,
      'titleShow':false,
      'centerOnScroll':true
   });

But, what I would like to do, is to somehow define the config as the fancybox default, so that consequently when I bind an element, I can only do this:

$(".newElement").fancybox();

And it will automatically have my config.

like image 374
Frantisek Avatar asked Aug 15 '11 20:08

Frantisek


1 Answers

This is how I do it (according to the latest (fancybox3) documentation):

         $.fancybox.defaults.clickOutside = 'close'

         $.fancybox.defaults.slideShow = {
             autoStart : false,
             speed     : myGallerySlideshowSpeed
         }

And so on. That is, I dont really initiate anything, I just have my items tagged data-fancybox="gallery" and use the above code to set defaults.

like image 70
yPhil Avatar answered Dec 11 '22 01:12

yPhil