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

114
Views
Detecting an element is being resized with Javascript

With CSS' resize rule, one can allow an element to be resized like so:

.someClass {
  resize: vertical/horizontal/both
}

However, I'm unable to find a way to detect an element is being resized.

HTML' Drag and Drop API has built-in events to detect dragging which are documented here.

Is there a similar way I can detect when an element is being dragged, or make my own version?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to get the element by a selector. For example:

const element = document.querySelector('.someClass');

And then you can use resizeObserver:

const resizeObserver = new ResizeObserver((entries) => {
  for (let entry of entries) {
     console.log(entry)
  }
  console.log('Size changed');
  
});

resizeObserver.observe(element);

For more resources: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver

about 4 years ago · Santiago Trujillo 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!