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
// https://codepen.io/dgca/pen/WoJoNB | |
export const ResizeObserver = window.ResizeObserver || class ResizeObserver { | |
constructor(callback) { | |
this.observables = []; | |
// Array of observed elements that looks like this: | |
// [{ | |
// el: domNode, | |
// size: {height: x, width: y} | |
// }] | |
this.boundCheck = this.check.bind(this); |
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
export function rgbToHsl(rgb) { | |
const r = rgb.r / 255 | |
const g = rgb.g / 255 | |
const b = rgb.b / 255 | |
const max = Math.max(r, g, b), min = Math.min(r, g, b) | |
let h, s, l = (max + min) / 2 | |
if (max == min) { | |
h = s = 0 // achromatic |
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 copyRecursively(sourceDir: string, destinationDir: string): void { | |
const files = fs.readdirSync(sourceDir) | |
if (!fs.existsSync(destinationDir)) | |
fs.mkdirSync(destinationDir, { recursive: true }) | |
files.forEach(file => { | |
const sourceFile = path.join(sourceDir, file) | |
const destinationFile = path.join(destinationDir, file) | |
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 constrain(value, min, max) { | |
return Math.min(Math.max(value, min), max) | |
} |
OlderNewer