adds the *scrollin* and *scrollout* events to jquery, which will fire when any given element becomes (respectively) visible and invisible in the browser viewpori

Overview

jQuery.scrolling

This plugin adds the scrollin and scrollout events to jquery: these events will fire when any given element becomes visible/invisible in the browser viewport, allowing you to:

  • automatically or programmatically show/hide any HTML content as soon as it comes inside or outside the browser viewport (i.e. when the user scrolls to them).
  • prevent unnecessary processing for content that is hidden or is outside of the browser viewport.
  • trigger a custom function or behaviour (such as loading external AJAX content) when a certain point of the page is reached.

and more.

The plugin also supports frame, iframe and/or dynamically-generated content.

Requires jQuery 1.7 or above.

Home Page

For the latest package, documentation, API and support please refer to the project Home Page.

Installation

Installing the plugin is easy: all you need to do is download the latest version from the official project page (tar or zip): unpack the archive somewhere, copy the .js file in your website javascript folder and add the following line to the head block of your web page:

    <script type="text/javascript" src="/yourpath/jquery.scrolling.js"></script>

Usage

Activate the plugin for one or more elements defined by a selector:

    $('selector').scrolling(); 

Or for raw DOM nodes created using the standard jQuery syntax:

    $('<div>content</div>').scrolling(); 

Once activated, you can bind your code to the scrollin and scrollout events: they will trigger when the active element(s) will come inside the browser viewport.

    $('selector').on('scrollin', function(event, $all_elements) {
      // we reach this point as soon as the 'selector' element becomes visibile inside the browser viewport.
      // $all_elements contains all the appeared elements.
    });
    
    $('yourselector').on('scrollout', function(event, $all_elements) {
      // we reach this point as soon as the 'selector' element goes outside the browser viewport.
      // $all_elements contains all the disappeared elements.
    });

If you want to fire the scrollIn event for elements which are close to viewport but are not visible yet you may either:

  • use the offsetTop and offsetLeft options properties during initialization.

  • add the following custom data attributes offset-top and offset-left to DOM nodes.

      $('#myEl').scrolling({ offsetTop: 100 }); 
      // appear will be fired when "myEl" is 100 or less pixels
      // below browser viewport 
    

or

    <div id="myEl" data-offset-top="100">...</div>
    // same as above using data attributes.

Appear check can also be forced by calling $.checkScrolling(). This is suitable in cases when page is in initial state (not scrolled and not resized) and when you want manually trigger appearance check.

There's also a custom scrollin jQuery filter you can use for manual checking if the element is inside the viewport or not.

    $('selector').is(':scrollin')

Demo and Examples

Check the project demo page to see the most common implementation scenarios.

Related links

Credits

This is a revamp/upgrade of the jquery.appear plugins respectively hosted on:

The original code has been rewritten and updated in order to support additional features, namely:

  • IFrame support
  • more options
  • configurable values
  • revised documentation
  • additional samples and more.

Support

You can support this project's development by clicking on the following button.

Donate

Thanks a lot!

License

Licensed under MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...

A jQuery plugin that adds cross-browser mouse wheel support.

jQuery Mouse Wheel Plugin A jQuery plugin that adds cross-browser mouse wheel support with delta normalization. In order to use the plugin, simply bin

Dec 26, 2022

JavaScript micro-library: pass in an element and a callback and this will trigger when you click anywhere other than the element

Add a click listener to fire a callback for everywhere on the window except your chosen element. Installation run npm install @lukeboyle/when-clicked-

May 13, 2021

An easy-to-use jQuery plugin that allows the user to pick an icon from a responsive icon browser and shows the corresponding icon class in an input element.

Font Awesome Browser An easy-to-use jQuery plugin that allows the user to pick an icon from a responsive icon browser and shows the corresponding icon

May 1, 2021

This tool uses native browser APIs to take screenshots of a given web page, tab, window, or the user's entire screen.

This tool uses native browser APIs to take screenshots of a given web page, tab, window, or the user's entire screen.

This tool uses native browser APIs to take screenshots of a given web page, tab, window, or the user's entire screen.

Jan 1, 2023

FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors

FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors

FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors. You can add photos, code blocks, featured images, social media & SEO attributes, embedded HTML (YouTube Videos, Embedded Podcasts Episodes, Tweets, ...), and markdown! Dark & Light modes available so everyone is happy

Jan 2, 2023

