Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
¿Cómo no recibir spam con mouseover y mouseout (por tiempo)?

https://jsfiddle.net/0bt3hy29/6/

 function chandgeBackgroundImageOnMouse() { house.addEventListener("mouseover", ()=>{ bgImage.style.backgroundImage = home is_paused = true }) house.addEventListener("mouseout", ()=>{ is_paused = false }) }

Cuando pasa el mouse sobre el elemento "casa" y luego lo aleja, todo funciona como debería. Pero si pasa el mouse sobre y hacia afuera muy rápidamente, el control deslizante automático se romperá.

Entonces, veo 2 opciones.

  1. Para hacer que reaccione solo después de un intervalo de 3 segundos (se pasa el mouse y luego se aleja; solo después de 3 segundos se puede pasar el mouse una vez más)

  2. Para hacer que reaccione solo cuando se cambió la imagen (es pasar el mouse, luego alejar el mouse, y solo después de que se cambió la imagen, se puede pasar el mouse una vez más)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su código es recursivo con intervalo, por lo que crea recursivamente nuevas instancias de muchas cosas. En su lugar, intente esto.

 const car = "url('https://images.unsplash.com/photo-1580273916550-e323be2ae537?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=464&q=80')" const home = "url('https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1175&q=80')" const candles = "url('https://images.unsplash.com/photo-1593542468714-ac3ba4b38d43?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1169&q=80')" const data = [ car, home, candles, ] const house = document.querySelector('#house') const avto = document.querySelector('#avto') const bgImage = document.querySelector('.img-of-dog') let current = 0; function intervalMethod(){ bgImage.style.backgroundImage = data[current] current = ++current % data.length } let changeTimeset = setInterval(()=>{ intervalMethod(); }, 2000) house.addEventListener("mouseover", ()=>{ clearInterval(changeTimeset); bgImage.style.backgroundImage = home }) house.addEventListener("mouseout", ()=>{ changeTimeset = setInterval(()=>{ intervalMethod(); }, 2000) })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!