1
1
import { SuperComponent , wxComponent , RelationsOptions } from '../common/src/index' ;
2
2
import config from '../common/config' ;
3
3
import props from './props' ;
4
- import { unitConvert , systemInfo } from '../common/utils' ;
5
- import useCustomNavbar from '../mixins/using-custom-navbar' ;
4
+ import { unitConvert , systemInfo , getRect } from '../common/utils' ;
6
5
7
6
const { prefix } = config ;
8
7
const name = `${ prefix } -pull-down-refresh` ;
8
+ const defaultLoadingTexts = [ '下拉刷新' , '松手刷新' , '正在刷新' , '刷新完成' ] ;
9
9
10
10
@wxComponent ( )
11
11
export default class PullDownRefresh extends SuperComponent {
@@ -39,11 +39,10 @@ export default class PullDownRefresh extends SuperComponent {
39
39
40
40
properties = props ;
41
41
42
- behaviors = [ useCustomNavbar ] ;
43
-
44
42
data = {
45
43
prefix,
46
44
classPrefix : name ,
45
+ distanceTop : 0 ,
47
46
barHeight : 0 ,
48
47
tipsHeight : 0 ,
49
48
refreshStatus : - 1 ,
@@ -58,15 +57,21 @@ export default class PullDownRefresh extends SuperComponent {
58
57
attached ( ) {
59
58
const { screenWidth } = systemInfo ;
60
59
const { loadingTexts, maxBarHeight, loadingBarHeight } = this . properties ;
60
+ const isCustomLoadingTexts = Array . isArray ( loadingTexts ) && loadingTexts . length >= 4 ;
61
+
61
62
this . setData ( {
62
63
_maxBarHeight : unitConvert ( maxBarHeight ) ,
63
64
_loadingBarHeight : unitConvert ( loadingBarHeight ) ,
64
- loadingTexts :
65
- Array . isArray ( loadingTexts ) && loadingTexts . length >= 4
66
- ? loadingTexts
67
- : [ '下拉刷新' , '松手刷新' , '正在刷新' , '刷新完成' ] ,
65
+ loadingTexts : isCustomLoadingTexts ? loadingTexts : defaultLoadingTexts ,
68
66
} ) ;
67
+
69
68
this . pixelRatio = 750 / screenWidth ;
69
+
70
+ getRect ( this , `.${ name } ` ) . then ( ( rect ) => {
71
+ this . setData ( {
72
+ distanceTop : rect . top ,
73
+ } ) ;
74
+ } ) ;
70
75
} ,
71
76
72
77
detached ( ) {
0 commit comments