All Products
Search
Document Center

SuperApp:Other features

Last Updated:Oct 25, 2024

This topic describes other JavaScript APIs. You can refer to this topic when you create HTML5 apps or Miniapps.

WindVaneReady

When a page is loaded, WindVane will trigger the WindVaneReady event, and the page can listen for this event to obtain the page loading status. Page refresh and page history rollback will also trigger this event.

document.addEventListener('WindVaneReady', function(e) {
        alert('WindVaneReady');
}, false);

Background

When the app is moved to the background, such as switching to another app or opening the notification bar, WindVane will trigger the WV.Event.APP.Background event, and the page can listen for this event to obtain the app switchover to the background.

Due to the limitations of the Android system, the WV.Event.APP.Background event is triggered even when you switch from WebView to other activities, not just when the app is moved to the background.

Important

When the app is moved to the background, operations cannot be performed until WebView is reactivated. Make sure that no alerts are triggered in this event, which will cause a serious bug in some Android models – any page opened will be blank.

In the iOS system, WindVane 5.6.0 or later updated the condition for triggering the WV.Event.APP.Background event to be the same as in the Android system: The WV.Event.APP.Background event is triggered when the app is switched from WebView to Native or other views.

The "to" parameter is added to WindVane 5.6.0 or later to specify to which the app is switched from WebView. The valid value of the parameter is 'background', indicating that WebView is moved to the background.

If this parameter does not exist, it cannot be determined to which the app is switched from WebView.

document.addEventListener('WV.Event.APP.Background', function(e) {
        // For some models, an alert is triggered when the app exits, which will cause a system bug. 
        console.log('Event Background');
}, false);

Active

When the app is moved from the background to the foreground, WindVane will trigger the WV.Event.APP.Active event, and the page can listen for this event to obtain the app activation.

Due to the limitations of the Android system, the WV.Event.APP.Active event is triggered even when you switch from other activities to WebView, not just when the app is moved from the background to the foreground.

In the iOS system, WindVane 5.6.0 or later updated the condition for triggering the WV.Event.APP.Active event to be the same as in the Android system: The WV.Event.APP.Active event is triggered when the app is switched from Native or other views to WebView.

The "from" parameter is added to WindVane 5.6.0 or later to specify from which the app is switched to WebView. Valid values:

  • 'background': specifies that the app is switched from the background to WebView.

  • 'webview': specifies that the app is switched from other views to WebView.

If this parameter does not exist, it cannot be determined from where the app is switched to WebView.

The "data" parameter is added to WindVane 6.3.0 or later to obtain the data passed by WebAppInterface.pop.

document.addEventListener('WV.Event.APP.Active', function(e) {
        alert('Event Active');
}, false);

Pull Refresh

Note

This API is available only in WindVane iOS.

In the iOS system, WindVane enables the pull-to-refresh feature by default. To disable pull-to-refresh, add the following metadata to the <head> element of HTML:

<meta id="stopUsePullRefresh" value="true">

You can specify whether to display the URL of the current page in the prompt section when a pull-to-refresh action is taken. To display the URL of the current page, add the following metadata to the <head> element of HTML:

<meta id="urlInLaw" value="true">

Infinite Scroll

Note

This API is available only in WindVane iOS.

Loads more content when the user scrolls to the bottom of the page. To enable infinite scrolling, add the following metadata to the <head> element of HTML:

<meta id="infiniteScroll" value="true">

In WindVane of the iOS system, add the following metadata to the <head> element of HTML:

<meta id="urlInLaw" value="true">

urlInLaw must be added to mitigate the bug of WindVane in the iOS system. The value of urlInLaw can be set as needed.

After the metadata is added, the WV_INFINIT_SCROLL event is triggered. In the event, you can continuously obtain new content and add it to the end of the page. After the new content is obtained, you need to call the WVScrollWidget.hiddenInfinitScroll operation to hide the loading prompt during infinite scrolling.

document.addEventListener('WV_INFINIT_SCROLL', function(e) {
        var data = 'New document element for infinit scroll';
        window.WindVane.call('WVScrollWidget', 'hiddenInfinitScroll', {}, function(e) {
                var newDiv = document.createElement('div');
                newDiv.innerHTML = data;
                document.body.appendChild(newDiv);
        });
}, false);