|
| 1 | +# Infinite Scroll |
| 2 | + |
| 3 | +_Automatically add the next page_ |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +### Download |
| 8 | + |
| 9 | +### CDN |
| 10 | + |
| 11 | +### Package managers |
| 12 | + |
| 13 | +Bower: `bower install infinite-scroll --save` |
| 14 | + |
| 15 | +## License |
| 16 | + |
| 17 | +### Commercial license |
| 18 | + |
| 19 | +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. |
| 20 | + |
| 21 | +### Open source license |
| 22 | + |
| 23 | +If you are creating an open source application under a license compatible with the [GNU GPL license v3](https://www.gnu.org/licenses/gpl-3.0.html), you may use Infinite Scroll under the terms of the GPLv3. |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | +Infinite Scroll works on a container element with its child item elements |
| 28 | + |
| 29 | +``` html |
| 30 | +<div class="container"> |
| 31 | + <article class="post">...</article> |
| 32 | + <article class="post">...</article> |
| 33 | + <article class="post">...</article> |
| 34 | + ... |
| 35 | +</div> |
| 36 | +``` |
| 37 | + |
| 38 | +### Options |
| 39 | + |
| 40 | +``` js |
| 41 | +var infScroll = new InfiniteScroll( '.container', { |
| 42 | + // defaults listed |
| 43 | + |
| 44 | + path: undefined, |
| 45 | + // REQUIRED. Determines the URL for the next page |
| 46 | + // Set to selector string to use the href of the next page's link |
| 47 | + // path: '.pagination__next' |
| 48 | + // Or set with {{#}} in place of the page number in the url |
| 49 | + // path: '/blog/page/{{#}}' |
| 50 | + // or set with function |
| 51 | + // path: function() { |
| 52 | + // return return '/articles/P' + ( ( this.loadCount + 1 ) * 10 ); |
| 53 | + // } |
| 54 | + |
| 55 | + append: undefined, |
| 56 | + // REQUIRED for appending content |
| 57 | + // Appends selected elements from loaded page to the container |
| 58 | + |
| 59 | + checkLastPage: true, |
| 60 | + // Checks if page has path selector element |
| 61 | + |
| 62 | + prefill: false, |
| 63 | + // Loads and appends pages on intialization until scroll requirement is met. |
| 64 | + |
| 65 | + responseType: 'document', |
| 66 | + // Sets the type of response returned by the page request. |
| 67 | + // Set to 'text' to return flat text for loading JSON. |
| 68 | + |
| 69 | + outlayer: false, |
| 70 | + // Integrates Masonry, Isotope or Packery |
| 71 | + // Appended items will be added to the layout |
| 72 | + |
| 73 | + scrollThreshold: 400, |
| 74 | + // Sets the distance between the viewport to scroll area |
| 75 | + // for scrollThreshold event to be triggered. |
| 76 | + |
| 77 | + elementScroll: false, |
| 78 | + // Sets scroller to an element for overflow element scrolling |
| 79 | + |
| 80 | + loadOnScroll: true, |
| 81 | + // Loads next page when scroll crosses over scrollThreshold |
| 82 | + |
| 83 | + history: 'replace', |
| 84 | + // Changes the browser history and URL. |
| 85 | + // Set to 'push' to use history.pushState() |
| 86 | + // to create new history entries for each page change. |
| 87 | + |
| 88 | + historyTitle: true, |
| 89 | + // Updates the window title. Requires history enabled. |
| 90 | + |
| 91 | + hideNav: undefined, |
| 92 | + // Hides navigation element |
| 93 | + |
| 94 | + status: undefined, |
| 95 | + // Displays status elements indicating state of page loading: |
| 96 | + // .infinite-scroll-request, .infinite-scroll-load, .infinite-scroll-error |
| 97 | + // status: '.page-load-status' |
| 98 | + |
| 99 | + button: undefined, |
| 100 | + // Enables a button to load pages on click |
| 101 | + // button: '.load-next-button' |
| 102 | + |
| 103 | + onInit: undefined, |
| 104 | + // called on initialization |
| 105 | + // useful for binding events on init |
| 106 | + // onInit: function() { |
| 107 | + // this.on( 'append', function() {...}) |
| 108 | + // } |
| 109 | + |
| 110 | + log: false, |
| 111 | + // Logs events and state changes to the console. |
| 112 | +}) |
| 113 | +``` |
| 114 | + |
| 115 | +## WordPress plugin |
| 116 | + |
| 117 | +The Infinite Scroll WordPress plugin is being moved to another repo. |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +By [Metafizzy](http://metafizzy.co) |
0 commit comments