Search code examples
jquerycolorbox

jQuery Colorbox background transition effect?


I find the background transition of the jQuery Colorbox very 'hard'. I couldn't find a setting where I can specify a custom transition. Is it possible to create a fade-effect for the background like Nyro Modal has?


Solution

  • UPDATED 2 with easing effects

    DEMO: http://so.lucafilosofi.com/jquery-colorbox-background-transition-effect/

    $('.example').colorbox({
        //added to remove initial flickering
        opacity : 0,
        //use the onOpen event...
        onOpen: function() {
            // prevent Overlay from being displayed...
            $('#cboxOverlay,#colorbox').css('visibility', 'hidden');
            // make the overlay visible and
            // re-add all it's original properties!
            $('#cboxOverlay').css({
                'visibility': 'visible',
                'opacity': 0.9,
                'cursor': 'pointer'
                // execute our original animation on the overlay!
                // animate it you can use here all the
                // possible animate combination or plugin...
            }).animate({
                height: ['toggle', 'swing'],
                opacity: 'toggle'
            }, 1000 , function() {
                $('#colorbox').css({
                'visibility': 'visible'
            }).fadeIn(1000);
            });
        }
    });