Skip to content

Instantly share code, notes, and snippets.

@stoyan
Created July 14, 2022 18:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stoyan/eaa436661f55a7e01b23c85149763a4f to your computer and use it in GitHub Desktop.
Save stoyan/eaa436661f55a7e01b23c85149763a4f to your computer and use it in GitHub Desktop.
let i = document.querySelector('input.waterfall-transparency');
let up = true;
i.value = parseFloat(i.min);
i.dispatchEvent(new Event('change'));
function animate() {
const curr = parseFloat(i.value);
const max = parseFloat(i.max);
const min = parseFloat(i.min);
const step = parseFloat(i.step);
i.value = up ? curr + step : curr - step;
i.dispatchEvent(new Event('change'));
if (parseFloat(i.value) === max || parseFloat(i.value) === min) {
up = !up;
}
}
let inter = setInterval(animate, 20);
//clearTimeout(inter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment