fancybox icon indicating copy to clipboard operation
fancybox copied to clipboard

data attribute width + fitToView

Open moymadethis opened this issue 10 years ago • 2 comments

Is it possible to set a width using a data attribute while allowing the overlay to still use fitToView?

I have it working in essence but I've noticed my overlays are not responsive/won't scale with the browser unless I remove fitToView from my script?

Here's an example of my 'basic' fancybox: http://codepen.io/moy/pen/YGgjqv

And here is a forked version where I've tried to implement a different width: http://codepen.io/moy/pen/JRzBJp

Do you think it would be easier to set a new fancybox on a different class (like .fancybox-narrow)? I basically want the behaviour to remain the same but due to the content in a couple of overlays I want to display them with a narrower width?

Thanks in advance, hope you can help! :)

moymadethis avatar Oct 26 '16 10:10 moymadethis

I seem to have found a solution to the problem by using the following:

beforeLoad: function() {
    if ($(this.element).hasClass('fancybox--small')) {
        this.maxWidth = 600;
    }
}

Can't see any problems with it (yet). It also means I don't need to adjust the rest of the fancybox rules. Does it seem ok to you?

Thanks again!

moymadethis avatar Nov 03 '16 09:11 moymadethis

That is what callbacks are supposed to do - to manipulate with options, data, content, etc

fancyapps avatar Feb 27 '17 13:02 fancyapps