简体   繁体   English

将stapel功能与弹出框混合使用

[英]Mix stapel-function with magnific-popup

I found 2 awesome jquery plugins in "Magnific Popup" and a special stapel-function "Adaptive Thumbnail Pile Effect with Automatic Grouping" and I thought with both together, I could make a pretty cool (responsive) portfolio with resizing lightbox. 我在“ Magnific Popup”中找到了2个很棒的jquery插件,还有一个特殊的排笔功能“带有自动分组的自适应缩略图桩效果”,我认为将它们组合在一起,可以通过调整灯箱大小来制作一个非常酷的(响应式)投资组合。

But unfortunately they don't work together as I expected as you can see here . 但不幸的是如我所料,你可以看到他们不工作一起在这里

When you click on the top picture and open one of the 2 that appear, it will show up in a lightbox, but without the close-Button and title below the image. 当您单击顶部图片并打开出现的2张图片时,它将显示在一个灯箱中,但图片下方没有关闭按钮和标题。 So you have to go back with the "browser-back-button" (not good). 因此,您必须使用“浏览器后退按钮”返回(不好)。

When you click on one of the small pics on the bottom "without stapel function" the picture opens with the close-button and Title from "magnific popup". 当您单击底部的“不带排字功能”的小图片之一时,带有关闭按钮的图片会打开,并且标题会显示为“壮观的弹出窗口”。 So here magnific pop up works fine. 因此,这里宏伟的弹出窗口可以正常工作。 Now, I didn't find out why the magnific-popup close-button/title doesn't appear with the stapel function pics on the top. 现在,我没有发现为什么弹出式关闭图片/标题没有显示在顶部的stapel功能图片上。

As I'm not a JS pro, I can only guess that there might be a conflict between the two js-scripts, so I tried to add "jQuery.noConflict();" 由于我不是JS专业人士,所以我只能猜测两个js脚本之间可能存在冲突,因此我尝试添加“ jQuery.noConflict();” but it was just a guess and it didn't solve the problem. 但这只是一个猜测,并不能解决问题。

I hope, someone has an idea. 我希望有人有一个主意。

This is the JS stuff in the HTML header: 这是HTML标头中的JS内容:

<!-- Magnific Popup core CSS file -->
<link rel="stylesheet" href="css/magnific-popup.css"> 

<!-- jQuery 1.7.2+ or Zepto.js 1.0+ -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 

 <!-- Modernizr -->
<script src="js/modernizr.custom.63321.js"></script>

<!-- Magnific Popup core JS file -->
<script src="js/jquery.magnific-popup.js"></script> 

<!-- external Stapel JS file  -->
<script type="text/javascript" src="js/jquery.stapel.js"></script>

<!-- internal Stapel JS  -->    
<script type="text/javascript">

jQuery.noConflict();

$(function() {
    var $grid = $( '#tp-grid' ),
    $name = $( '#name' ),
    $close = $( '#close' ),
    $loader = $( '<div class="loader"><i></i><i></i><i></i><i></i><i></i><i></i><span>Loading...</span></div>' ).insertBefore( $grid ),
    stapel = $grid.stapel( {
    onLoad : function() {
    $loader.remove();
    },
    onBeforeOpen : function( pileName ) {
    $name.html( pileName );
    },
    onAfterOpen : function( pileName ) {
                        $close.show();
                    }
                } );

            $close.on( 'click', function() {
                $close.hide();
                $name.empty();
                stapel.closePile();
            } );

        } );
    </script>

This is JS for magnific-popup before closing body-Tag: 这是关闭body-Tag之前用于放大弹出式窗口的JS:

<script type="text/javascript"> 
$(document).ready(function() {

$('.popup').magnificPopup({
    type: 'image',
    closeOnContentClick: true,
    image: {
        verticalFit: false
    }
});

});

</script>

The magnific-popup is called by the class="popup" in the links (works fine here): magnific-popup由链接中的class =“ popup”调用(在这里工作正常):

<a class="popup" href="http://farm9.staticflickr.com/8379/8588290361_ecf8c27021_b.jpg" title="This image fits only horizontally.">
<img src="http://farm9.staticflickr.com/8379/8588290361_ecf8c27021_s.jpg" height="75" width="75">
</a>

<a class="popup" href="http://www.marvin-online.de/test/images/print/large/logo-safework-1.jpg" title="Der Titel">  <img src="http://www.marvin-online.de/test/images/print/large/logo-safework-1.jpg" height="75" width="75"></a>

..and with those pictures it doesn't work: ..并且这些图片不起作用:

<ul id="tp-grid" class="tp-grid">

<li data-pile="Logo">
    <a class="popup" href="http://www.marvin-online.de/test/images/print/large/visitenkartendesign-erbengemeinschaft.jpg">
<span class="tp-info"><span>Logo 1</span></span>
<img src="http://www.marvin-online.de/test/images/print/thumbs/visitenkartendesign-erbengemeinschaft.jpg" />
    </a>
</li>

<li data-pile="Logo">
    <a class="popup" href="http://www.marvin-online.de/test/images/print/large/logo-safework-1.jpg">
<span class="tp-info"><span>Logo 2</span></span>
<img src="http://www.marvin-online.de/test/images/print/thumbs/logo-safework-1.jpg" />
    </a>
</li>
</ul>

Ok, I've found a solution: just add the magnific plugin's code inside Stapel's “onAfterOpen” callback function. 好的,我找到了一个解决方案:只需在Stapel的“ onAfterOpen”回调函数中添加宏伟的插件代码即可。 (Many thx to Andrew-David!) (对安德鲁·戴维很感激!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM