dimsemenov / Magnific-Popup

Light and responsive lightbox script with focus on performance.
http://dimsemenov.com/plugins/magnific-popup/
MIT License
11.39k stars 3.49k forks source link

automatic disable magnific popup after 10 seconds #821

Open cyberformed opened 8 years ago

cyberformed commented 8 years ago

I am using magnific popup for a promotion banner using a popup modal which displays an image. I want to close that modal with the image after 10 seconds automatically. How to achieve it.

`

` ```
ghost commented 8 years ago

You can add the callback open, and setTimeout to achieve this...

$('.floater').magnificPopup({
    type:'image',
    disableOn: function() {
        return true;
    },
    callbacks: {
        open: function() {
            setTimeout(function(){
                $('.floater').magnificPopup('close');
            },10000); // 10000 == 10seconds
        }
    }
});
$('.floater').magnificPopup('open');