You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
2.4 KiB
124 lines
2.4 KiB
Component({
|
|
options: {
|
|
multipleSlots: true
|
|
},
|
|
properties: {
|
|
height: {
|
|
type: Number,
|
|
value: 800
|
|
},
|
|
refresherTextStyle: {
|
|
type: String,
|
|
value: "black"
|
|
},
|
|
refresherBackground: {
|
|
type: String,
|
|
value: "inherit"
|
|
},
|
|
scrollTop: {
|
|
type: Number,
|
|
value: 0
|
|
},
|
|
triggered: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
threshold: {
|
|
type: Number,
|
|
value: 50
|
|
},
|
|
restoredText: {
|
|
type: String,
|
|
value: "下拉刷新"
|
|
},
|
|
pullingText: {
|
|
type: String,
|
|
value: "松开刷新"
|
|
},
|
|
refreshingText: {
|
|
type: String,
|
|
value: "正在刷新"
|
|
},
|
|
useSlotStyle: Boolean,
|
|
scrollX: Boolean,
|
|
scrollY: {
|
|
type: Boolean,
|
|
value: true
|
|
},
|
|
upperThreshold: {
|
|
type: Number,
|
|
value: 50
|
|
},
|
|
owerThreshold: {
|
|
type: Number,
|
|
value: 50
|
|
},
|
|
scrollLeft: Number,
|
|
scrollIntoView: String,
|
|
scrollWithAnimation: Boolean,
|
|
enableBackToTop: {
|
|
type: Boolean,
|
|
value: true
|
|
},
|
|
enableFlex: Boolean,
|
|
scrollAnchoring: Boolean
|
|
},
|
|
data: {
|
|
stateText: "下拉刷新",
|
|
stateCode: 0,
|
|
process: 0
|
|
},
|
|
lifetimes: {
|
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
detached: function () {}
|
|
},
|
|
methods: {
|
|
$emit(type, e) {
|
|
this.triggerEvent(type, e)
|
|
},
|
|
on2Upper(e) {
|
|
this.$emit("scrolltoupper", e)
|
|
},
|
|
on2Lower(e) {
|
|
this.$emit("scrolltolower", e)
|
|
},
|
|
onScroll(e) {
|
|
this.$emit("scroll", e)
|
|
},
|
|
onPulling(e) {
|
|
const dy = e.detail.dy,
|
|
threshold = this.properties.threshold
|
|
this.setData({
|
|
process: dy / threshold,
|
|
stateCode: 1,
|
|
stateText: dy < threshold ?
|
|
this.properties.restoredText : this.properties.pullingText
|
|
})
|
|
this.$emit("pulling", e)
|
|
},
|
|
onRefreshed(e) {
|
|
this.setData({
|
|
stateText: this.properties.refreshingText,
|
|
stateCode: 2,
|
|
process: 1
|
|
})
|
|
this.$emit("refresh", e)
|
|
},
|
|
onRestored(e) {
|
|
this.setData({
|
|
stateText: "",
|
|
stateCode: 0,
|
|
process: 0
|
|
})
|
|
this.$emit("restore", e)
|
|
},
|
|
onAbort(e) {
|
|
this.setData({
|
|
stateText: "",
|
|
stateCode: 0,
|
|
process: 0
|
|
})
|
|
this.$emit("abort", e)
|
|
}
|
|
}
|
|
})
|