Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 690 Bytes

debounce-throttle-pause.md

File metadata and controls

25 lines (19 loc) · 690 Bytes

Javascript debounce / throttle / pause

Throttle will call function at beginning, and then again every Xms if the event is still firing.

Debounce will wait Xms has elapsed until function is called.

Custom

resize_timeout = null
resize_throttle = 250

$(window).on 'resize', ->
  clearTimeout(resize_timeout)
  window.resize_timeout = setTimeout(->
    do_something_here()
  , resize_throttle);