Skip to content

Instantly share code, notes, and snippets.

@acidjazz
Created September 3, 2021 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acidjazz/a8e1620e24d01d51d5f00a2b00605d32 to your computer and use it in GitHub Desktop.
Save acidjazz/a8e1620e24d01d51d5f00a2b00605d32 to your computer and use it in GitHub Desktop.
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