Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frozenjs有图片随滚动条异步加载的功能么? #18

Open
abbleto opened this issue Jan 26, 2015 · 2 comments
Open

frozenjs有图片随滚动条异步加载的功能么? #18

abbleto opened this issue Jan 26, 2015 · 2 comments

Comments

@abbleto
Copy link

abbleto commented Jan 26, 2015

No description provided.

@hkz404
Copy link
Contributor

hkz404 commented Feb 1, 2015

具体指的是哪一个组件?

@fayching
Copy link
Member

fayching commented Feb 2, 2015

因为没有固定的结构,这种页面拉到底部继续加载的交互现在一般没有用组件,就是在onscroll事件中判断滚动条高度和页面高度,下面的代码可以参考下:

 function onScroll() {
        if (base.hasMask() || !hasMore) {
            return;
        }
        var viewHeight = $(window).height();//浏览器可视区域高度
        var scrollHeight = $(window).scrollTop();//已滚动高度
        var docHeight = $(document).height();//页面文档高度
        var loadingHeight = $("#loading").height();
        if (lastDocHeight == docHeight) {//避免页面内容改变前多次触发滚动条事件导致重复加载内容
            return false;
        }
        if (viewHeight + scrollHeight >= docHeight - loadingHeight / 2) {
            lastDocHeight = docHeight;
           // to do something
        } else if (viewHeight + scrollHeight >= docHeight - loadingHeight / 2 - 100) {
            var date = new Date();
            var now = date.getTime();
            if (window.lastSetScrollTime == undefined || now - window.lastSetScrollTime >= 200) {
                document.body.scrollTop = scrollHeight;
                window.lastSetScrollTime = now;
            }
        }
    }
      $(window).scroll(function (event) {
            onScroll();
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants