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 characters
| (function() { | |
| var observer = new IntersectionObserver(function(entries) { | |
| if(entries[0].isIntersecting === true) { | |
| // your work here... | |
| } | |
| //... same for all elemensts if there are more than one. or just check with cycle | |
| //threshold from 0 - just became visible to 1 - fully visible | |
| }, { threshold: [0.5] }); | |
| observer.observe(/*elements to observe*/); |
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 characters
| const getHashVar = hash_var => | |
| location.hash.includes(hash_var + '=') ? location.hash.split(hash_var + '=')[1].replace(/&.*/g, "") : ""; |
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 characters
| function mapDOM(element, json) { | |
| var treeObject = {}; | |
| // If string convert to document Node | |
| if (typeof element === "string") { | |
| if (window.DOMParser) { | |
| parser = new DOMParser(); | |
| docNode = parser.parseFromString(element,"text/xml"); | |
| } else { // Microsoft strikes again | |
| docNode = new ActiveXObject("Microsoft.XMLDOM"); |