目录

refresh-footer (1090+)

Overview

Pull-to-refresh footer container of refresh2.

Application Scope

Item

Description

Applicable devices

Mobile phones, tablets, Vision products, and telematics devices

Applicable regions

Global

Subelements

Supported.

Attributes

In addition to general attributes, the attributes listed in the following table are supported.

Attribute

Type

Default Value

Mandatory

Description

dragRate

number

0.5

No

Drag rate, calculated based on Footer movement distance/Gesture movement distance.

triggerRatio

number

0.7

No

Movement rate, which is used to calculate the footer movement distance (Footer movement distance = Value of triggerRatio x Footer height). The priority of triggerRatio is lower than that of triggerSize.

tiggerSize

number

0

No

Movement distance (in px) when the refresh is triggered. This attribute, which is valid when its value is greater than 0, has a higher priority than triggerRatio.

maxdragratio

number

1

No

Maximum rate that the footer can move. The value of maxdragratio multiplied by footer height is equal to the value of maxdragsize.

maxdragsize

number

0

No

Maximum movement distance that a footer can move. This attribute, which is valid when its value is greater than 0, has a higher priority than maxdragratio.

Unit: px

refreshdisplayratio

number

0.7

No

Footer display height rate when the refresh is trigger. The value of refreshdisplayratio multiplied by footer height is equal to the value of refreshdisplaysize. The footer height is 1 by default.

refreshdisplaysize

number

0

No

Footer display height when the refresh is triggered. This attribute, which is valid when its value is greater than 0, has a higher priority than refreshdisplayratio.

Unit: px

spinnerstyle

string

translation

No

Footer display style. The options are as follows:

  • translation: The content moves with the footer.
  • front: The footer is displayed above the content, which does not move with the footer.
  • behind: The footer is displayed below the content, which does not move with the footer.

autorefresh

boolean

false

No

Indicates whether to enable automatic loading when the element is scrolled to the bottom.

translationwithcontent

boolean

true

No

Indicates whether the footer moves with the content when the refresh is triggered. The default value is true.

Styles

Common styles are supported.

Events

In addition to common events, the events listed in the following table are supported.

Event

Parameter

Triggering Conditions

move

{scrollY:number,percent:number,isDrag:boolean,refreshing:boolean}

The footer moves.

  • scrollY: moving distance of the footer relative to the initial position. When the footer is pulled up, the value is negative.
  • percent: movement rate, calculated based on Footer movement distance/Movement distance to trigger a refresh. When percent is greater than or equal to 1f (floating-point number), the refresh is triggered.
  • isDrag: indicates whether to enable gesture drag.
  • refreshing: indicates whether to process the current refresh status. Movement is supported during the refresh.

Sample Code

<import name="movie-item" src="../Common/SR399/movie-item.ux"></import>
<template>
  <div class="root">
  <refresh2 id="refresh" style="background-color:{{backgroundColor}};progress-color:{{progressColor}};" offset="132px" animationduration="300" class="container" reboundable="true" type="auto" @refresh="refresh" @pulluprefresh="pullUpRefresh" @pulldownrefresh="pullDownRefresh" gesture="true" enablepulldown="true" enablepullup="true">
   <!-- content -->
    <div class="content-list">
      <list class="list" id="movie-list" @scrollbottom="loadMoreData">
        <list-item type="listItem" for="{{dataList}}" tid="$item.id">
          <movie-item item="{{$item}}"></movie-item>
        </list-item>
      </list>
    </div>
  <refresh-footer class="footer" spinnerstyle="behind" triggerratio="0.7" dragrate="0.5" triggersize="0" maxdragratio="1" maxdragsize="0" refreshdisplayratio="0.7" refreshdisplaysize="0" translationwithcontent="false" @move="footerMove" autorefresh="true">
    <text class="loading">Loading...</text>
  </refresh-footer>
  </refresh2>
