Lynx

<refresh> XElement

<refresh> element provides a pull-to-refresh gesture that reveals a customizable header view while new data is being fetched.

It fires the refresh event when the user pulls down past a configurable threshold, allowing you to trigger asynchronous updates and automatically hide the header once the operation completes.

Usage

  • <refresh> only supports vertical pull-to-refresh gestures.
  • It accepts up to two direct children: <refresh-header> and <view> has vertically scrollable inside.

Pull to refresh

Define the refresh effect through <refresh-header>, and set enable-refresh to true for <refresh>.

  1. Pull to refresh: Drag down or call autoStartRefresh to lock the <refresh-header> at the top and fire the startrefresh event.

  2. Finish loading: Call finishRefresh to animate the <refresh-header> out of view.

Attributes

enable-refresh

Android
iOS
Harmony
// @defaultValue: true
'enable-refresh'?: boolean;

Determines if dragging down or calling autoStartRefresh can trigger the startrefresh event.

Events

Frontend can bind corresponding event callbacks to listen for runtime behaviors of the element, as shown below.

bindheaderoffset

Android
iOS
Harmony
bindheaderoffset = (e: RefreshHeaderOffsetEvent) => {};
FieldTypeOptionalDefaultPlatformsSinceDescription
isDraggingbooleanNo
Android
iOS
Harmony
Indicates if <refresh-header> is being dragged
offsetPercentnumberNo
Android
iOS
Harmony
The ratio of the pull-down movement distance to its own height

Triggered during movement when <refresh-header> is exposed.

bindrefreshstatechange

Android
iOS
Harmony
bindrefreshstatechange = (e: RefreshStateChangeEvent) => {};
FieldTypeOptionalDefaultPlatformsSinceDescription
stateRefreshStateNo
Android
iOS
Harmony
Indicates if <refresh-header> is being dragged

Triggered when <refresh-header> state changes.

bindstartrefresh

Android
iOS
Harmony
bindstartrefresh = (e: RefreshStartRefreshEvent) => {};
FieldTypeOptionalDefaultPlatformsSinceDescription
isManualbooleanNo
Android
iOS
Harmony
Indicates whether the startrefresh event is triggered by manual drag

Triggered when enable-refresh is true, and dragging down or calling autoStartRefresh (enters refresh state).

Methods

Frontend can invoke component methods via the SelectorQuery API.

autoStartRefresh

Android
iOS
Harmony

lynx.createSelectorQuery()
.select('#id')
.invoke({
method: 'autoStartRefresh',
success: function (res) {},
fail: function (res) {},
})
.exec();

When enable-refresh is true, call this method to expose the entire <refresh-header> , triggering the startrefresh event, after which <refresh-header> will attach to the top edge of the refresh's viewport.

finishRefresh

Android
iOS
Harmony

lynx.createSelectorQuery()
     .select('#id')
     .invoke({
      method: 'finishRefresh',
      success: function (res) {},
      fail: function (res) {},
    })
    .exec();

Called after the startrefresh event to end the refresh state, making <refresh-header> rebound.

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.