Options
item
Type: string|Element
Default: undefined
Required: yes
Selector of the item elements that should be appended to the container.
The item elements should live inside the container element.
next
Type: string
Default: undefined
Required: yes
Selector of the next link. The href
attribute will be used for the url of the next page. Only a single element should match this selector.
prev
Introduced in Infinite Ajax Scroll 3.1.0
Type: string
Default: undefined
Required: no
Selector of the previous link. The href
attribute will be used for the url of the previous page. Only a single element should match this selector.
pagination
Type: boolean|string|Element
Default: false
Required: no
Selector of the elements that contain the pagination. The elements that match the selector will be hidden (element.style.display
-> none) when Infinite Ajax Scroll binds.
The pagination elements will be restored (element.style.display
-> original value) when unbind
is called.
responseType
Type: string
Default: "document"
Required: no
Type of response. Can be set to "json".
See MDN documentation for available values.
bind
Type: boolean
Default: true
Required: no
By default Infinite Ajax Scroll binds to the scroll and resize events on document ready. If you want to have manual control over this behaviour you can set this option to false
. To bind manually you can call the bind
method.
scrollContainer
Type: string|Element|window
Default: window
Required: no
Set a selector of the element you want to use as a scroll container. Use this if you want infinite scroll inside an overflow element.
Note: Only a single element should match the selector.
Read more about scrolling inside an element
negativeMargin
Type: int
(pixels)
Default: 0
Required: no
By default Infinite Ajax Scroll starts loading new items when the user scrolls to the bottom of the last item. The negativeMargin (in pixels) will be subtracted from the items' offset, allowing you to load new pages sooner.
This value is always transformed to a positive integer (a value of -100
will behave the same as 100
)
User experience can degrade when new pages are loaded too quickly without visual feedback. Use with caution.
spinner
Type: string|Element|Object|boolean
Default: false
Required: no
Configures a spinner/loader. By default no spinner is configured.
You can set a selector to an element you want to display when Infinite Ajax Scroll is loading the next page.
You can also set advanced spinner options.
View the use of a spinner in a live demo
trigger
Type: string|Element|Object|boolean
Default: false
Required: no
Configures a trigger. By default no trigger is configured.
You can use the selector of an element you want to use as a trigger.
We can also set advanced trigger options.
View the use of a button in a live demo
logger
Type: Object|boolean
Default: Object
(see src/logger.js)
Required: no
Configure an event logger.
On default events are logged to console (see src/logger.js):
To disable the logger you can pass false
:
To create your own logger, pass an object:
loadOnScroll
Type: boolean
Default: true
Required: no
Configures if the next/previous page should automatically be loaded when the users scrolls to the bottom or the top of the page.
When loadOnScroll
is disabled the hit
event is still emitted, allowing you to manually trigger the next/prev page (for example by calling next
).
We can use enableLoadOnScroll
and disableLoadOnScroll
to configure this setting on runtime.
prefill
Type: boolean
Default: true
Required: no
When enabled, and the content is shorter than the scroll container, Infinite Ajax Scroll will load the next page(s) until the content is taller than the scroll container. When disabled the responsibility to load the next page is in the hands of the developer. This can be done by calling next
manually.
We can listen to the prefill
and prefilled
events to act on respectively the start and finish of the prefill action.
Last updated