There is a so-called "news" tape. There are not news but tiles. Tiles with text that are loaded from the database. so here In VK, when scrolling through the news, the news is automatically loaded by itself. I decided to do something similar. I use JS and the scroolTop () function. I do this:

$(document).ready(function() { var height = screen.height, append_height = height/2, elements = 49, //сколько плиточек append = false; console.log("height " + height); console.log("append_height " + append_height); $(window).scroll(function() { $('a.text').text($(this).scrollTop()); if($(this).scrollTop() > append_height) { $('a.text-1').text("scrollTop() > append_height: " + $(this).scrollTop() + " " + append_height); for(var i = 0;i <= elements; i++) { $('.feed-main ul').append('<li class="link-block">' + i + '</li>'); } append_height+=height; $('a.text-2').text("append_height+=height = " + append_height); console.log("append_height " + append_height); } }); }); 

For debugging, I display information in the console and in tags a .

So. When it comes to these values ​​(debag):

7669 SCROLLTOP ()> APPEND_HEIGHT: 6738 6656 APPEND_HEIGHT + = HEIGHT = 7680

Next, the tiles are not loaded (for the test just made an addition to the end of ul). Why - I can not understand. What could it be?

  • And what does the output code from db look like? - user33274
  • @LenovoID it is not yet implemented. but the essence is this. When scrolling, an ajax request for a servlet will be sent (I make a site in JavaEE). The servlet makes a request to the database, pulls out the elements and returns everything that it pulled out with the answer. When the answer arrives, I, JS, disassemble it all and form tiles in the same way - append (). - Tsyklop
  • pancake - I thought js + php, then I can, but I don’t know about it, forgive me - user33274
  • @LenovoID so i need to understand why from my example they are simply not added below. Why append does not work. Now I just add li-and for the test. I do not pull out of the database yet. - Tsyklop
  • in fact, the usual vertical slider only instead of img you should have news, that is, a certain block which is displayed in a loop and inside it is the very news, I personally would do that - user33274

0