当用户到达页面右侧时加载新内容

时间:2022-07-01 20:32:21

There is plenty of plugins that allow to load content when the user reaches the bottom of the page, however I can't find jquery plugin that would allow you to load content when user reaches the right side of the document.

有很多插件允许在用户到达页面底部时加载内容,但是我找不到允许您在用户到达文档右侧时加载内容的jquery插件。

Is there a good strategy to do this ?

有一个很好的策略来做到这一点?

Is there a good plugin that does this ?

这是一个很好的插件吗?

Thanks, Peter

2 个解决方案

#1


1  

$('div').scroll(function (){
  var padder = 50;
  if( $(this).scrollLeft() >= $(this).scrollWidth -padder){
     //load more content as the user has scrolled 50px less than, the end, 
  }
})

I think something like this would do it ....

我认为像这样的事情会......

#2


0  

This does the job nicely:

这很好地完成了这项工作:

//Scroll
  var padder = 150;
  $(document).live('scroll',function (){
     if($(this).scrollLeft() > padder){
    $.post("data.txt", { bla: "1", blu: "ax" },
        function(data) {
         //TODO add a check when reach the end
         padder = padder +200;
         $("#events_list").width($("#events_list").width()+200);
         $("#events_list").append(data);
        },"text");
     }
  }); 

#1


1  

$('div').scroll(function (){
  var padder = 50;
  if( $(this).scrollLeft() >= $(this).scrollWidth -padder){
     //load more content as the user has scrolled 50px less than, the end, 
  }
})

I think something like this would do it ....

我认为像这样的事情会......

#2


0  

This does the job nicely:

这很好地完成了这项工作:

//Scroll
  var padder = 150;
  $(document).live('scroll',function (){
     if($(this).scrollLeft() > padder){
    $.post("data.txt", { bla: "1", blu: "ax" },
        function(data) {
         //TODO add a check when reach the end
         padder = padder +200;
         $("#events_list").width($("#events_list").width()+200);
         $("#events_list").append(data);
        },"text");
     }
  });