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

125
Views
No se puede cambiar el tamaño de Rect con eventos del mouse

Estoy tratando de cambiar el tamaño del rectángulo dentro del SVG usando eventos del mouse. Actualmente, estoy trabajando en el borde inferior derecho, para eso, creé otra forma de círculo y estoy aplicando eventos en esa forma para cambiar el tamaño del rectángulo. No sé por qué cuando empiezo a cambiar el tamaño primero se vuelve pequeño y luego comienza a cambiar el tamaño.

 const min = 54; let initialWidth = 0, initialHeight = 0, mouseX = 0, mouseY = 0; rightBottomCorner.addEventListener('mousedown', function(evt: any) { getMousePositions(evt); getElementDimensions(); evt.stopPropagation(); window.addEventListener('mousemove', scale); window.addEventListener('mouseup', removeScale); }); function getMousePositions(evt: any) { mouseX = evt.pageX; mouseY = evt.pageY; } function getElementDimensions() { selectedRect = rect; initialWidth = selectedRect.clientWidth; initialHeight = selectedRect.clientHeight; } function scale(evt: any) { selectedRect = rect; const width = initialWidth + (evt.pageX - mouseX); const height = initialHeight + (evt.pageY - mouseY); if (width > min) { selectedRect.setAttributeNS(null, 'width', width as unknown as string); } if (height > min) { selectedRect.setAttributeNS(null, 'height', height as unknown as string); } } function removeScale() { window.removeEventListener('mousemove', scale); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Está pasando las funciones a addEventlistener antes de que se definan. Tiene que mover la función rightBottomCorner.addEventListener debajo de su función removeScale . Entonces el cambio de tamaño funciona.

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!