Created
May 16, 2020 19:15
-
-
Save leemartin/46392248e1924f739a5ece1d8c3d4654 to your computer and use it in GitHub Desktop.
Basic Javascript hooks of Shelter In Space "Scanner" transition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
methods: { | |
beforeEnter(el) { | |
el.style.cssText = "clip-path: inset(0 0 100% 0)" | |
}, | |
enter(el, done) { | |
let scan = { percent: 100 } | |
anime({ | |
targets: scan, | |
percent: 0, | |
duration: 2000, | |
easing: "linear", | |
update() { | |
el.style.cssText = `clip-path: inset(0 0 ${scan.percent}% 0)` | |
document.getElementById('scan').style.top = `${100 - scan.percent}%` | |
}, | |
complete() { | |
done() | |
} | |
}) | |
}, | |
leave(el, done) { | |
let scan = { percent: 0 } | |
anime({ | |
targets: scan, | |
percent: 100, | |
duration: 2000, | |
easing: "linear", | |
update() { | |
el.style.cssText = `clip-path: inset(${scan.percent}% 0 0 0)` | |
}, | |
complete() { | |
done() | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment