This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
toascii/resources/gif-animation.js

23 lines
587 B
JavaScript

setTimeout(function() {
var scripts = document.getElementsByTagName('script');
var thisScript = scripts[scripts.length - 1];
var frameContainer = thisScript.previousSibling;
var frames = frameContainer.children;
var currentFrame = frames[0];
function animate() {
currentFrame.style.display = 'block';
var delay = parseInt(currentFrame.dataset['delay']);
setTimeout(function() {
currentFrame.style.display = 'none';
currentFrame = currentFrame.nextSibling;
if (currentFrame == null)
currentFrame = frames[0];
animate();
}, delay);
}
animate();
}, 100);