首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Packery +无限滚动+ imagesLoaded =不工作

Packery +无限滚动+ imagesLoaded =不工作
EN

Stack Overflow用户
提问于 2013-05-03 03:53:22
回答 1查看 1.7K关注 0票数 0

我一直在尝试让Packery和infinitescroll jquery插件工作,然而由于某种原因,新的元素出现在彼此的顶部。

我被引导到图像加载的插件,但是由于某种原因,它似乎覆盖了一个又一个元素。我为jQuery 1.9 (https://github.com/lukeshumard/smartscroll/pull/2)的智能滚动插件应用了一个补丁,但是,我认为问题出在图片加载和打包上。

我的脚本如下所示:

代码语言:javascript
复制
    $(document).ready(function() {

        // declaring variables
        var $sidebar        = $("#sidebarHolder"),
            $sidebarwidth   = $sidebar.width(),
            $window         = $(window),
            $windowheight   = $window.height(),
            $offset         = $sidebar.offset(),
            $topPadding     = $("#sitewide").height(),
            $container      = $('#container.clearfix');

        // making sure the sidebar stays the right size when it's resized
        $(window).on("resize",function () {
            $("[role=sidebar]").width($sidebarwidth).show();
            $("#sidebarHolder,[role=sidebar]").height($windowheight + 20);
        }).resize();

        // scroll 'stick to the top' function
        $(window).on("scroll",function() {
            if ($window.scrollTop() > $offset.top) {
                $sidebar.addClass('sticky');
            }else{
                $sidebar.removeClass('sticky');
            }
        }).scroll();

        $container.packery({
            itemSelector:'article.item',
            columnWidth:"div.grid-sizer",
            rowHeight:"div.grid-sizer",
            gutter:"div.gutter-sizer",
            transitionDuration:'0.2s'
        });

        $container.infinitescroll({
            navSelector:'div.paginate',
            nextSelector:'div.paginate a.next',
            itemSelector:'article.item',
            loading:{
                finishedMsg:'No more pages to load.'
            }
        },
        function(newElements) {
            $(newElements).imagesLoaded(function(){
                $container.packery('appended', newElements);
            });
        });

    });

任何帮助都将不胜感激。

如果需要,我可以设置一个jsbin或codepen。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-03 18:19:59

这似乎是Chrome Canary的一个问题,因为它可以在其他浏览器中工作……

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16346591

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档