Created
November 7, 2017 06:16
-
-
Save nikhilkesari/14d48282e8afe7c6bb9c5543ff954e7b to your computer and use it in GitHub Desktop.
Revisions
-
Nikhil S Kesari created this gist
Nov 7, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ import '../css/main.css'; console.log("message"); (function() { var observer; var index = 0; var options = { root: null, rootMargin: '0px', threshold: 0 } function addNewBoxes(entry) { entry.forEach((change) => { if (change.isIntersecting && index <= 10) { console.log(index); index = ++index; createNewBox(index); } if (index === 10) { observer.disconnect(); } }); } function createNewBox(index) { var newDiv = document.createElement("div"); var newContent = document.createTextNode(index); newDiv.setAttribute('class', 'bigbox'); newDiv.appendChild(newContent); document.getElementById("main").appendChild(newDiv); observer.observe(newDiv); } observer = new IntersectionObserver(addNewBoxes, options); createNewBox(0); })(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ <!DOCTYPE html> <html> <head> <title>Hello Webpack</title> </head> <body> <div id="top"></div> <div id="main"></div> <footer> <div class="footer" id="footer">Footer</div> </footer> <script src="app.js"></script> </body> </html>