Skip to content

Commit

Permalink
Fix scroll issue in chrome (fixes tiff#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiff committed May 30, 2012
1 parent 47a517b commit ebafa27
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/selection/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
*/
scrollIntoView: function() {
var doc = this.doc,
tolerance = 5, // px
hasScrollBars = doc.documentElement.scrollHeight > doc.documentElement.offsetHeight,
tempElement = doc._wysihtml5ScrollIntoViewElement = doc._wysihtml5ScrollIntoViewElement || (function() {
var element = doc.createElement("span");
Expand All @@ -310,7 +311,7 @@
this.insertNode(tempElement);
offsetTop = _getCumulativeOffsetTop(tempElement);
tempElement.parentNode.removeChild(tempElement);
if (offsetTop > doc.body.scrollTop) {
if (offsetTop >= (doc.body.scrollTop + doc.documentElement.offsetHeight - tolerance)) {
doc.body.scrollTop = offsetTop;
}
}
Expand Down

0 comments on commit ebafa27

Please sign in to comment.