Permalink
Browse files

Ignore elements with display:none properties

  • Loading branch information...
Sergey Tatarintsev
Sergey Tatarintsev committed Feb 25, 2014
1 parent b9f7bcc commit cf9834deccf67827e438ecfd455a0522cb00984b
Showing with 14 additions and 13 deletions.
  1. +14 −9 lib/element-rect.js
  2. +0 −4 lib/geometery/rect.js
View
@@ -3,17 +3,22 @@ var q = require('q'),
Rect = require('./geometery/rect');
exports.getMultiple = function getMultiple(elements) {
- return q.all(Object.keys(elements).map(function(key) {
- return exports.get(elements[key]);
+ var elementsArray = Object.keys(elements).map(function(key) {
+ return elements[key];
+ });
+ return q.all(elementsArray.map(function(element) {
+ return element.getCssValue('display');
}))
+ .then(function(displays) {
+ var visibleElements = elementsArray.filter(function(element, index) {
+ return displays[index] !== 'none';
+ });
+ return q.all(visibleElements.map(exports.get));
+ })
.then(function(rects) {
- return rects
- .filter(function(rect) {
- return !rect.isZero();
- })
- .reduce(function(first, second) {
- return first.merge(second);
- });
+ return rects.reduce(function(first, second) {
+ return first.merge(second);
+ });
});
};
View
@@ -38,10 +38,6 @@ var Rect = inherit({
Math.max(this.right, other.right) - x,
Math.max(this.bottom, other.bottom) - y
);
- },
-
- isZero: function() {
- return this.width === 0 || this.height === 0;
}
});

0 comments on commit cf9834d

Please sign in to comment.