automatically detect web browser window width change?

前端 未结 8 1434
清酒与你
清酒与你 2021-02-01 16:20

i know that you with $(window).width() can get the size of the web browser.

i want to detect when the user change the size of his web browser so i could readjust the col

8条回答
  •  广开言路
    2021-02-01 17:13

    You might want to use debounce : https://davidwalsh.name/javascript-debounce-function

    Otherwise the

    window.addEventListener("resize")
    

    Will fire the whole time as the window resize is in progress. Which will tax your CPU overhead.

提交回复
热议问题