5

I need to fix the problem with body element and the css overflow attribute discussed in this post: When a fancybox 2 is activated, a scrollbar flashes on the parent page causing the content to shift left and then back

Using the helper option helpers: {overlay: {locked: false}} fixes my problem, but I need a solution to set this option for all Fancybox calls, this way I do not need to spend this setting on each call.

I tried with different forms, but doesn't works:

$.fancybox.open([{
    helpers: {
        overlay: {
            locked: false
        }
    }
}]);

$.extend($.fn.fancybox.helpers, {
    overlay: {
        locked: false
    }
});

$.fn.fancybox.defaults.overlay.locked = false;

I do not want to change the css component, because currently use the same via Bower.

Community
  • 1
  • 1
Fred Wuerges
  • 1,965
  • 2
  • 21
  • 42

1 Answers1

0

You could setup an object with this setting that you use in all of your fancyBox calls:

var fancyBoxDefaults = 
{
    helpers: {
        overlay: {
            locked: false
        }
    }
};
$(".fancybox1").fancybox(fancyBoxDefaults);
$(".fancybox2").fancybox(fancyBoxDefaults);

If you need to set settings for any specific fancyBox, you could extend the object:

$(".fancybox3").fancybox($.extend(fancyBoxDefaults,{
    maxWidth: 800,
    maxHeight: 600
}));
Gabby Paolucci
  • 887
  • 8
  • 23