All Projects β†’ dirkgroenen β†’ Viewport Checker

dirkgroenen / Viewport Checker

Licence: mit
Little utility to detect if elements are currently within the viewport πŸ”§

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Viewport Checker

react-awesome-reveal
React components to add reveal animations using the Intersection Observer API and CSS Animations.
Stars: ✭ 564 (-5.37%)
Mutual labels:  animations, viewport
React Cool Inview
😎 πŸ–₯️ React hook to monitor an element enters or leaves the viewport (or another element).
Stars: ✭ 830 (+39.26%)
Mutual labels:  animations, viewport
Within Viewport
JavaScript utility that determines whether an element is completely within the browser viewport
Stars: ✭ 244 (-59.06%)
Mutual labels:  viewport, browser
React Awesome Reveal
React components to add reveal animations using the Intersection Observer API and CSS Animations.
Stars: ✭ 346 (-41.95%)
Mutual labels:  animations, viewport
Webtorrent
⚑️ Streaming torrent client for the web
Stars: ✭ 25,554 (+4187.58%)
Mutual labels:  browser
Pixi Viewport
A highly configurable viewport/2D camera designed to work with pixi.js
Stars: ✭ 532 (-10.74%)
Mutual labels:  viewport
Fenix
Firefox for Android
Stars: ✭ 5,423 (+809.9%)
Mutual labels:  browser
Transition X
{ } Declarative Kotlin DSL for choreographing Android transitions
Stars: ✭ 514 (-13.76%)
Mutual labels:  animations
Badgehub
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
Stars: ✭ 592 (-0.67%)
Mutual labels:  animations
Reanimate
Haskell library for building declarative animations based on SVG graphics
Stars: ✭ 581 (-2.52%)
Mutual labels:  animations
Awesome Ios Animation
A curated list of awesome iOS animation, including Objective-C and Swift libraries
Stars: ✭ 4,983 (+736.07%)
Mutual labels:  animations
Bowser
a browser detector
Stars: ✭ 5,006 (+739.93%)
Mutual labels:  browser
Quadplay
The quadplay✜ fantasy console
Stars: ✭ 563 (-5.54%)
Mutual labels:  browser
Bpmn Js
A BPMN 2.0 rendering toolkit and web modeler.
Stars: ✭ 5,592 (+838.26%)
Mutual labels:  browser
Htextview
Animation effects to text, not really textview
Stars: ✭ 5,309 (+790.77%)
Mutual labels:  animations
In View
Get notified when a DOM element enters or exits the viewport. πŸ‘€
Stars: ✭ 4,684 (+685.91%)
Mutual labels:  viewport
Browser.php
A PHP Class to detect a user's Browser. This encapsulation provides a breakdown of the browser and the version of the browser using the browser's user-agent string. This is not a guaranteed solution but provides an overall accurate way to detect what browser a user is using.
Stars: ✭ 546 (-8.39%)
Mutual labels:  browser
Yt Player
Simple, robust, blazing-fast YouTube Player API
Stars: ✭ 576 (-3.36%)
Mutual labels:  browser
Webdriver
Remote control interface that enables introspection and control of user agents.
Stars: ✭ 546 (-8.39%)
Mutual labels:  browser
Axphotoviewer
An iOS/tvOS photo gallery viewer, useful for viewing a large (or small!) number of photos.
Stars: ✭ 544 (-8.72%)
Mutual labels:  browser

viewport-checker

Note: jQuery-viewport-checker has been rewritten and renamed to no longer require jQuery.

Little script that detects if an element is in the viewport and adds a class to it.

Starting V2.x.x this plugin no longer requires jQuery. Take a look at version 1.x.x if you're still looking for the jQuery version.

Installation

Distribution files are shipped with the npm package. Install the package and use it in your project:

npm install --save viewport-checker

Or use unpkg.com to directly include the distribution files in your site:

<script type="text/javascript" src="//unpkg.com/[email protected]^2"></script>

After including the script in your project you can construct a new instance by providing a querySelector. Make sure to call attach() after you're DOM is ready so your elements are actually checked.

<head>
    <script src="dist/viewportChecker.umd.js"></script>

    <script>
        const vpc = new ViewportChecker('.dummy');
        document.addEventListener('DOMContentLoaded', () => vpc.attach());
    </script>
</head>

Options

ViewportChecker can be initialized with an additional argument representing the options. Available options are:

new ViewportChecker('.dummy', {
    classToAdd: 'visible', // Class to add to the elements when they are visible,
    classToAddForFullView: 'full-visible', // Class to add when an item is completely visible in the viewport
    classToRemove: 'invisible', // Class to remove before adding 'classToAdd' to the elements
    removeClassAfterAnimation: false, // Remove added classes after animation has finished
    offset: [100 OR 10%], // The offset of the elements (let them appear earlier or later). This can also be percentage based by adding a '%' at the end
    invertBottomOffset: true, // Add the offset as a negative number to the element's bottom
    repeat: false, // Add the possibility to remove the class if the elements are not visible
    callbackFunction: function(elem, action){}, // Callback to do after a class was added to an element. Action will return "add" or "remove", depending if the class was added or removed
	scrollHorizontal: false // Set to true if your website scrolls horizontal instead of vertical.
});

In addition to the global options you can also provide 'per element' options using data-attributes. These attributes will then override the globally set options.

Available attributes are:

<div data-vp-add-class="random"></div>          > classToAdd
<div data-vp-remove-class="random"></div>       > classToRemove
<div data-vp-remove-after-animation="true|false"></div>      > Removes added classes after CSS3 animation has completed
<div data-vp-offset="[100 OR 10%]"></div>       > offset
<div data-vp-repeat="true"></div>               > repeat
<div data-vp-scrollHorizontal="false"></div>    > scrollHorizontal

Use case

The guys from web2feel have written a little tutorial with a great example of how you can use this script. Note that this tutorial was written for the original version (V1) which required jQuery. Although the API has changed it pretty much still shows what you can do with this plugin. You can check the tutorial here and the demo here.

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].