mercredi 7 février 2018

Popup modal to not be jumpy

I created a popup modal with Jquery and I have three questions about it.

  1. Right now I have the popup to close on click with the button but I also want it to close when clicking outside of the popup.

  2. When the user close the popup in the middle of the page, I want the page to stay where it is and not jump back to the top.

  3. Once the user click close to the popup, it won't appear again. I'm guessing I might need to write another condition statement.

Do you guys have any hint or documentation I can look over? So sorry for asking a lot of questions. I am still new to web development.

Thank you and below are my code.

    $(document).scroll(function(){
    var a = $(this).scrollTop();
    if (a > 500) {
        $("#mc_embed_signup").fadeIn();
    } else 

    $(".popup-close").click(function(e){
            closeSPopup();
        });
});

function closeSPopup(){
    $("#mc_embed_signup").fadeTo(0);
}

Aucun commentaire:

Enregistrer un commentaire