element-in-document
Determine if the client rect of element is positioned on the document
Install
$ npm install element-in-document
API
elementInDocument(element, threshold = 1.0)
Returns: Boolean
Options
argument | type | description | default value |
---|---|---|---|
element |
HTMLElement |
Target Node | not null |
threshold |
float |
Greater than or equal to (threshold * 100)% of the pixels in the element was on document |
1.0 |
Example
var elementInDocument = require('element-in-document')
var dom = document.body
elementInDocument(dom)
// true
var div = document.createElement('div')
div.style.width = '200px'
div.style.height = '200px'
div.style.position = 'absolute'
div.style.left = '-200px'
div.style.top = '-200px'
document.body.appendChild(div)
elementInDocument(div)
// `false` because div is actually not seen on document