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 distance = distanceBetween({ | |
| lat: 59.329323, | |
| lng: 18.068581 | |
| }, { | |
| lat: 57.708870, | |
| lng: 11.974560 | |
| }); | |
| function getRadius(x) { | |
| return x * Math.PI / 180; |
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
| /** | |
| * Turns a list of nodes into an array | |
| * @param { NodeList } nodeList | |
| * @return { Array } | |
| */ | |
| export function nodesToArray(nodeList) { | |
| return [...nodeList]; | |
| return Array.from(nodeList); | |
| return [].slice.call(nodeList); | |
| return Array.prototype.slice.call(nodeList); |
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
| <?php | |
| /** | |
| * Check if on posts-page | |
| */ | |
| function is_page_for_posts () { | |
| return ( is_home() || (is_archive() && ! is_post_type_archive() ) ); | |
| } | |
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
| /** | |
| * isUndefined | |
| * Check if object is undefined | |
| * @param {Anything} value | |
| * @return {Boolean} Returns `true` if `value` is `undefined`, else `false`. | |
| */ | |
| export function isUndefined(value) { | |
| return value === undefined; | |
| } |
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
| /** | |
| * Get closest DOM element up the tree that contains a class, ID, or data attribute | |
| * @param {Node} elem The base element | |
| * @param {String} selector The class, id, data attribute, or tag to look for | |
| * @return {Node} Element or Null if no match | |
| */ | |
| export function getClosest (elem, selector) { | |
| let firstChar = selector.charAt(0); | |
| // Get closest match |
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 orientationEls = doc.querySelectorAll('.js-orientation'); | |
| window.addEventListener('deviceorientation', function(eventData) { | |
| var yTilt = Math.round((-eventData.beta + 90) * (40/180) - 40); | |
| var xTilt = Math.round(-eventData.gamma * (20/180) - 20); | |
| if (xTilt > 0) { | |
| xTilt = -xTilt; | |
| } else if (xTilt < -40) { | |
| xTilt = -(xTilt + 80); |
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 PREFIXES = ['', 'Moz', 'webkit', 'Webkit', 'O', 'ms']; | |
| function applyStyle(prop, value, element) { | |
| const first = prop[0]; | |
| const trail = prop.slice(1); | |
| PREFIXES.forEach(prefix => { | |
| let name = prefix ? (prefix + first.toUpperCase()) : first.toLowerCase(); | |
| name += trail; |
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
| /* If js doesnt load or just before it does: hide element for 2 seconds. */ | |
| .no-js .u-showIfNoJs { | |
| animation: showAfterLong 2000ms; | |
| } | |
| /* Hide when js loads and remove animation */ | |
| .js .u-showIfNoJs { | |
| animation: none; | |
| display: none; | |
| } |
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
| /** | |
| * Get a random int between two values | |
| * @param {Int} min | |
| * @param {Int} max | |
| * @return {Int} | |
| */ | |
| export function randomBetween(min = 0, max = 0) { | |
| return Math.floor(Math.random() * (max - min + 1) + min) | |
| } |
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
| export function getMousePosition (e) { | |
| let posX = 0 | |
| let posY = 0 | |
| if (!e) { | |
| e = window.event | |
| } | |
| if (e.pageX || e.pageY) { | |
| posX = e.pageX |
OlderNewer