tupali/librerias/infinite.php

125 lines
4.6 KiB
PHP
Raw Normal View History

2017-11-06 16:23:43 +00:00
<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>
2017-11-06 16:49:07 +00:00
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css?" >
2017-11-06 16:23:43 +00:00
<script type="text/javascript">
$(document).ready(function () {
2017-11-06 16:49:07 +00:00
var count = 1;
2017-11-06 16:23:43 +00:00
$("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>
2017-11-06 16:49:07 +00:00
<div class='container' style="overflow-y: scroll; overflow-x: hidden; height: 400px; border: 1px solid red;">
2017-11-06 16:23:43 +00:00
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p> <p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p> <p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p> <p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<p>This is the div content</p>
<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