Delay function from running for n seconds then run it once. (2minute question)

Posted by Ozaki on Stack Overflow See other posts from Stack Overflow or by Ozaki
Published on 2010-05-24T03:21:26Z Indexed on 2010/05/24 3:31 UTC
Read the original article Hit count: 287

Filed under:
|
|

TLDR I have a function that runs on the end of a pan in an openlayers map. Don't want it to fire continously.


I have a function that runs on the end of panning a map. I want it so that it will not fire the function until say 3 secconds after the pan has finished. Although I don't want to queue up the function to fire 10 or so times like setTimeout is currently doing.

How can I delay a function from running for n seconds then run it only once no matter how many times it has been called?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about function