简体   繁体   English

发布窗口调整大小事件,但在用户看不到页面之前?

[英]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. 我试图在window.resize方法之后获取div的高度,以便该元素具有其新的高度,但是在向用户显示输出之前,我可以更改另一个div的高度。

What I know already and not so tempted to use in this case 我已经知道的,在这种情况下不打算使用

  • Use percentages for setting height of another div 使用百分比设置另一个div的高度
  • Use fixed heights 使用固定高度
  • Use CSS instead 改用CSS
  • use clientHeight 使用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. JS或JQuery中是否有任何事件可以让我知道调整文档大小但尚未在屏幕上显示给用户的状态。

 $(window).resize(WindowResizeNow);

You can use $(window).resize() . 您可以使用$(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. 当您在JS函数中更改DOM时,DOM会立即更新,但是在执行该函数后会呈现一个页面。

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. 对于某些每秒触发几次的事件(例如resizescrollkeydown等),这可能并不明显,但是用户可以将它们作为单个事件保留。

If multiple handler calls cause troubles, they can be omitted by using a debouncer . 如果多个处理程序调用引起麻烦,则可以使用debouncer将其忽略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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