backup
This commit is contained in:
19
src/hooks/use-mobile.ts
Normal file
19
src/hooks/use-mobile.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as React from "react"
|
||||
|
||||
const MOBILE_BREAKPOINT = 768
|
||||
|
||||
export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
||||
|
||||
React.useEffect(() => {
|
||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
||||
const onChange = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||
}
|
||||
mql.addEventListener("change", onChange)
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||
return () => mql.removeEventListener("change", onChange)
|
||||
}, [])
|
||||
|
||||
return !!isMobile
|
||||
}
|
||||
21
src/hooks/useGlaze.ts
Normal file
21
src/hooks/useGlaze.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
'use client'
|
||||
import { useState, useEffect,useMemo } from 'react'
|
||||
import gsap from 'gsap'
|
||||
import glaze from 'glazejs'
|
||||
export default function useGlaze() {
|
||||
const [glazeInit] = useMemo(() => false,[]);
|
||||
useEffect(() => {
|
||||
console.log(glazeInit)
|
||||
if (!glazeInit) {
|
||||
console.log("initilizing glaze")
|
||||
glaze({
|
||||
lib: {
|
||||
gsap: {
|
||||
core: gsap
|
||||
}
|
||||
}
|
||||
});
|
||||
setGlazeInit(true)
|
||||
}
|
||||
},[])
|
||||
}
|
||||
Reference in New Issue
Block a user