-
- var prev = parent.getScroll();
- var prevbottom = parent.getScrollSize().y;
- var prevsize = parent.getSize();
-
- /* fixes an IE bug */
- if(prevbottom < prevsize.y)
- prevbottom = prevsize.y;
-
- return prev.y + prevsize.y == prevbottom;
+
+ var scrollPos = parent.getScroll().y;
+ var linesHeight = parent.getScrollSize().y;
+ var windowHeight = parent.clientHeight;
+
+ /*
+ * fixes an IE bug: the scrollheight is less than the actual height
+ * when the div isn't full
+ */
+ if(linesHeight < windowHeight)
+ linesHeight = windowHeight;
+
+ return scrollPos + windowHeight >= linesHeight - 3; /* window of error */