"Auto scroll loading content"
Bootstrap 3.2.0 Snippet by ugnandish

<link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://code.jquery.com/jquery-2.2.4.js"></script> <div class="container"> <div class="row"> <div class="col-sm-9"> <h1>Test</h1> <div class="scrollContent"> <section class="dynamicContent"> <div id="content"> </div> <div id="loader">LOADING...</div> </section> </div> </div> <div class="col-sm-3"> <h2>Test again</h2> <div class="sticky"> Sticky </div> </div> </div> </div>
.sticky {border:1px dotted orange;} .box1 {width:150px;height:150px;display:inline-block; margin:5px;} #loader {background-color:white;color:red} #loader.active {background-color:red;color:white}
// init controller var controller = new ScrollMagic.Controller(); // build scene var scene = new ScrollMagic.Scene({triggerElement: ".dynamicContent #loader", triggerHook: "onEnter"}) .setPin(".sticky") // pins the element for the the scene's duration .addTo(controller) .on("enter", function (e) { if (!$("#loader").hasClass("active")) { $("#loader").addClass("active"); if (console){ console.log("loading new items"); } // simulate ajax call to add content using the function below setTimeout(addBoxes, 1000, 9); } }); // pseudo function to add new content. In real life it would be done through an ajax request. function addBoxes (amount) { for (i=1; i<=amount; i++) { var randomColor = '#'+('00000'+(Math.random()*0xFFFFFF<<0).toString(16)).slice(-6); $("<div></div>") .addClass("box1") .css("background-color", randomColor) .appendTo(".dynamicContent #content"); } // "loading" done -> revert to normal state scene.update(); // make sure the scene gets the new start position $("#loader").removeClass("active"); } // add some boxes to start with. addBoxes(18);

Related: See More


Questions / Comments: