This file contains 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
/** | |
* Smooth Scroll Script | |
* URL: https://gist.github.com/patrickkahl/641f0b5c80d3fbdf174dac4ee8d60fb1 | |
* | |
* POLYFILLS: | |
* - https://github.com/iamdustan/smoothscroll | |
* - https://github.com/w3c/IntersectionObserver/tree/master/polyfill | |
*/ | |
import 'intersection-observer' | |
import 'core-js/features/promise' |
This file contains 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
myString.replace(/[^\x20-\x7E]/gmi, "") |
This file contains 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 isElementInViewport(el) { | |
const rect = el.getBoundingClientRect(); | |
const viewPortHeight = | |
window.innerHeight || document.documentElement.clientHeight; | |
const topBottom = | |
(rect.top > 0 && rect.top < viewPortHeight) || | |
(rect.bottom > 0 && rect.bottom < viewPortHeight) || | |
(rect.top <= 0 && rect.height + rect.top >= viewPortHeight); | |
// @TODO LeftRight |
This file contains 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 throttle(fn, threshhold = 250, scope, args = []) { | |
let last, deferTimer; | |
return function() { | |
const context = scope || this; | |
const now = +new Date(); | |
const eventArgs = arguments; | |
if (last && now < last + threshhold) { | |
// hold on to it | |
clearTimeout(deferTimer); |
This file contains 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 hyphenToCamelCase(string) { | |
return string.replace('data-', '').replace(/-([a-z])/g, string => { | |
return string[1].toUpperCase(); | |
}); | |
} | |
function camelCaseToHyphen(string) { | |
return `data-${string.replace(/([A-Z])/g, string => { | |
return `-${string.toLowerCase()}`; | |
})}`; |
This file contains 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 onScrollOnce(fn, scope) { | |
let mw1 = 0, | |
mw2 = 0; | |
let lock; | |
return function() { | |
const context = scope || this; | |
const args = arguments; | |
const e = args[0]; | |
const d = e.deltaY; |