Skip to content

Commit

Permalink
added isElementOnScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
kahwee committed Jun 2, 2015
1 parent 3811062 commit 9bea379
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v1.2.0 - 2015-06-02
* added isElementOnScreen

## v1.1.0 - 2015-06-01
* Added dist file: dist/viewability.js
* File name changes.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ Finding out if the element is 100% on screen and using Common JS:
```js
var v = require('viewability');
var el = document.getElementById('blue-box');
if (v.horizontal(el).value === 0 && v.vertical(el).value === 0) {
console.log('100% on screen.')
} else if (v.horizontal(el).value > 0 || v.value(el).value > 0) {
console.log('Part of element in on screen.')
if (v.isElementOnScreen(el, true)) {
console.log('100% on screen.');
} else if (v.isElementOnScreen(el)) {
console.log('Some parts are on screen');
} else {
console.log('not on screen at all');
}
```

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "viewability",
"main": "dist/viewability.js",
"version": "1.1.2",
"version": "1.2.0",
"description": "Returns how viewable an element is",
"homepage": "https://github.com/kahwee/viewability",
"authors": [
Expand Down
18 changes: 15 additions & 3 deletions dist/viewability.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ module.exports = function(el) {
};

},{}],2:[function(require,module,exports){
var horizontal = require('./horizontal');
var vertical = require('./vertical');
module.exports = function(el, full) {
if (full) {
return vertical(el).value * horizontal(el).value === 1;
} else {
return vertical(el).value > 0 || horizontal(el).value > 0;
}
};

},{"./horizontal":1,"./vertical":3}],3:[function(require,module,exports){
module.exports = function(el) {
var windowHeight = window.innerHeight;
var elemTop = el.getBoundingClientRect().top;
Expand Down Expand Up @@ -98,11 +109,12 @@ module.exports = function(el) {
};
};

},{}],3:[function(require,module,exports){
},{}],4:[function(require,module,exports){
module.exports = {
vertical: require('./vertical'),
horizontal: require('./horizontal')
horizontal: require('./horizontal'),
isElementOnScreen: require('./isElementOnScreen')
};

},{"./horizontal":1,"./vertical":2}]},{},[3])(3)
},{"./horizontal":1,"./isElementOnScreen":2,"./vertical":3}]},{},[4])(4)
});
2 changes: 1 addition & 1 deletion dist/viewability.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions isElementOnScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var horizontal = require('./horizontal');
var vertical = require('./vertical');
module.exports = function(el, full) {
if (full) {
return vertical(el).value * horizontal(el).value === 1;
} else {
return vertical(el).value > 0 || horizontal(el).value > 0;
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "viewability",
"version": "1.1.2",
"version": "1.2.0",
"description": "Returns how viewable an element is",
"main": "dist/viewability.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion viewability.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
vertical: require('./vertical'),
horizontal: require('./horizontal')
horizontal: require('./horizontal'),
isElementOnScreen: require('./isElementOnScreen')
};

0 comments on commit 9bea379

Please sign in to comment.