mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-28 22:59:36 -04:00
Move scroll bounds code to Element.getScrollBounds().
This commit is contained in:
parent
ca9e70ade0
commit
3a8bdeb19b
1 changed files with 8 additions and 4 deletions
|
@ -33,16 +33,20 @@ var Element = {
|
||||||
return new Rectangle(Element.getOffset(el), Element.getSize(el));
|
return new Rectangle(Element.getOffset(el), Element.getSize(el));
|
||||||
},
|
},
|
||||||
|
|
||||||
// Checks if element is visibile in current viewport
|
getScrollBounds: function() {
|
||||||
isVisible: function(el) {
|
|
||||||
var doc = document.getElementsByTagName(
|
var doc = document.getElementsByTagName(
|
||||||
document.compatMode == 'CSS1Compat' ? 'html' : 'body')[0];
|
document.compatMode == 'CSS1Compat' ? 'html' : 'body')[0];
|
||||||
// See if the two rectangle intersect
|
|
||||||
return Rectangle.create(
|
return Rectangle.create(
|
||||||
window.pageXOffset || doc.scrollLeft,
|
window.pageXOffset || doc.scrollLeft,
|
||||||
window.pageYOffset || doc.scrollTop,
|
window.pageYOffset || doc.scrollTop,
|
||||||
window.innerWidth || doc.clientWidth,
|
window.innerWidth || doc.clientWidth,
|
||||||
window.innerHeight || doc.clientHeight
|
window.innerHeight || doc.clientHeight
|
||||||
).intersects(Element.getBounds(el));
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks if element is visibile in current viewport
|
||||||
|
isVisible: function(el) {
|
||||||
|
// See if the two rectangle intersect
|
||||||
|
return Element.getScrollBounds().intersects(Element.getBounds(el));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue