Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 993832f29e
@fredwu
106 lines (96 sloc) 3.301 kb
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Endless Scroll Demo (by Fred Wu)</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<style type="text/css" media="screen">
* { margin: auto; }
body { margin: 20px 0; background: #abc; color: #111; font-family: Helvetica, Arial, Verdana, 'Lucida Grande', sans-serif; }
h1, h3, p { text-align: center; }
div.example { padding: 20px; margin: 10px auto; background: #bcd; width: 750px; }
div.example h3 { margin-bottom: 10px; }
ul, ol { padding: 0; }
#list { width: 50px; height: 150px; overflow-y: scroll; }
#images { width: 600px; height: 550px; overflow-x: hidden; text-align: center; list-style: none; }
.endless_scroll_loader { position: fixed; top: 10px; right: 20px; }
</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.endless-scroll.js"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
$('#list').endlessScroll({
pagesToKeep: 10,
fireOnce: false,
insertBefore: "#list div:first",
insertAfter: "#list div:last",
content: function(i, p) {
console.log(i, p)
return '<li>' + p + '</li>'
},
ceaseFire: function(i) {
if (i >= 10) {
return true;
}
},
intervalFrequency: 5
});
$('#images').scrollTop(101);
var images = $("ul#images").clone().find("li");
$('#images').endlessScroll({
pagesToKeep: 5,
inflowPixels: 100,
fireDelay: 10,
content: function(i, p, d) {
console.log(i, p, d)
return images.eq(Math.floor(Math.random()*8))[0].outerHTML;
}
});
});
</script>
</head>
<body>
<h1>Endless Scroll Demo</h1>
<h3>by <a href="http://fredwu.me/">Fred Wu</a></h3>
<div class="example">
<h3>Ends in 10 calls:</h3>
<ul id="list">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>12</li>
<li>13</li>
<li>14</li>
<li>15</li>
<li>16</li>
<li>17</li>
<li>18</li>
<li>19</li>
<li>20</li>
</ul>
</div>
<div class="example">
<h3>Never ending:</h3>
<ul id="images">
<li><img src="img/grass-blades.jpg" width="580" height="360" alt="Grass Blades" /></li>
<li><img src="img/stones.jpg" width="580" height="360" alt="Stones" /></li>
<li><img src="img/sea-mist.jpg" width="580" height="360" alt="Sea Mist" /></li>
<li><img src="img/pier.jpg" width="580" height="360" alt="Pier" /></li>
<li><img src="img/lotus.jpg" width="580" height="360" alt="Lotus" /></li>
<li><img src="img/mojave.jpg" width="580" height="360" alt="Mojave" /></li>
<li><img src="img/lightning.jpg" width="580" height="360" alt="Lightning" /></li>
<li><img src="img/flowing-rock.jpg" width="580" height="360" alt="Grass Blades" /></li>
</ul>
</div>
<div class="example">
<p>Copyright &copy; <a href="http://fredwu.me/">Fred Wu</a></p>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.