Skip to content

How can i refresh Tilt? #55

Discussion options

You must be logged in to vote

I did it.
If someone will be useful:


const mouseEndterHandler = (event) => {
  event.target.children[0].addEventListener('mousemove', function(e) { 
    let ax = e.offsetX / event.target.children[0].clientWidth
    let ay = e.offsetY / event.target.children[0].clientHeight
    let _ax = Math.min(Math.max(ax, 0), 1);
    let _ay = Math.min(Math.max(ay, 0), 1);
    const tiltX = (1 * (35 / 2 - _ax * 35)).toFixed(2);
    const tiltY = (1 * (_ay * 35 - 35 / 2)).toFixed(2);

    event.target.children[0].style.transform = 'perspective(300px) rotateX('+tiltY+'deg) rotateY('+tiltX+'deg)'
  })
  event.target.children[0].style.transition = 'all 400ms cubic-bezier(0.03, 0.98, 0.24, 0.98) 0s'
  setT…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RedirexStudio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant