Created
September 3, 2021 18:19
-
-
Save acidjazz/a8e1620e24d01d51d5f00a2b00605d32 to your computer and use it in GitHub Desktop.
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
lottie (): void { | |
if (!process.browser || !window.lottie) return | |
const lottie = window.lottie | |
const container = this.$refs.darkMode as HTMLElement | |
this.darkMode = lottie.loadAnimation({ | |
container, | |
renderer: 'svg', | |
path: '/json/darkMode.json', | |
loop: false, | |
autoplay: false, | |
}) | |
if (this.is_dark) this.darkMode.goToAndStop(114, true) | |
else this.darkMode.goToAndStop(0, true) | |
}, | |
async mode (): Promise<void> { | |
if (this.$colorMode.preference === 'dark') { | |
this.darkMode?.playSegments([160, 228], true) | |
await this.$sleep(400) | |
this.$colorMode.preference = 'light' | |
} else { | |
this.darkMode?.playSegments([0, 114], true) | |
await this.$sleep(400) | |
this.$colorMode.preference = 'dark' | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment