I'm trying to position the fancybox that is inside a Facebook app with scrolling disabled.
The onComplete function works for a fraction of a second before going back to the vertical center of the frame. What is making it snap back to the center?
$("#footer-test-link").fancybox({
"transitionIn" : "fade",
"transitionOut" : "fade",
"speedIn" : 300,
"speedOut" : 300,
"easingIn" : "fade",
"easingOut" : "fade",
"type": "ajax",
"overlayShow" : true,
"overlayOpacity" : 0.3,
"titleShow" : false,
"padding" : 0,
"scrolling" : "no",
"onComplete" : function() {
$("#fancybox-wrap").css({"top": 80 +"px"});
}
});
FancyBox is showing your positioning for a split second because there is a race condition between the event that vertically centers the FancyBox wrapper (
#fancybox-wrap
) and the onComplete callback. onComplete will usually finish first, so thecss({"top": 80 +"px"})
is then over-written. You could try any number of ways to fix this, but I prefer to add a CSS rule onComplete rather than force the position of every FancyBox ever, as algorhythm's solution does.You may want to look into a better unique id for this, but this was sufficient for my needs. Please note that this answer is in regard to FancyBox v1.x (I used v1.3.4). v2.x may have a different logical flow, and DOES have different callbacks. Instead of using onComplete, in v2.x you would need to use either afterLoad or afterShow as per the FancyBox docs.