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

139
Views
¿Cómo usar ResizeObserver para verificar solo el cambio de ancho del cuerpo en JavaScript?

Quiero verificar el cambio de ancho de <body> (no la altura).

¿Hay alguna manera de hacerlo con ResizeObserver?

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

0

Aquí hay un ejemplo. Lea más documentación en https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver .

 function handleWidthChange (width) { console.log(width); } let prevWidth = 0; const observer = new ResizeObserver(entries => { for (const entry of entries) { const width = entry.borderBoxSize?.[0].inlineSize; if (typeof width === 'number' && width !== prevWidth) { prevWidth = width; handleWidthChange(width); } } }); observer.observe(document.body, {box: 'border-box'});
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!