</div>
</template>
<style>
  .root {
    align-items: center;
  }
  .list {
    padding-left: 16px;
    padding-right: 16px;
  }
  .content-list {
    background-color: #D0D0D0;
    flex-direction: column;
    align-items: center;
  }
  .container {
    height: 100%;
    width: 100%;
  }
  .header {
    height: 175%;
    width: 100%;
    background-color: #800000;
    justify-content: center;
    align-items: center;
  }
  .content {
    width: 100%;
    height: 100%;
    background-color: #ffffff;
  }
  .txt {
    width: 100%;
    height: 100px;
  }
  .circular {
    width: 100%;
    height: 75px;
  }
  .footer {
    height: 100px;
    width: 100%;
    background-color: #008000;
    justify-content: center;
    align-items: center;
  }
  .loading {
    color: #ffffff;
  }
</style>
<script>
import api from '../Common/SR399/service.js'
  const LOAD_MORE_INITIAL_INDEX = 1;
  const LOAD_MORE_INCREASE_THRESHOLD = 1;
  module.exports = {
    backgroundColor: "#ffffff",
    progressColor: "#ffffff",
    data: {
      dataList: [],
      currentTotalPages: Number.MAX_SAFE_INTEGER,
      currentPage: LOAD_MORE_INITIAL_INDEX,
    },
    computed: {
      loadMoreEnabled: {
        get() {
          return this.currentPage < this.currentTotalPages
        }
      },
    },
    onReady(options) {
      this.getData(LOAD_MORE_INITIAL_INDEX)
    },
    // Service calls
    loadMoreData: function () {
      if (this.loadMoreEnabled) {
        this.getData(this.currentPage + LOAD_MORE_INCREASE_THRESHOLD)
      }
    },
    clearData: function () {
      this.dataList = []
    },
    getData: function (page) {
      this.currentPage = page
      var app = this
      api.callGet({ page: page }, function (data) {
        if (page > LOAD_MORE_INCREASE_THRESHOLD) {
          data.results.forEach(movie => {
            app.dataList.push(movie)
          });
        } else {
          app.dataList = data.results
        }
        app.currentTotalPages = data.total_pages
      })
    },
    pullDownRefresh: function () {
      console.log("pullDownRefresh");
      console.log("pulldownrefreshing:" + this.$element('refresh').pulldownrefreshing)
      console.log("pulluprefreshing:" + this.$element('refresh').pulluprefreshing)
      this.$element('refresh').startPullDownRefresh()
      setTimeout(() => {
        this.clearData()
        this.getData(LOAD_MORE_INITIAL_INDEX)
        this.finishPullDownRefresh()
      }, 1500);
    },
    pullUpRefresh: function () {
      console.log("pullUpRefresh");
      console.log("pulldownrefreshing:" + this.$element('refresh').pulldownrefreshing)
      console.log("pulluprefreshing:" + this.$element('refresh').pulluprefreshing)
      this.$element('refresh').startPullUpRefresh();
      setTimeout(() => {
        this.finishPullUpRefresh()
      }, 1500);
    },
    refresh: function (e) {
      console.log("refresh:" + e.refreshing);
    },
    headerMove: function (params) {
      console.log("headermove - scrollY:" + params.scrollY + " percent:" + params.percent + " isDrag:" + params.isDrag + " refreshing:" + params.refreshing);
    },
    footerMove: function (params) {
      console.log("footermove - scrollY:" + params.scrollY + " percent:" + params.percent + " isDrag:" + params.isDrag + " refreshing:" + params.refreshing)
    },
    finishPullDownRefresh: function () {
      console.log("finishPullDownRefresh")
      this.$element('refresh').stopPullDownRefresh()
    },
    finishPullUpRefresh: function () {
      console.log("finishPullUpRefresh")
      this.$element('refresh').stopPullUpRefresh()
    },
  }
</script>

Version Change History

Version

Date

Description

1090

2022-05-19

First official version.