gpoitch / Viewprt
A tiny, dependency-free, high performance viewport position & intersection observation tool
Stars: ✭ 36
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Viewprt
Ng In Viewport
Allows us to check if an element is within the browsers visual viewport
Stars: ✭ 178 (+394.44%)
Mutual labels: lazy-loading, viewport, infinite-scroll
React Intersection Observer
React implementation of the Intersection Observer API to tell you when an element enters or leaves the viewport.
Stars: ✭ 2,689 (+7369.44%)
Mutual labels: lazy-loading, viewport, scrolling
React Cool Inview
😎 🖥️ React hook to monitor an element enters or leaves the viewport (or another element).
Stars: ✭ 830 (+2205.56%)
Mutual labels: lazy-loading, viewport, scrolling
Infinitescroll
Infinite Scroll (Endless Scrolling) for RecyclerView in Android
Stars: ✭ 183 (+408.33%)
Mutual labels: scrolling, infinite-scroll
Ngx Ui Scroll
Infinite/virtual scroll for Angular
Stars: ✭ 145 (+302.78%)
Mutual labels: scrolling, infinite-scroll
angular-inviewport
A simple lightweight library for Angular with no other dependencies that detects when an element is within the browser viewport and adds a "sn-viewport-in" or "sn-viewport-out" class to the element
Stars: ✭ 72 (+100%)
Mutual labels: scrolling, viewport
render-props
㸚 Easy-to-use React state containers which utilize the render props (function as child) pattern
Stars: ✭ 33 (-8.33%)
Mutual labels: scrolling, viewport
Wordpress Ajax Load More
🔥 WordPress infinite scroll with Ajax Load More - the ultimate solution to add infinite scroll functionality to your WordPress powered website.
Stars: ✭ 222 (+516.67%)
Mutual labels: lazy-loading, infinite-scroll
react-scroll-trigger
📜 React component that monitors scroll events to trigger callbacks when it enters, exits and progresses through the viewport. All callback include the progress and velocity of the scrolling, in the event you want to manipulate stuff based on those values.
Stars: ✭ 126 (+250%)
Mutual labels: scrolling, viewport
react-cool-virtual
😎 ♻️ A tiny React hook for rendering large datasets like a breeze.
Stars: ✭ 1,031 (+2763.89%)
Mutual labels: infinite-scroll, lazy-loading
vue-in-viewport-mixin
Vue 2 mixin to determine when a DOM element is visible in the client window
Stars: ✭ 99 (+175%)
Mutual labels: scrolling, viewport
svelte-intersection-observer
Detect if an element is in the viewport using the Intersection Observer API
Stars: ✭ 151 (+319.44%)
Mutual labels: viewport, lazy-loading
Django Infinite Scroll Pagination
🌀 Pagination based on the seek method / keyset paging / offset-less pagination
Stars: ✭ 90 (+150%)
Mutual labels: scrolling, infinite-scroll
Jscroll
An infinite scrolling plugin for jQuery.
Stars: ✭ 1,084 (+2911.11%)
Mutual labels: scrolling, infinite-scroll
onscroll-effect
A tiny JavaScript library to enable CSS animations when user scrolls.
Stars: ✭ 35 (-2.78%)
Mutual labels: scrolling, viewport
React On Screen
Check if a react component in the viewport
Stars: ✭ 357 (+891.67%)
Mutual labels: lazy-loading, viewport
React Intersection Observer
React component for the Intersection <Observer /> API
Stars: ✭ 940 (+2511.11%)
Mutual labels: viewport, scrolling
Android scroll endless
Scroll endless for Android recyclerview
Stars: ✭ 12 (-66.67%)
Mutual labels: scrolling
Uiscrollview Infinitescroll
UIScrollView ∞ scroll category
Stars: ✭ 957 (+2558.33%)
Mutual labels: infinite-scroll
Fuckmyscroll.js
🔮 Animated scrolling to certain point or anchor
Stars: ✭ 10 (-72.22%)
Mutual labels: scrolling
A tiny, dependency-free, high performance viewport position & intersection observation tool. You can watch when elements enter & exit a viewport, or when a viewport itself reaches its bounds. Use this as a building block for lazy loaders, infinite scrolling, etc.
Demo / Examples 🕹
Install
npm i viewprt -S
Usage & API
import {
ElementObserver, // Use this to observe when an element enters and exits the viewport
PositionObserver // Use this to observe when a viewport reaches its bounds
ObserverCollection // Advanced: Used for grouping custom viewport handling
} from 'viewprt'
// All options are optional. The defaults are shown below.
// ElementObserver(element, options)
const elementObserver = ElementObserver(document.getElementById('element'), {
onEnter(element, viewport) {}, // callback when the element enters the viewport
onExit(element, viewport) {}, // callback when the element exits the viewport
offset: 0, // offset from the edges of the viewport in pixels
once: false, // if true, observer is detroyed after first callback is triggered
observerCollection: new ObserverCollection() // Advanced: Used for grouping custom viewport handling
})
// PositionObserver(options)
const positionObserver = PositionObserver({
onBottom(container, viewport) {}, // callback when the viewport reaches the bottom
onTop(container, viewport) {}, // callback when the viewport reaches the top
onLeft(container, viewport) {}, // callback when the viewport reaches the left
onRight(container, viewport) {}, // callback when the viewport reaches the right
onFit(container, viewport) {}, // callback when the viewport contents fit within the container without having to scroll
container: document.body, // the viewport element to observe the position of
offset: 0, // offset from the edges of the viewport in pixels
once: false, // if true, observer is detroyed after first callback is triggered
observerCollection: new ObserverCollection() // Advanced: Used for grouping custom viewport handling
})
The viewport
argument in callbacks is an object containing the current state of the viewport e.g.:
{
width: 1024,
height: 768,
positionX: 0,
positionY: 2000
directionY: "down",
directionX: "none"
}
// Stop observing:
positionObserver.destroy()
elementObserver.destroy() // This happens automatically if the element is removed from the DOM
// Start observing again:
positionObserver.activate()
elementObserver.activate()
Advanced: Using a custom observer collection
If you need to control scroll and resize events (e.g. for custom throttling/debouncing), you can create a new instance of ObserverCollection
.
const debouncedObserverCollection = new ObserverCollection({ handleScrollResize: h => debounce(h, 300) })
const elementObserver = ElementObserver(document.getElementById('element1'), {
observerCollection: debouncedObserverCollection
})
// The same instance of ObserverCollection should be reused to have only one scroll and resize event
const elementObserver = ElementObserver(document.getElementById('element2'), {
observerCollection: debouncedObserverCollection
})
Browser support
Chrome, Firefox, Edge, IE 11+, Safari 8+
(requestAnimationFrame, MutationObserver, Map)
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].