Polymer 聚合物:如何在聚合物2中使用铁卷轴阈值

Polymer 聚合物:如何在聚合物2中使用铁卷轴阈值,polymer,Polymer,我想使用iron scroll threshold元素,以便在滚动时加载更多数据,但我在webcomponents上发现的一个示例似乎不起作用。 它不会在控制台返回任何内容。这是我的代码: <iron-scroll-threshold lower-threshold="400" on-lower-threshold="loadMoreData" id="threshold"> <iron-list scroll-target="threshold" items="[[aja

我想使用iron scroll threshold元素,以便在滚动时加载更多数据,但我在webcomponents上发现的一个示例似乎不起作用。 它不会在控制台返回任何内容。这是我的代码:

<iron-scroll-threshold lower-threshold="400" on-lower-threshold="loadMoreData" id="threshold">
  <iron-list scroll-target="threshold" items="[[ajaxResponse]]" as="item">
    <template>
      <div>[[item.name]]</div>
    </template>
  </iron-list>
</iron-scroll-threshold>

my function: loadMoreData() { 
    console.log("Inside ..."); 

    asyncStuff(function done() { 
        ironScrollTheshold.clearTriggers(); 
    }
);    

[[项目名称]]
我的函数:loadMoreData(){
控制台日志(“内部…”);
asyncStuff(函数完成(){
IronScrollTheShared.clearTriggers();
}
);    

铁阈值似乎有很多问题,如下所述:

我建议不要使用它,只需实现您自己的滚动事件监听器,如下所示:

    const lowerThreshold = 500
    window.addEventListener('scroll', function(e) {
      var body = document.body // For Chrome, Safari and Opera
      var html = document.documentElement // Firefox and IE
      var documentHeight = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight )
      var windowHeight = window.innerHeight
      var bodyScrollBottom = documentHeight - windowHeight - body.scrollTop
      var htmlScrollBottom = documentHeight - windowHeight - html.scrollTop

      //to take in account for difference browsers
      if( bodyScrollBottom < lowerThreshold ){
        //below the threshold. Do something
        //for Chrome, Safari and Opera
      }else if( htmlScrollBottom < lowerThreshold){
        //below thre threshold. Do something
        //for Firefox and IE
      }
    })
const lowerThreshold=500
window.addEventListener('scroll',函数(e){
var body=document.body//用于Chrome、Safari和Opera
var html=document.documentElement//Firefox和IE
var documentHeight=Math.max(body.scrollHeight、body.offsetHeight、html.clientHeight、html.scrollHeight、html.offsetHeight)
var windowHeight=window.innerHeight
var bodyScrollBottom=documentHeight-windowHeight-body.scrollTop
var htmlscrollbooth=documentHeight-windowHeight-html.scrollTop
//考虑不同的浏览器
如果(车身滚动底部<下部滚动保持){
//低于临界值。做点什么
//用于Chrome、Safari和Opera
}else if(htmlScrollBottom
当我将函数代码放在同一条注释中时,它会返回一个错误已接受,谢谢-你知道这个问题的答案吗???@Azim检查这里还有一个我将尝试的演示,谢谢它返回我这个错误:Uncaught TypeError:this.$.mytras.clearTriggers在setTimeout时不是函数(my-view1.html:54)