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

92
Views
No estoy seguro de cómo usar addEventListener para ver la consulta de medios

Estoy tratando de ejecutar una función cuando la ventana cambia de tamaño y alcanza un tamaño determinado. Lo siguiente estaba funcionando perfectamente:

 var mediaQuery = window.matchMedia("(max-width: 480px)") mobileSlider(mediaQuery) // Call listener function at run time mediaQuery.addListener(mobileSlider) // Attach listener function on state changes

Sin embargo, recibí una advertencia de que addListener está obsoleto, por lo que estoy intentando cambiarlo sin mucho éxito. He intentado lo siguiente, pero no funciona. ¿Qué debería estar haciendo?

 var mediaQuery = window.matchMedia("(max-width: 480px)") mobileSlider(mediaQuery) // Call listener function at run time window.addEventListener('resize', mobileSlider) // Attach listener function on state changes

También probé window.addEventListener('resize', mobileSlider(mediaQuery)) sin éxito.

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

0

Puede intentar agregar un detector de eventos en el evento de change de MediaQueryList.

Creo que esto podría ayudar con su problema, eche un vistazo aquí: https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#examples

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!