I'm trying to create tiltable 3d elements using js. But it shows me this error not working in my js code. Can anyone help me?
const box = document.querySelector('.container')
const boxReact = box.getBoundingClientRect()
box.addEventListener('mousemove', e => {
const xPosition = (e.clientX - boxReact.left) / boxReact.width
const yPosition = (e.clientY - boxReact.top) / boxReact.height - 0.6
const xOffset = -(xPosition - 0.6)
const dxNorm = Math.min(Math.max(xOffset, - 0.6), 0.6)
box.style.transform = `perspective(1000px)
rotateY(${dxNorm*45}deg)
rotateX(${yPosition*45}deg) `
})
box.addEventListener('mouseleave', () => {
box.style.transform = 'none'
})