Skip to content

Commit

Permalink
Fix bug where tribute didn't factor in the window scrolloffset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Humphreys committed Apr 14, 2016
1 parent 296d930 commit 4d47d4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions dist/tribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,12 @@ if (!Array.prototype.find) {
div.appendChild(span);

var rect = element.getBoundingClientRect();
var doc = document.documentElement;
var windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
var windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
var coordinates = {
top: rect.top + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize),
left: rect.left + span.offsetLeft + parseInt(computed.borderLeftWidth)
top: rect.top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize),
left: rect.left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth)
};

this.getDocument().body.removeChild(div);
Expand Down
7 changes: 5 additions & 2 deletions js/tribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,12 @@ if (!Array.prototype.find) {
div.appendChild(span)

let rect = element.getBoundingClientRect()
var doc = document.documentElement;
var windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
var windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
let coordinates = {
top: rect.top + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize),
left: rect.left + span.offsetLeft + parseInt(computed.borderLeftWidth)
top: rect.top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize),
left: rect.left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth)
}

this.getDocument().body.removeChild(div)
Expand Down

0 comments on commit 4d47d4b

Please sign in to comment.