InfinityScroller

This class virtualizes a DOM Scroller to allow scroll ranges that exceed browser limits and also allow negative scroll positions. These are managed by instances of InfinityAxis named x and y.

Configs

6
animate: smooth | null= smoothAlso a property

Set to null to disable smooth scroll animation.

The proportional amount of the browser's true scrollLimit to not use in order to reduce likelihood of browser anomalies. By default, 99% of the limit is used (this value being 1%, by default).

snap: x | y | nullAlso a property

If not null, this config determines which axis to use for scroll snapping.

The minimum number of pixels or the minimum proportion of the item that must be scrolled to initiate a snap to reveal the whole item. A completed scroll of less than this amount is reversed. If this value is less-than 1, then this is the decimal fraction of the item's size. By default, this value is 0.1, which is 10% of the item's width. Otherwise, this value is an absolute number of pixels.

The InfinityAxis instance managing the x-axis.

The InfinityAxis instance managing the y-axis.

Properties

6
animate: smooth | null= smoothAlso a config

Set to null to disable smooth scroll animation.

The proportional amount of the browser's true scrollLimit to not use in order to reduce likelihood of browser anomalies. By default, 99% of the limit is used (this value being 1%, by default).

snap: x | y | nullAlso a config

If not null, this config determines which axis to use for scroll snapping.

The minimum number of pixels or the minimum proportion of the item that must be scrolled to initiate a snap to reveal the whole item. A completed scroll of less than this amount is reversed. If this value is less-than 1, then this is the decimal fraction of the item's size. By default, this value is 0.1, which is 10% of the item's width. Otherwise, this value is an absolute number of pixels.

The InfinityAxis instance managing the x-axis.

The InfinityAxis instance managing the y-axis.

Functions

1

Scrolls to the specified x and y positions, or by the specified dx and dy. Only one of these values is required. It is invalid to pass x and dx, or y and dy at the same time, however, it is valid to pass x and dy, or y and dx.

This method returns a Promise that resolves to a boolean value. This value indicates that the desired scroll adjustment was made. It is false if the scroll ends at a different position. This can happen if the user interferes with the scroll, or another call to this method is made before the first call completes.

ParameterTypeDescription
optionsObject
options.animateBoolean

Specify false to scroll without animation.

options.dxNumber

The amount by which the x scroll position should be adjusted.

options.dyNumber

The amount by which the y scroll position should be adjusted.

options.xNumber

The new value for the x scroll position.

options.yNumber

The new value for the y scroll position.

Returns: Boolean

Events

2

Fired when scrolling happens on this InfinityScroller's element.

// Adding a listener using the "on" method
infinityScroller.on('scroll', ({ relatedEvent, widget, source }) => {

});
ParameterTypeDescription
relatedEventEvent

The DOM event.

widgetContainer

The owning client instance.

sourceInfinityScroller

This InfinityScroller

Fired when scrolling finished on this InfinityScroller's element.

// Adding a listener using the "on" method
infinityScroller.on('scrollEnd', ({ relatedEvent, widget, source }) => {

});
ParameterTypeDescription
relatedEventEvent

The last DOM event to fire.

widgetContainer

The owning client instance.

sourceInfinityScroller

This InfinityScroller

Event handlers

2

Called when scrolling happens on this InfinityScroller's element.

new InfinityScroller({
    onScroll({ relatedEvent, widget, source }) {

    }
});
ParameterTypeDescription
relatedEventEvent

The DOM event.

widgetContainer

The owning client instance.

sourceInfinityScroller

This InfinityScroller

Called when scrolling finished on this InfinityScroller's element.

new InfinityScroller({
    onScrollEnd({ relatedEvent, widget, source }) {

    }
});
ParameterTypeDescription
relatedEventEvent

The last DOM event to fire.

widgetContainer

The owning client instance.

sourceInfinityScroller

This InfinityScroller