-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimate-favicon.js
More file actions
31 lines (23 loc) · 803 Bytes
/
animate-favicon.js
File metadata and controls
31 lines (23 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var $parent = document.createElement("div")
$gif = document.createElement("img")
,$favicon = document.createElement("link")
// Required for CORS
$gif.crossOrigin = "anonymous"
// $gif.src = "https://drive.google.com/uc?id=1rnsz6ag4Y9HVAykUgaz_C9_bahOkjknr"
$gif.src = "favicon.ico"
$favicon.rel = "icon"
// JS Fiddle always displays the result in an <iframe>,
// so we have to add the favicon to the parent window
window.parent.document.head.appendChild($favicon)
// libgif.js requires the GIF <img> tag to have a parent
$parent.appendChild($gif)
var supergif = new SuperGif({gif: $gif})
,$canvas
supergif.load(()=> {
$canvas = supergif.get_canvas()
updateFavicon()
})
function updateFavicon() {
$favicon.href = $canvas.toDataURL()
window.requestAnimationFrame(updateFavicon)
}