Viewing 30 posts - 1 through 30 (of 35 total)
  • Author
    Posts
  • #1186866

    Greetings
    Is it possible to have a lightbox that can contain text block ?
    I am using a Masonry Gallery and i want to click on the photo and have a window that contains images, text, and buttons with links

    Is this available in Enfold ? if not can you recommend a solution
    Thank you

    #1187152

    Hey Mohamad,
    Sorry for the late reply, please try this solution

    Best regards,
    Mike

    #1187160

    @Mike
    Thank you very much, his is working perfectly on links i add to texts ..
    However
    1- i want to have the link applied on a masonry gallery image , meaning when someone clicks on an image, he will get the pop up lightbox
    is that possible ?

    2- i can benefit from your solution elsewhere on the site, not only with what mentioned above, so my next question is, can the pop up include images and buttons ? i tried adding a shortcode from within Enfold inside the code block but it didnt work

    #1187326

    Hi,
    Glad to hear this is working for you, the trigger to open the popup is a link with the URL #test-popup that also has the class open-popup-link so to add this to a masonry gallery image, add this jQuery to a code block on your page:

    
    <script>
    (function($){
      $(document).ready(function(){
        $("a#av-masonry-1-item-1960").attr("href", "#test-popup").addClass('open-popup-link');
    });
    })(jQuery);
    </script>
    

    You will need to adjust the masonry ID you yours, and clone this code for every link, if you need help finding it please link to your page so we can inspect.
    You can add image and button shortcodes from the shortcode wand to the popup and it will work, here is an example:
    2020-02-24-060959
    Best regards,
    Mike

    #1191048

    Dear @Mike
    Thank you so much for your help !

    I am using it perfectly within a content slider (i did not test it in a masonry yet but i will later and update you)

    Thanks again !

    #1191091

    Hi,
    Glad to hear.

    Best regards,
    Mike

    #1270029

    Dear @Mike
    I am having a problem concerning this solution that worked for a while but now it is acting weird
    Whenever i click on the photo for the lightbox to appear, i get a page scroll up to the top

    i think it is due to the #

    would you try it yourself .. and it is also acting more weird on mobile !

    Example: https://per-vurt.com/dj-music-production-school-lebanon
    whenever you see “Student Success Stories” you can click on any of the photos named “Nesta, Nur …)

    Thank you for the help !

    #1270093

    Hi,

    Thank you for the update.

    We are not really sure why it scrolls up but we could try to adjust the lightbox options. Try to set the fixedBgPos option to false, and the overflowY option to hidden. In the previous lightbox snippet, please look for this code.

    jQuery('.open-popup-link').magnificPopup({
    	  type:'inline',
    	  midClick: true // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href.
    	});
    

    .. and add the options or replace it with.

    jQuery('.open-popup-link').magnificPopup({
    	  type:'inline',
    	  midClick: true,
              fixedBgPos: false,
              overflowY: 'hidden'
    	});
    

    Best regards,
    Ismael

    #1270187

    Hi @Ismael
    Thank you for the answer .. this solution did not work !
    I hope you can try again and solve it !

    #1270205

    the old snippet does not work anymore ? :

    function no_background_scroll_on_lightbox_open(){
    ?>
    <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
    }
    add_action('wp_footer', 'no_background_scroll_on_lightbox_open');

    but on some browsers this will cause a jump of the content because the scrollbar space needed or not.
    so here is a solution you can test without the snippet above:

    .mfp-wrap ~ #wrap_all {
      position: fixed !important ;
    }
    #1270210

    the scroll to top i only know if you did that on magnific parameters: https://dimsemenov.com/plugins/magnific-popup/documentation.html#aligntop

    and if i look to that DOM – and the events on that inline links – i never had so much jQuery on those inline-popups :

    • This reply was modified 3 years, 10 months ago by Guenni007.
    #1270641

    Hi,


    @Guenni007
    : Thank you for the help. If I am not mistaken, setting the overflowY option to hidden should accomplish the same thing and prevent background scroll, but @Cloudypro should definitely try the suggested script.


    @Cloudypro
    : Please try the suggested script above, see if it helps.

    Best regards,
    Ismael

    #1270648

    Hello @guenni007 and @Ismael

    1- I tried to add
    `.mfp-wrap ~ #wrap_all {
    position: fixed !important ;
    }
    to the Additional CSS
    Result: No more scrolling to top, however it jumps instantly to top(you can try it yourself as the above code is still in Additional CSS
    On mobile, the pop up does not show at all, and i still have a scroll up to top

    2- I do not have the snippet mentioned on #1270205 in my functions.php initially.
    I tried to add it but it did not change anything

    I hope you can advise further to solve this

    Thanks !

    #1271334

    my snippet above should work.

    but on reading the magnific popup docu – a better idea comes to my thoughts:

    we can try on Ismaels inline popup code the before and after function – remove all done so far except the snippet from Ismael https://kriesi.at/support/topic/lightbox-17/#post-1270093
    and add some callbacks:

    jQuery('.open-popup-link').magnificPopup({
    	type:'inline',
    	midClick: true,
    	callbacks: {
    		beforeOpen: function () {
    			jQuery('html').css("overflow-y", "hidden");
    		},
    		close: function() {
    			jQuery('html').css("overflow-y", "auto");
    		},
    	},
    });

    PS to Ismael: the overflowY parameter for magnific popup only rules the sidebars in the popup itself ! Link
    “Defines scrollbar of the popup… ”
    ______________

    PPS: again

    and if i look to that DOM – and the events on that inline links – i never had so much jQuery on those inline-popups

    maybe there are different events on that click too !
    this is the amount of jQuery on my inline popups:

    • This reply was modified 3 years, 9 months ago by Guenni007.
    #1271780

    Hi,

    Thank you for the info.

    Since we are clicking a link with anchor, it is possible that it is also triggering the smooth scroll function from the theme and of course it is using jQuery. Did you also install a plugin called Page Scroll to ID? Based on the screenshot, a script page-scroll-to-id.min.js is also used when clicking on the link.

    Best regards,
    Ismael

    #1271831

    Yes, I like this little plugin – not least because of the possibility to bring in correction values regarding the focused elements.
    Because of the changeable selector you can exclude the inline anchor

    a[href*='#']:not([href^='#'])
    

    but you are right on that test page i forgot to edit the selector and forgot to insert that “^” on href.

    it is now:

    #1272233

    Hello Guys
    Since you are both much more advanced than me, can you please give me one final solution .. like a simple instruction on what i should EXACTLY do to solve my issue ? as this has become a bit complicated for me to understand especially after followup modifications i got lost
    Thank you

    #1272390

    i can see in your sourc code of that page: https://per-vurt.com/dj-music-production-school-lebanon/
    ( click to enlarge:)

    so you used ismaels code above – replace it by:

    jQuery(window).load(function(){
    	jQuery('.open-popup-link').magnificPopup({
    		type:'inline',
    		midClick: true,
    		callbacks: {
    			beforeOpen: function () {
    				jQuery('html').css("overflow-y", "hidden");
    			},
    			close: function() {
    				jQuery('html').css("overflow-y", "auto");
    			},
    		},
    	});
    });

    and remove from your css:

    .mfp-wrap ~ #wrap_all {
        position: fixed !important;
    }
    #1272393

    to avoid the extensive use of using jQuery instead of $ i do use this syntax in my child-theme functions.php:
    (so every $ is a jQuery)

    function open_inline_popup(){
    ?>
    <script type="text/javascript">
    (function($) {
    	$(window).load(function(){
    		$('.open-popup-link').magnificPopup({
    			type:'inline',
    			midClick: true,
    			callbacks: {
    				beforeOpen: function () {
    					$('html').css("overflow-y", "hidden");
    				},
    				close: function() {
    					$('html').css("overflow-y", "auto");
    				},
    			},
    		});
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'open_inline_popup');
    #1272472

    Hello @Guenni007
    I have followed your instructions but it is still scrolling to top and acting weird on Mobile

    :(

    #1272649

    where did that function come from:

    function(e) {
      var current = link.find('img:first'),
        _self = current.get(0),
        outerH = current.outerHeight(),
        outerW = current.outerWidth(),
        pos = current.position(),
        linkCss = link.css('display'),
        overlay = link.find('.image-overlay');
      if (outerH > 100) {
        if (!overlay.length) {
          overlay = $("<span class='image-overlay " + span_class + "'><span class='image-overlay-inside'></span></span>").appendTo(link);
        }
        if (link.height() == 0) {
          link.addClass(_self.className);
          _self.className = "";
        }
        if (!linkCss || linkCss == 'inline') {
          link.css({
            display: 'block'
          });
        }
        overlay.css({
          left: (pos.left - overlay_offset) + parseInt(current.css("margin-left"), 10),
          top: pos.top + parseInt(current.css("margin-top"), 10)
        }).css({
          overflow: 'hidden',
          display: 'block',
          'height': outerH,
          'width': (outerW + (2 * overlay_offset))
        });
        if (cssTrans === false) overlay.stop().animate({
          opacity: opa
        }, 400);
      } else {
        overlay.css({
          display: "none"
        });
      }
    }

    it is on that click event too

    #1272661

    maybe there is indeed an interaction with the smoothscroll function of enfold. Don’t know. on my end it only scolls a few pixels but never to top.
    Sorry

    #1272670

    Thank you @Guenni007 for your time


    @Ismael
    can you help please ?

    #1272732

    Hi,

    Try to edit the open-popup-link in the slide content, then include the class name “no-scroll” to prevent the smoothscroll script from executing when the link is clicked. Have you considered making the background darker or remove the transparency so that the site content is not visible when lightbox is enabled?

    Best regards,
    Ismael

    #1272803

    yes – and that is a part of the smoothscroll function on avia.js …

    jQuery(window).load(function(){
    	jQuery('.open-popup-link').addClass('no-scroll');
    	jQuery('.open-popup-link').magnificPopup({
    		type:'inline',
    		midClick: true,
    		callbacks: {
    			beforeOpen: function () {
    				jQuery('html').css("overflow-y", "hidden");
    			},
    			close: function() {
    				jQuery('html').css("overflow-y", "auto");
    			},
    		},
    	});
    });

    that works for me

    _____________

    i tried to implement as magnific popup described with callback and beforeOpen –
    but that will not work on first click – but our trigger class see above will do the job better

    that part

    callbacks: {
    	beforeOpen: function () {
    		(this.st.el).addClass('no-scroll');
    		$('html').css("overflow-y", "hidden");
    	},
    	close: function() {
    		$('html').css("overflow-y", "auto");
    	},
    },
    • This reply was modified 3 years, 9 months ago by Guenni007.
    #1272830

    Can i please have a final code ? i am not expert like you guys so i am not getting what you are saying

    i want to copy a final code and paste it in my functions.php if that’s possible please

    #1272842

    that was the final code:

    that is what you have now:

    
    jQuery(window).load(function(){
    	jQuery('.open-popup-link').magnificPopup({
    		type:'inline',
    		midClick: true,
    		callbacks: {
    			beforeOpen: function () {
    				jQuery('html').css("overflow-y", "hidden");
    			},
    			close: function() {
    				jQuery('html').css("overflow-y", "auto");
    			},
    		},
    	});
    });
    

    replace it with:

    jQuery(window).load(function(){
    	jQuery('.open-popup-link').addClass('no-scroll');
    	jQuery('.open-popup-link').magnificPopup({
    		type:'inline',
    		midClick: true,
    		callbacks: {
    			beforeOpen: function () {
    				jQuery('html').css("overflow-y", "hidden");
    			},
    			close: function() {
    				jQuery('html').css("overflow-y", "auto");
    			},
    		},
    	});
    });
    #1272929

    HI
    It worked
    Thank you very much

    #1273102

    Hi Cloudypro,

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

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1273685

    small things would still be worth mentioning.
    For large popups with lots of content, on mobile the html attribute overflow-y : hidden causes you to have no chance to scroll through the popup.
    You can avoid this by assigning this attribute to the body tag and not to html

Viewing 30 posts - 1 through 30 (of 35 total)
  • The topic ‘Lightbox’ is closed to new replies.