You can also use the beforeShow
callback function, but you may need to cancel all transitions (set nextSpeed
and prevSpeed
to 0
).
The transition speed seems to create a jump effect using the afterShow
or to get the correct value using the beforeShow
.
You may also need to update fancybox v2.0.6.
In addition, you can simplify your script without using external variables such as:
$(document).ready(function() { $("a.fancybox").fancybox({ openEffect : 'elastic', closeEffect : 'elastic', fitToView: false, nextSpeed: 0, //important prevSpeed: 0, //important beforeShow: function(){ // added 50px to avoid scrollbars inside fancybox this.width = ($('.fancybox-iframe').contents().find('html').width())+50; this.height = ($('.fancybox-iframe').contents().find('html').height())+50; } }); // fancybox }); // ready
See DEMO here
source share