Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Add a slow fadein effect to my popup modal

Can someone show me how to do a slow fadein effect to my current popup modal which opens up on click event?

here is my code

var THRESHOLD = 5 * 1000;
var lastActive = Date.now();
$(window).on('click', function() {
    if (Date.now() > lastActive + THRESHOLD) {
     $('#modal').css('display','block');
    }
    lastActive = Date.now();
});

Thanks alot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

There is a default fadeIn()/fadeOut() function in jQuery you can use, there you can pass value in milliseconds which is speed of fading-in/out your content

var THRESHOLD = 5 * 1000;
    var lastActive = Date.now();
    $(window).on('click', function() {
        if (Date.now() > lastActive + THRESHOLD) {
         $('#modal').fadeIn( 500 );
        }
        lastActive = Date.now();
    });
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading