[英]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 我已经知道的,在这种情况下不打算使用
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. 对于某些每秒触发几次的事件(例如
resize
和scroll
, keydown
等),这可能并不明显,但是用户可以将它们作为单个事件保留。
If multiple handler calls cause troubles, they can be omitted by using a debouncer . 如果多个处理程序调用引起麻烦,则可以使用debouncer将其忽略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.