Reference Source
import ScrollListener from 'flarum/utils/ScrollListener'
public class | source

ScrollListener

The ScrollListener class sets up a listener that handles window scroll events.

Constructor Summary

Public Constructor
public

constructor(callback: Function)

Member Summary

Public Members
public
public
public

lastTop: *

Method Summary

Public Methods
public

start()

Start listening to and handling the window's scroll position.

public

stop()

Stop listening to and handling the window's scroll position.

public

update(force: Boolean)

Check if the scroll position has changed; if it has, run the handler.

Protected Methods
protected

loop()

On each animation frame, as long as the listener is active, run the update method.

Public Constructors

public constructor(callback: Function) source

Params:

NameTypeAttributeDescription
callback Function

The callback to run when the scroll position changes.

Public Members

public active: boolean source

public callback: * source

public lastTop: * source

Public Methods

public start() source

Start listening to and handling the window's scroll position.

public stop() source

Stop listening to and handling the window's scroll position.

public update(force: Boolean) source

Check if the scroll position has changed; if it has, run the handler.

Params:

NameTypeAttributeDescription
force Boolean
  • optional
  • default: false

Whether or not to force the handler to be run, even if the scroll position hasn't changed.

Protected Methods

protected loop() source

On each animation frame, as long as the listener is active, run the update method.