Fancybox, Custom Open Transition

后端 未结 4 1339
Happy的楠姐
Happy的楠姐 2020-12-15 15:03

Does anyone know how you open a fancyBox with a custom open transition:

http://fancyapps.com/fancybox/

Im looking to achieve a similar transition to the exam

4条回答
  •  失恋的感觉
    2020-12-15 15:34

    Add custom transitions -

    (function ($, F) {
        F.transitions.dropIn = function() {
            var endPos = F._getPosition(true);
    
            endPos.top = (parseInt(endPos.top, 10) - 200) + 'px';
    
            F.wrap.css(endPos).show().animate({
                top: '+=200px'
            }, {
                duration: F.current.openSpeed,
                complete: F._afterZoomIn
            });
        };
    
        F.transitions.dropOut = function() {
            F.wrap.removeClass('fancybox-opened').animate({
                top: '-=200px'
            }, {
                duration: F.current.closeSpeed,
                complete: F._afterZoomOut
            });
        };
    
    }(jQuery, jQuery.fancybox));
    

    Use them like -

    $(".fancybox").fancybox({
        openMethod : 'dropIn',
        openSpeed : 250,
    
        closeMethod : 'dropOut',
        closeSpeed : 100
    });
    

    And whoa-la - the same effect!

提交回复
热议问题