tupali_fork/librerias/infinite.php
2017-11-06 12:59:58 -05:00

109 lines
3.6 KiB
PHP

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Image</title>
<script src="jquery/jquery-2.1.4.min.js" ></script>
<script src="bootstrap/js/bootstrap.min.js" ></script>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css?" >
<script type="text/javascript">
$(document).ready(function () {
loadArticle(1);
loadArticle(2);
loadArticle(3);
var count = 4;
$("div").scroll(function () {
var offset = $('#scroll-content div').length;
var $this = $(this);
var height = this.scrollHeight - $this.height(); // Get the height of the div
var scroll = $this.scrollTop(); // Get the vertical scroll position
var isScrolledToEnd = (scroll >= height);
$(".scroll-pos").text(scroll);
$(".scroll-height").text(height);
if (isScrolledToEnd) {
loadArticle(count);
// var additionalContent = GetMoreContent(); // Get the additional content
//alert("hola");
count++;
document.getElementById("paginas").innerHTML=count;
/*
var newDiv = document.createElement("div");
newDiv.setAttribute("class", "container");
$.ajax({
//url: 'get-post.php?variable='+(offset),
url: '../milfs/api.php?id=74&tipo=simple&formato=li&registros=1&pagina='+offset,
dataType: 'html',
success: function(html) {
// $('#scroll-contentx').append(html);
var contenido = html;
// $('#loading').hide();
newDiv.innerHTML = contenido;
//newDiv.innerHTML.append(html);
}
});
document.getElementById("scroll-content").appendChild(newDiv);
document.getElementById("paginas").innerHTML=offset;
// checkForNewDiv();
*/
// $this.append(additionalContent); // Append the additional content
}
});
});
function loadArticle(pageNumber){
var newDiv = document.createElement("div");
newDiv.setAttribute("class", "container");
// var contenido ="Hola mundo "+ pageNumber;
// newDiv.innerHTML = contenido;
//newDiv.innerHTML.append(html);
document.getElementById("scroll-content").appendChild(newDiv);
$.ajax({
//url: 'get-post.php?variable='+(offset),
url: '../milfs/api.php?id=74&tipo=simple&formato=li&registros=1&pagina='+pageNumber,
type:'POST',
dataType: 'html',
success: function(html) {
// $('#scroll-contentx').append(html);
var contenido = html;
newDiv.innerHTML = contenido;
}
});
}
</script>
</head>
<body>
<div class='container' style="overflow-y: scroll; overflow-x: hidden; height: 400px; border: 1px solid red;">
<div id="wrapper">
<div id="scroll-content">
<div id='posts'></div>
</div>
</div>
</div>
<div id='paginas'>las paginas</div>
Scroll Height: <span class="scroll-height"></span> <br/>
Scroll position: <span class="scroll-pos"></span>
</body>
</html>
shareimprove this answer