Skip to content

Commit be7da72

Browse files
committed
added new height fix for buggy sites
1 parent 4100988 commit be7da72

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/sscr.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,24 @@ function init() {
141141
else if (scrollHeight > windowHeight &&
142142
(body.offsetHeight <= windowHeight ||
143143
html.offsetHeight <= windowHeight)) {
144-
root.style.height = "auto";
144+
145+
// DOMChange (throttle): fix height
146+
var pending = false;
147+
var refresh = function() {
148+
if (!pending && html.scrollHeight != document.height) {
149+
pending = true; // add a new pending action
150+
setTimeout(function(){
151+
html.style.height = document.height + 'px';
152+
pending = false;
153+
}, 500); // act rarely to stay fast
154+
}
155+
};
156+
html.style.height = 'auto';
157+
setTimeout(refresh, 10);
158+
addEvent("DOMNodeInserted", refresh);
159+
addEvent("DOMNodeRemoved", refresh);
160+
161+
// clearfix
145162
if (root.offsetHeight <= windowHeight) {
146163
var underlay = document.createElement("div");
147164
underlay.style.clear = "both";

0 commit comments

Comments
 (0)