Add view transition
parent
54ed75b7b7
commit
75a1201d4f
21
app.vue
21
app.vue
|
@ -22,17 +22,28 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
this.themeChangeListener = (event) => {
|
||||
this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => {
|
||||
this.$appState.theme = event.theme;
|
||||
this.$appState.darkTheme = event.dark;
|
||||
EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark });
|
||||
});
|
||||
if (!document.startViewTransition) {
|
||||
this.applyTheme(event);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
document.startViewTransition(() => this.applyTheme(event));
|
||||
};
|
||||
|
||||
EventBus.on('theme-change', this.themeChangeListener);
|
||||
},
|
||||
beforeUnmount() {
|
||||
EventBus.off('theme-change', this.themeChangeListener);
|
||||
},
|
||||
methods: {
|
||||
applyTheme(event) {
|
||||
this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => {
|
||||
this.$appState.theme = event.theme;
|
||||
this.$appState.darkTheme = event.dark;
|
||||
EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark });
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue