简体   繁体   English

当最初没有足够的内容用于页面加载时的滚动条时触发infiniteajaxscrolling

[英]trigger infiniteajaxscrolling when there's initially not enough content for scroll bar on page load

I'm using infiniteajaxscrolling , but my initial ajax call often (depending on screen size) doesn't contain enough content that it shows a scroll bar. 我正在使用infiniteajaxscrolling ,但是我最初的ajax调用经常(取决于屏幕大小)包含的内容不足以显示滚动条。

Without scrollbar, there is no scroll event => infinite scrolling never starts? 没有滚动条,就没有滚动事件=>无限滚动永远不会开始吗?

How can I let ias load content until there are at least scrollbars visible? 如何让ias加载内容,直到至少可见滚动条?

(except of course, just coding it myself ). (当然,只是自己编写 )。

Is there something like this already implemented in ias I just have to activate? 是否有这样的事情已经在ias中实施,我只需要激活即可?

I tried just calling ias.next() on a "rendered" event, but that funnily gets to duplicated loading of content. 我尝试仅在“渲染的”事件上调用ias.next(),但这很有趣地导致重复加载内容。 I suppose because somehow a scroll event gets triggered then... 我想是因为然后以某种方式触发了滚动事件...

Ok, it seems, the problem is, that the next url gets loaded AFTER "rendered" is called. 好的,看来,问题是,调用“ rendered” 加载了下一个URL。 Don't ask me why... 不要问我为什么...

This seems like a pretty painless way to fix it without being to "hackish". 这似乎是一种无需费力就可以轻松修复的方法。 Just fast-forwarding loading of the new next url. 只是快速加载新的下一个URL。 Doesn't seem to break anything in my testing... 在我的测试中似乎没有破坏任何东西...

ias.on("loaded", $.proxy(function(data, items)
{
    this.nextUrl = this.getNextUrl(data); // fast forward for next() in on.'rendered'
}, ias));

ias.on('rendered',$.proxy(function(items)
{
   if($(CONTAINER).height() <= $(window).height()) // call until scroll bars are shown
   {
      this.next();
   }
}), ias);

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

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