Class PageLoader

Configures the given element as a PageLoader widget.

The page loader is a full-page spinner. You would almost certainly use this only once, to hide the page before it's loaded.

IMPORTANT: You should not instantiate more than one PageLoader widget on a given element. Use PageLoader.get to get an existing instance if any. If there is already a widget instance, it will be destroyed!


To use with auto-widgets (HTML API) (see settings.autoWidgets), the following CSS classes or data attributes are recognized:

  • lisn-page-loader class or data-lisn-page-loader attribute set on the element that constitutes the widget. The element should be empty.

See below examples for what values you can use set for the data attributes in order to modify the configuration of the automatically created widget.

This will create a page loader using the JavaScript API.

This will work even if settings.autoWidgets) is false

<!-- LISN should be loaded beforehand -->
<script>
LISN.widgets.PageLoader.enableMain();
</script>

This will create a page loader using an existing element with default PageLoaderConfig.

<div class="lisn-page-loader"></div>

As above but with custom settings.

<div data-lisn-page-loader="auto-remove=false"></div>

Hierarchy (View Summary)

Methods

Constructors

Properties

destroy: () => Promise<void>

Undoes all modifications to the element and returns it to its original state.

You will need to recreate it if you want to enable its functionality again.

disable: () => Promise<void>

Disables the functionality of the widget. What this means is specific to each widget.

enable: () => Promise<void>

Re-enables the functionality of the widget. What this means is specific to each widget.

getElement: () => Element

Returns the element passed to the widget constructor.

isDestroyed: () => boolean

Returns true if the widget is destroyed.

isDisabled: () => boolean

Returns true if the widget is currently disabled.

onDestroy: (handler: WidgetHandler) => void

The given handler will be called when the widget is destroyed.

onDisable: (handler: WidgetHandler) => void

The given handler will be called when the widget is disabled.

onEnable: (handler: WidgetHandler) => void

The given handler will be called when the widget is enabled.

toggleEnable: () => Promise<void>

Re-enables the widget if disabled, otherwise disables it.