What needs to be added so that the function starts working after a certain scroll and works only once?

  • 0
    Good afternoon!
    There is the following function.
    Its essence is as follows: when you move the mouse cursor off the screen, a modal window appears.
    Can you please tell me what needs to be added and how to make this function work after a certain scroll, for example, at 900px and, most importantly, so that it works only once?
    I would be very grateful to you!

    $(function() {
          var $window = $(window);  
          $window.on('mouseout', function(e){
              if (e.toElement === null) {
                  $('#mouse-popup').css('display','block');
                  $('.black-bg').css('opacity','0.8');
                  $('.black-bg').css('display','block');
                  
              }
              
              
            })
    
    
            $('.decline').on('click', function() {
                $('#mouse-popup').css('display','none');
                $('.black-bg').css('display','none');
            });
    
            $('.black-bg').on('click',function(){
                $('#mouse-popup').css('display','none');
                $('.black-bg').css('display','none');
            }) ;
            
      })
    CSS Adrian Payne, Jul 10, 2020

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!