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

413
Views
¿Cómo esperar el 'fin' del evento 'cambiar el tamaño' y solo luego realizar una acción?

Así que actualmente uso algo como:

 $(window).resize(function(){resizedw();});

Pero esto se llama muchas veces mientras continúa el proceso de cambio de tamaño. ¿Es posible capturar un evento cuando finaliza?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Puede usar setTimeout() y clearTimeout()

 function resizedw(){ // Haven't resized in 100ms! } var doit; window.onresize = function(){ clearTimeout(doit); doit = setTimeout(resizedw, 100); };

Ejemplo de código en jsfiddle .

over 4 years ago · Santiago Trujillo Report

0

Tuve suerte con la siguiente recomendación: http://forum.jquery.com/topic/the-resizeend-event

Aquí está el código para que no tenga que buscar en el enlace y la fuente de su publicación:

 var rtime; var timeout = false; var delta = 200; $(window).resize(function() { rtime = new Date(); if (timeout === false) { timeout = true; setTimeout(resizeend, delta); } }); function resizeend() { if (new Date() - rtime < delta) { setTimeout(resizeend, delta); } else { timeout = false; alert('Done resizing'); } }

¡Gracias sime.vidas por el código!

over 4 years ago · Santiago Trujillo Report

0

Este es el código que escribo según la respuesta de @Mark Coleman:

 $(window).resize(function() { clearTimeout(window.resizedFinished); window.resizedFinished = setTimeout(function(){ console.log('Resized finished.'); }, 250); });

¡Gracias Marcos!

over 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!