Skip to content

Instantly share code, notes, and snippets.

View justenh's full-sized avatar

Justen Holter justenh

View GitHub Profile
@justenh
justenh / animate.js
Last active December 12, 2024 18:57
Animates a function at a given FPS.
/**
* Throttles an animation callback at a specified FPS.
* @param {number} The target frame rate.
* @param {function} The callback to trigger at the specified FPS.
*/
const animate = (fps, fn, startingFrame = 1) => {
const fpsInterval = 1000 / fps;
let then = window.performance.now();
let now = then;
let elapsed = 0;
@justenh
justenh / mobile-meta-tags.html
Created December 4, 2015 16:23
Viewport Meta Tags
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
@justenh
justenh / fit.js
Last active August 29, 2015 14:01
JS scale to fit/fill
/**
*
*/
function getScaleTofit(width, height, maxWidth, maxHeight)
{
return Math.min(maxWidth / width, maxHeight / height);
}
/**
*