


You can test it by opening the codepen on a new window and resizing the right frame. Right before setTimeout (), we set clearTimeOut () which keeps clearing this setTimeout () timer. Now, we keep setTimeout () function in the resize event. No such event exists in native JavaScript. For those cases we don't usually want to execute them tens of times while the user is still re-sizing the window to reach the desired size.įor these particular cases we can use a very simple trick: var resizeId $ (window ). setTimeout () function clearTimeOut () function Example: We will use setTimeout () so that they function in which we want to be fire after resizing waits for 500ms. If you’re used to something like jQuery UI resizeable, you get events you can bind to during the resizing, but also at the end of resizing. You can achieve this with JavaScript using a Mutation Observer.
Plus (as long as you don’t disable it) the user is still provided a control to resize the