Front-end for FireNearby service. View recent fires and sign up to receive alerts: caseymm.github.io/fire-nearby

fire-nearby (firenearby service front-end) This application is composed of three pages: Map of recent fires Sign up form to receive alerts About this

Mar 30, 2022

Firebase Storage with Angular 14 example: Upload File, Retrieve, Display, Download Url & Delete using @angular/fire AngularFireStorage

Firebase Storage with Angular 14 example: Upload File, Retrieve, Display, Download Url & Delete using @angular/fire AngularFireStorage

Angular 14 File Upload to Firebase Storage example I will show you how to make Angular 14 Firebase Storage: File Upload/Display/Delete Application usi

Sep 7, 2022

Tampermonkey script which adds the ability to add a user-defined label/tag/flair on a user, shown throughout Hacker News.

Hacker News User Tags Hacker News User Tags is a Tampermonkey userscript which allows the user to associate a custom coloured label/tag on usernames t

Oct 7, 2022

A jQuery Single/Multi Select plugin which can be used on almost any device

jquery.sumoselect jquery.sumoselect.js - A beautiful cross device Single/Multi Select jQuery Select plugin. A jQuery plugin that progressively enhance

Dec 7, 2022
Comments
  • checkScrolling doesn't work for elements allready out of viewPort at initializing

    checkScrolling doesn't work for elements allready out of viewPort at initializing

    Helllo Darkseal, Thanks for this interesting plugin. I'd like to use this but stumbled upon a 'bug' I guess. Upon document ready and initializing the plugin on elements that already are out of the viewport, the 'scrollout' is not fired, because the element hasn't been in the viewport (yet). I created a jsfiddle for demonstration purposes: https://jsfiddle.net/jpakbnfz/1/ I experienced this bug when you reload a page when already scrolled somewhere, and the browser remembers it's position. Also, how would I call checkScrolling() directly on a jQuery object? $('#scrolling').checkScrolling(); gives TypeError: $(...).checkScrolling is not a function"

    opened by LeoZandvliet 0
Owner
Dark
CTO, IT Project Manager, Lead Developer, Microsoft MVP. What I'm using: ASP.NET, .NET Core, C#, MVC/Razor, PHP, HTML5, JavaScript, Angular, React & more.
Dark
Given a list of items, only render what's visible on the screen while allowing scrolling the whole list.

Solid Windowed Given a list of items, only render what's visible on the screen while allowing scrolling the whole list. A Solid component. See https:/

Tito 40 Dec 21, 2022
An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve and modify the bot state, respectively.

CQRS Wechaty An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve

Wechaty 3 Mar 23, 2022
BookStore is a website that allows a given user to view a list of books, to add a new book and remove a given book.

Project Name : BookStore CMS BookStore is a website that allows a given user to view a list of books, to add a new book and remove a given book. In or

Chris Siku 10 Aug 22, 2022
Simple string diffing. Given two strings, striff will return an object noting which characters were added or removed, and at which indices

Simple string diffing. Given two strings, striff will return an object noting which characters were added or removed, and at which indices

Alex MacArthur 196 Jan 6, 2023
A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time. Dropdown, navigation bu

Matthieu Bué 277 Nov 25, 2022
Adds `swiped` events to the DOM in 0.7k of pure JavaScript

swiped-events A 0.7k script that adds swiped-left, swiped-right, swiped-up and swiped-down events to the DOM using CustomEvent and pure JS. Based on t

John Doherty 493 Jan 8, 2023
Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

catalogist ?? ?? ?? ?? ?? The easy way to catalog and make your software and (micro)services visible to your organization through an API You were a pe

Mikael Vesavuori 11 Dec 13, 2022
Chrome extension that applies phrase-based line breaking and visible phrase boundaries to the current page.

BudouX Chrome Extension This extension applies the phrase-based line breaking or the Japanese Wakachi-gaki style line breaking to the current page. Pl

Google 9 Nov 18, 2022
A simple jQuery extension to make any HTML element sticky on scroll.

jquery.sticky.js A simple jQuery extension to make any HTML element sticky on scroll. Installation Just download the script and include it in your HTM

Achal Jain 2 Aug 22, 2022
A simple lightweight file dropzone component based on jQuery. You can easily make any existing element become a dropzone that holds files.

file-dropzone A simple lightweight file dropzone component based on jQuery. You can easily make any existing element become a dropzone that holds file

Anton Bardov 1 May 31, 2021