• Stars
    star
    7,407
  • Rank 5,225 (Top 0.2 %)
  • Language
    HTML
  • Created over 14 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“œ Automatically add next page

Infinite Scroll

Automatically add next page

See infinite-scroll.com for complete docs and demos.

Install

Download

CDN

Link directly to Infinite Scroll files on unpkg.

<script src="https://unpkg.com/infinite-scroll@4/dist/infinite-scroll.pkgd.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/infinite-scroll@4/dist/infinite-scroll.pkgd.js"></script>

Package managers

npm: npm install infinite-scroll

Yarn: yarn add infinite-scroll

License

Commercial license

If you want to use Infinite Scroll to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Purchase an Infinite Scroll Commercial License at infinite-scroll.com

Open source license

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use Infinite Scroll under the terms of the GPLv3.

Read more about Infinite Scroll's license.

Usage

Infinite Scroll works on a container element with its child item elements

<div class="container">
  <article class="post">...</article>
  <article class="post">...</article>
  <article class="post">...</article>
  ...
</div>

Options

let infScroll = new InfiniteScroll( '.container', {
  // defaults listed

  path: undefined,
  // REQUIRED. Determines the URL for the next page
  // Set to selector string to use the href of the next page's link
  // path: '.pagination__next'
  // Or set with {{#}} in place of the page number in the url
  // path: '/blog/page/{{#}}'
  // or set with function
  // path: function() {
  //   return return '/articles/P' + ( ( this.loadCount + 1 ) * 10 );
  // }

  append: undefined,
  // REQUIRED for appending content
  // Appends selected elements from loaded page to the container

  checkLastPage: true,
  // Checks if page has path selector element
  // Set to string if path is not set as selector string:
  //   checkLastPage: '.pagination__next'

  prefill: false,
  // Loads and appends pages on intialization until scroll requirement is met.

  responseBody: 'text',
  // Sets the method used on the response.
  // Set to 'json' to load JSON.

  domParseResponse: true,
  // enables parsing response body into a DOM
  // disable to load flat text

  fetchOptions: undefined,
  // sets custom settings for the fetch() request
  // for setting headers, cors, or POST method
  // can be set to an object, or a function that returns an object

  outlayer: false,
  // Integrates Masonry, Isotope or Packery
  // Appended items will be added to the layout

  scrollThreshold: 400,
  // Sets the distance between the viewport to scroll area
  // for scrollThreshold event to be triggered.

  elementScroll: false,
  // Sets scroller to an element for overflow element scrolling

  loadOnScroll: true,
  // Loads next page when scroll crosses over scrollThreshold

  history: 'replace',
  // Changes the browser history and URL.
  // Set to 'push' to use history.pushState()
  //    to create new history entries for each page change.

  historyTitle: true,
  // Updates the window title. Requires history enabled.

  hideNav: undefined,
  // Hides navigation element

  status: undefined,
  // Displays status elements indicating state of page loading:
  // .infinite-scroll-request, .infinite-scroll-load, .infinite-scroll-error
  // status: '.page-load-status'

  button: undefined,
  // Enables a button to load pages on click
  // button: '.load-next-button'

  onInit: undefined,
  // called on initialization
  // useful for binding events on init
  // onInit: function() {
  //   this.on( 'append', function() {...})
  // }

  debug: false,
  // Logs events and state changes to the console.
})

Browser support

Infinite Scroll v4 supports Chrome 60+, Edge 79+, Firefox 55+, Safari 11+.

For IE10 and Android 4 support, try Infinite Scroll v3.

Development

This package is developed with Node.js v14 and npm v6. Manage Node and npm version with nvm.

nvm use

Install dependencies

npm install

Lint

npm run lint

Run tests

npm test

By Metafizzy 🌈🐻

More Repositories

1

isotope

πŸ’ž Filter & sort magical layouts
HTML
11,040
star
2

zdog

Flat, round, designer-friendly pseudo-3D engine for canvas & SVG
JavaScript
10,327
star
3

flickity

πŸƒ Touch, responsive, flickable carousels
JavaScript
7,511
star
4

packery

🍱 Gapless, draggable grid layouts
JavaScript
4,128
star
5

huebee

🐝 1-click color picker
JavaScript
402
star
6

outlayer

πŸ‘· the brains & guts of a layout library
JavaScript
163
star
7

unidragger

πŸ‘‡ Draggable base class
JavaScript
82
star
8

ev-emitter

πŸ”” Lil' event emitter
JavaScript
65
star
9

flickity-fade

Fade between Flickity slides
JavaScript
62
star
10

zdog-demos

Round, flat, designer friendly demos for Zdog
Makefile
57
star
11

fizzy-ui-utils

UI utilities & helpers
JavaScript
46
star
12

flickity-fullscreen

Enable fullscreen view for Flickity carousels
HTML
46
star
13

tap-listener

Listens to taps
JavaScript
42
star
14

isotope-packery

packery layout mode for Isotope
JavaScript
42
star
15

flickity-bg-lazyload

Flickity lazyload background images
HTML
31
star
16

flickity-as-nav-for

Enable asNavFor for Flickity
HTML
30
star
17

flickity-sync

Sync up two Flickity carousels
HTML
29
star
18

metafizzy.co

🐻 Metafizzy site!
Handlebars
29
star
19

flickity-docs

πŸ“ documentation for Flickity
Handlebars
28
star
20

unipointer

☝️ Do one thing with one pointer
JavaScript
27
star
21

flickity-imagesloaded

enables imagesLoaded option for Flickity
JavaScript
19
star
22

zdog-docs

Documentation site for Zdog
Handlebars
19
star
23

fizzy.school

πŸŽƒ Lessons for anyone writing jQuery
HTML
17
star
24

logo.pizza

πŸ• Logo Pizza site
JavaScript
16
star
25

next-project

Help us decide what to build next
16
star
26

isotope-docs

πŸ“ documentation for Isotope
Handlebars
13
star
27

isotope-masonry-horizontal

masonryHorizontal layout mode for Isotope
HTML
13
star
28

droppabilly

Drag and drop
JavaScript
11
star
29

flickity-hash

Select Flickity slides with links
HTML
11
star
30

packery-docs

πŸ“ Documentation for Packery
HTML
9
star
31

isotope-horizontal

horizontal layout mode for Isotope
JavaScript
8
star
32

isotope-fit-columns

fitColumns layout mode for Isotope
JavaScript
7
star
33

eslint-plugin-metafizzy

ESLint config and rules for Metafizzy
JavaScript
3
star
34

transfob

get a transform stream, like through2.obj()
JavaScript
3
star
35

isotope-cells-by-column

cellsByColumn layout mode for Isotope
JavaScript
3
star
36

flickity-dev

Little demos made in development of Flickity
JavaScript
3
star
37

fizzy-docs-modules

Modules used in Metafizzy documentation sites
Handlebars
3
star
38

isotope-cells-by-row

cellsByRow layout mode for Isotope
JavaScript
2
star
39

huebee-docs

Huebee documentation
Handlebars
2
star
40

infinite-scroll-docs

πŸ“ Documentation for Infinite Scroll
Handlebars
2
star
41

grunt-fizzy-docs

Grunt tasks for Masonry, Isotope, and Packery docs
JavaScript
2
star