Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1054914

    When you open the lightbox using a masonry gallery, the background will be darkend and you can use the navigation arrows. But some users start to scroll the hole webpage using the right scrollbar, while the popup window from the lightbox is in use. Of course this will cause the problem that the website content looks wired and you can’t click on any topic. This is not an intended function, but it is possible to do so.
    I like to stop this behaviour, using some css or jquery. I need some help where I have to place some code into the child theme to stop the background to move, while the lightbox popup is in use. I like to fix the background, when the the lightbox popup is in use und release the background when the lightbox modal is closed.
    Any hints or a link to a solution? Maybe there is already a solution that I didn’t found. Thank you for your help.

    #1054919

    you have to put this into your child-theme functions.php:

    add_action('wp_footer', 'custom_lightbox_script');
    function custom_lightbox_script(){
    ?>
    <script type="text/javascript">
    (function($) {
        function a() {
          $('body').on('click', '.lightbox-added', function() {
            if($('.mfp-bg').length >= 1) {
              $('html').css("overflow-y", "hidden");
            } 
          });
          
          $('body').on('click', function() {
            setTimeout( function() {
              if($('.mfp-bg').length == 0) { 
                $('html').css("overflow-y", "scroll");
              }
            },500);   
          });
        }
      a(); 
    })(jQuery);
    </script>
    <?php
    }

    some people would pay money for a code like that ;) :lol

    #1054935

    Thank you very much for this code, yes it works perfectly.
    This should be added to the faq, because the issue is a general issue and your code makes the user experience more easy and secure.

    #1055617

    Hi Ralf Behrendt,

    Glad you got it working for you with Guenni007’s help! :)

    Well, the solution is available at the forum, so others will be able to use it.

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.