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

104
Views
javascript drag an image after rotation

I'm working on dragging and rotating image on preact and javascript. the problem is, event.offsetX,Y doesn't work propery after I rotate an image. event.LayerX,Y works well, however, they are deprecated.

I tried to use sin, cos, matrix rotation. Is there any methods to solve this problem instead of LayerX,Y??

enter image description here

I used dragg formula below.

const movePosOfBox = useCallback((e: MouseEvent) => {

    const el = document.getElementById("canvas");
    if (el) {
        const elRect = el.getBoundingClientRect();

        let x = e.clientX - elRect.left - imgOffset.x;
        let y = e.clientY - elRect.top - imgOffset.y;

// I used e.offsetX,Y in imgOffset.x,y. but they cant not work on rotated image.

        setBoxPos({ left: x, top: y });
    }
}, []);
about 4 years ago · Juan Pablo Isaza
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!