-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
33 lines (26 loc) · 823 Bytes
/
index.js
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
32
33
'use strict'
require('./index.css')
// hosted courtesy of github
const narutoSrc = `https://raw.githubusercontent.com/ngoue/animeXYZ/main/naruto.gif`
module.exports = function (options) {
// get options (defaults set here)
const {duration, size} = Object.assign({
duration: 500,
size: 50,
}, options)
// create and style components
const container = document.createElement('div')
container.id = `animexyz-naruto`
container.style.left = `-${size}px`
container.style.animationDuration = `${(duration/1000)}s`
const img = document.createElement(`img`)
img.src = narutoSrc
img.style.height = `${size}px`
// add elements to the DOM
container.appendChild(img)
document.body.appendChild(container)
// remove after animating
setTimeout(() => {
container.remove()
}, duration)
}