All Projects → egoist → Element In View

egoist / Element In View

Licence: mit
Check if an element is in viewport. (580 bytes and IE9+)

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Element In View

viewport-spy
Godot editor UI to spy on what a Viewport is rendering. Useful for debugging.
Stars: ✭ 28 (-48.15%)
Mutual labels:  viewport
Motus
Animation library that mimics CSS keyframes when scrolling.
Stars: ✭ 502 (+829.63%)
Mutual labels:  viewport
React Cool Inview
😎 🖥️ React hook to monitor an element enters or leaves the viewport (or another element).
Stars: ✭ 830 (+1437.04%)
Mutual labels:  viewport
Scrollmonitor
A simple and fast API to monitor elements as you scroll
Stars: ✭ 3,250 (+5918.52%)
Mutual labels:  viewport
React Socks
🎉 React library to render components only on specific viewports 🔥
Stars: ✭ 400 (+640.74%)
Mutual labels:  viewport
Pixi Viewport
A highly configurable viewport/2D camera designed to work with pixi.js
Stars: ✭ 532 (+885.19%)
Mutual labels:  viewport
svelte-intersection-observer
Detect if an element is in the viewport using the Intersection Observer API
Stars: ✭ 151 (+179.63%)
Mutual labels:  viewport
Pixi Cull
a library to visibly cull objects designed to work with pixi.js
Stars: ✭ 51 (-5.56%)
Mutual labels:  viewport
Vue Mq
📱 💻 Define your breakpoints and build responsive design semantically and declaratively in a mobile-first way with Vue.
Stars: ✭ 474 (+777.78%)
Mutual labels:  viewport
Verge
Get viewport dimensions, detect elements in the viewport
Stars: ✭ 687 (+1172.22%)
Mutual labels:  viewport
Animate
A tiny JS (5KB) library to trigger animations on elements when they are within the viewport 👓
Stars: ✭ 340 (+529.63%)
Mutual labels:  viewport
React On Screen
Check if a react component in the viewport
Stars: ✭ 357 (+561.11%)
Mutual labels:  viewport
Viewport Checker
Little utility to detect if elements are currently within the viewport 🔧
Stars: ✭ 596 (+1003.7%)
Mutual labels:  viewport
Stickystack.js
A jQuery plugin that creates a stacking effect by sticking panels as they reach the top of the viewport.
Stars: ✭ 287 (+431.48%)
Mutual labels:  viewport
React Intersection Observer
React component for the Intersection <Observer /> API
Stars: ✭ 940 (+1640.74%)
Mutual labels:  viewport
vw-layout
Mobile website layout with viewport units
Stars: ✭ 47 (-12.96%)
Mutual labels:  viewport
In View
Get notified when a DOM element enters or exits the viewport. 👀
Stars: ✭ 4,684 (+8574.07%)
Mutual labels:  viewport
React Hook Inview
React hook for detecting when an element is in the viewport
Stars: ✭ 52 (-3.7%)
Mutual labels:  viewport
Viewprt
A tiny, dependency-free, high performance viewport position & intersection observation tool
Stars: ✭ 36 (-33.33%)
Mutual labels:  viewport
Isinviewport
An ultra-light jQuery plugin that tells you if an element is in the viewport but with a twist.
Stars: ✭ 646 (+1096.3%)
Mutual labels:  viewport

element-in-view

NPM version NPM downloads CircleCI donate

Features

  • Small and focus, only 580 bytes and exports a single function.
  • Supporting all modern browsers and IE9+.

Comparison

Comparing to in-viewport and in-view, element-in-view only exports a function for checking if an element is in viewport, handling events and other stuffs are left to user-land. In fact, this library is extracted from in-view, I tried to use that library in vue-mugen-scroll, but I need to use a custom logic to handle events, so many features in in-view become useless, that's why this library exists.

Install

yarn add element-in-view

CDN: UNPKG | JSDelivr

Usage

import inView from 'element-in-view'

window.addEventListener('scroll', () => {
  inView(element)
  //=> true or false
})

API

Note that the API doc is partially extracted from in-view.

inView(element, [options])

element

A DOM Element.

options

options.offset

Type: Number object
Default: 0

By default, element-in-view considers something in viewport if it breaks any edge of the viewport. This can be used to set an offset from that edge. For example, an offset of 100 will consider elements in viewport if they break any edge of the viewport by at least 100 pixels. offset can be a positive or negative integer.

Offset can also be set per-direction by passing an object.

{
  top: 100,
  right: 75,
  bottom: 50,
  left: 25
}
options.threshold

Type: Number
Default: 0

Set the ratio of an element's height and width that needs to be visible for it to be considered in viewport. This defaults to 0, meaning any amount. A threshold of 0.5 or 1 will require that half or all, respectively, of an element's height and width need to be visible. threshold must be a number between 0 and 1.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

element-in-view © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @_egoistlily

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].