mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05: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));
|
||||
},
|
||||
|
||||
// Checks if element is visibile in current viewport
|
||||
isVisible: function(el) {
|
||||
getScrollBounds: function() {
|
||||
var doc = document.getElementsByTagName(
|
||||
document.compatMode == 'CSS1Compat' ? 'html' : 'body')[0];
|
||||
// See if the two rectangle intersect
|
||||
return Rectangle.create(
|
||||
window.pageXOffset || doc.scrollLeft,
|
||||
window.pageYOffset || doc.scrollTop,
|
||||
window.innerWidth || doc.clientWidth,
|
||||
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…
Reference in a new issue