Update 'frontend.js'

This commit is contained in:
Maxwell Drake 2024-04-07 21:37:39 +00:00
parent 44b926e6f3
commit 58df23243e

View file

@ -328,13 +328,32 @@ function fadeIn(el, ms) {
} }
} }
function spin(el, ms){ function spin(elementID, duration) {
elem = getElementById(el); const element = document.getElementById(elementID);
for (i = 0; i < (ms / 361); i++) { if (!element) {
elem.style.transform = 'rotate(' + i + 'deg)'; console.error(`Element with ID '${elementID}' not found.`);
return;
} }
let start;
const animate = (timestamp) => {
if (!start) start = timestamp;
const elapsed = timestamp - start;
const rotation = (elapsed / duration) * 360;
element.style.transform = `rotate(${rotation}deg)`;
if (elapsed < duration) {
requestAnimationFrame(animate);
} else {
start = null;
element.style.transform = 'none'; // Reset transform after animation completes
}
};
requestAnimationFrame(animate);
} }
//Eval alternative //Eval alternative
//Example: exec("alert('Hello, world!')") //Example: exec("alert('Hello, world!')")
function exec(jsCode) { function exec(jsCode) {