element-in-document

1.0.2 • Public • Published

element-in-document

JavaScript Style Guide NPM version NPM download Dependency Status DevDependency Status

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

Package Sidebar

Install

npm i element-in-document

Weekly Downloads

21

Version

1.0.2

License

MIT

Last publish

Collaborators

  • kyungw00k