简体   繁体   中英

Post window resize event, but before page is visible to user?

I am trying to get height of a div, after window.resize method, so that the element has its new height, but before display the output to the user, so I could change height of another div.

What I know already and not so tempted to use in this case

  • Use percentages for setting height of another div
  • Use fixed heights
  • Use CSS instead
  • use clientHeight
  • use innerheight

so back to question

Is there any event in JS or JQuery which could get me state where document is re sized but not displayed to user yet on the screen.

 $(window).resize(WindowResizeNow);

You can use $(window).resize() .

When you change the DOM in JS function, DOM is updated immediately, but a page is rendered after the function has been executed.

This might not be obvious in case of some events, which fire several times per second (like resize and scroll , keydown etc.), but user might keep them as a single event.

If multiple handler calls cause troubles, they can be omitted by using a debouncer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM