Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
How to toggle shake animation on scroll only when a specific page level is reached, using react hooks or css?

I need help with shaking animation on my picture. The idea is that I would like to toggle shake animation only if the all picture became visible on the page. I try to do it in the code below but it is not working, I am using the reshake package and actually, the animation happens only if hover on it.

App:

import React, { useState} from "react";
import { ShakeRotate } from "reshake";

const App = () => {
  const [shake, setShake] = useState(false);

  const toggleShake = () => {
    if (window.scrollY >= 30) {
      setShake(true);
    } else {
      setShake(false);
    }
  };

  window.addEventListener("scroll", toggleShake);

  return (
      <div className="app">
        <ShakeRotate className={shake && "sc-furwcr fZevBE mobile_png"} h={15}>
          <img src="/images/mobile.png" className="mobile" alt="mobile" />
        </ShakeRotate>
      </div

app.css:

.app {
  position: absolute;
  top: 21%;
  left: 80%;
  transform: translate(-50%, -50%);
}
.mobile {
  height: 350px;
  width: 200px;
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda