mirror of
https://github.com/mmahdium/portfolio.git
synced 2026-08-16 21:14:31 +03:30
Initial commit (secrets removed)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { useState } from '#imports'
|
||||
|
||||
export function useLocaleSwitching() {
|
||||
const isLocaleSwitching = useState<boolean>('is-locale-switching', () => false)
|
||||
|
||||
let timer: number | null = null
|
||||
|
||||
const startLocaleSwitching = (duration = 600) => {
|
||||
if (!import.meta.client) return
|
||||
isLocaleSwitching.value = true
|
||||
document.documentElement.classList.add('locale-switching')
|
||||
if (timer) {
|
||||
window.clearTimeout(timer)
|
||||
timer = null
|
||||
}
|
||||
timer = window.setTimeout(() => {
|
||||
isLocaleSwitching.value = false
|
||||
document.documentElement.classList.remove('locale-switching')
|
||||
timer = null
|
||||
}, duration)
|
||||
}
|
||||
|
||||
return {
|
||||
isLocaleSwitching,
|
||||
startLocaleSwitching
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user