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
| // Some event attached to a parent element | |
| this.parent.addEventListener('click', this.handleItemsClick.bind(this), false); | |
| function handleItemsClick(e) { | |
| // e.currentTarget is the element that the event was attached to. this.parent here | |
| for (var target = e.target; target && target !== e.currentTarget; target = target = target.parentNode) { | |
| if (target.matches('.child-selector')) { | |
| // Do whatever |
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
| $video-total-margin: 96px; | |
| $overlay-bg-color: #000; | |
| $close-button-bg-color: #333; | |
| .video-overlay { | |
| background-color: $overlay-bg-color; | |
| display: flex; | |
| height: 100%; | |
| left: 0; | |
| opacity: 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 characters
| /** | |
| * Timeout promise that can cancel a long running promise | |
| * using Promise.race | |
| */ | |
| function timeoutPromise(delay) { | |
| return new Promise(function(resolve, reject) { | |
| setTimeout(function(){ | |
| reject("Timeout!"); | |
| }, delay); |
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 timeoutfunc(fn,delay) { | |
| var intv = setTimeout(function() { | |
| intv = null; | |
| fn(new Error("Timeout")); | |
| }, delay); | |
| return function() { | |
| // timeout hasn't happened yet? | |
| if(intv) { | |
| clearTimeout(intv); |
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
| <div class="fullscreen" data-img-width="1500" data-img-height="900"> <---- because its a background image, we need the width and height | |
| // whatever here. If it was a normal image tag, we could just get it off | |
| </div> the image | |
| /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| .fullscreen { | |
| width: 100%; | |
| height: 100%; | |
| background-image:url('http://someimage.jpg'); |
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
| var docElem = window.document.documentElement; | |
| function getViewportH() { | |
| var client = docElem['clientHeight'], | |
| inner = window['innerHeight']; | |
| if( client < inner ) | |
| return inner; | |
| else | |
| return client; |
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
| var attach = require('attach.js'); | |
| var utils = require('./helpers/utils'); | |
| var constants = require('./helpers/const'); | |
| /** | |
| * Create a new accordion object | |
| * @param {HTMLElement} el | |
| */ | |
| function Accordion(el) { |
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 whichAnimationEndEvent(){ | |
| var el = document.createElement('fakeelement'); | |
| var animationsEvents = { | |
| 'WebkitAnimation' : 'webkitAnimationEnd', | |
| 'OAnimation' : 'oAnimationEnd', | |
| 'msAnimation' : 'MSAnimationEnd', | |
| 'animation' : 'animationend' | |
| }; | |
| for(var t in animationsEvents){ |
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
| var latestKnownScrollY = 0, | |
| ticking = false; | |
| function onScroll(){ | |
| latestKnownScrollY = window.scrollY; | |
| requestTick(); | |
| } |