簡體   English   中英

如何使用無限滾動和砌體實現addthis共享

[英]How to implement addthis share with infinte scroll and masonry


我用磚石實現了無限滾動,當我滾動到下一個加載圖像時,我被卡在addthis共享按鈕中而無法工作,addthis按鈕得到顯示,但它沒有共享適當的圖像。

如果我從砌築功能中刪除以下三行

 addthis.toolbox('.addthis_toolbox');<br/>
 addthis.counter('.addthis_counter');<br/>
 addthis.init();

滾動到下一個圖像列表后,我只能在第一個圖像列表上看到addthis共享按鈕

JavaScript代碼

 <script type="text/javascript">var addthis_config = { "data_track_addressbar": false ;</script>
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4e142f1d185c5361"></script>

<script src="js/jquery.masonry.min.js"></script>
<script src="js/jquery.infinitescroll.min.js"></script>

<script type="text/javascript">


    $(function () {

        var $container = $('#container');

        $container.imagesLoaded(function () {
            $container.masonry({
                itemSelector: '.box',
                columnWidth: 95
            });

        });

        $container.infinitescroll({
            navSelector: '#page-nav',    // selector for the paged navigation
            nextSelector: '#page-nav a',  // selector for the NEXT link (to page 2)
            itemSelector: '.box',     // selector for all items you'll retrieve
            loading: {
                finishedMsg: 'No more photos to load.',
                img: 'http://i.imgur.com/6RMhx.gif',

            }
        },
            // trigger Masonry as a callback
            function (newElements) {
                // hide new items while they are loading
                var $newElems = $(newElements).css({ opacity: 0 });
                // ensure that images load before adding to masonry layout
                $newElems.imagesLoaded(function () {
                    // show elems now they're ready
                    $newElems.animate({ opacity: 1 });
                    $container.masonry('appended', $newElems, true);
                    addthis.toolbox('.addthis_toolbox');
                    addthis.counter('.addthis_counter');
                    addthis.init();

                });
                $('.listing_img_wrapper').hover(
                    function () { $(this).find('.hover_img').fadeIn("slow"); },
                    function () { $(this).find('.hover_img').fadeOut("slow"); }
                );
                //   console.log("called");
                //   window.addthis.toolbox('.addthis_toolbox');
            }
        );

    });
</script>

我已經通過添加解決了解決方案

addthis.counter('.addthis_counter');

 if (window.addthis) {
            window.addthis.ost = 0;
            window.addthis.ready();
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM