Skip to content

Commit 2a0eb3e

Browse files
authored
fix(pull-down-refresh): dynamically set container maximum height error (#3592)
1 parent 1eaa1e9 commit 2a0eb3e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/pull-down-refresh/pull-down-refresh.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SuperComponent, wxComponent, RelationsOptions } from '../common/src/index';
22
import config from '../common/config';
33
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';
65

76
const { prefix } = config;
87
const name = `${prefix}-pull-down-refresh`;
8+
const defaultLoadingTexts = ['下拉刷新', '松手刷新', '正在刷新', '刷新完成'];
99

1010
@wxComponent()
1111
export default class PullDownRefresh extends SuperComponent {
@@ -39,11 +39,10 @@ export default class PullDownRefresh extends SuperComponent {
3939

4040
properties = props;
4141

42-
behaviors = [useCustomNavbar];
43-
4442
data = {
4543
prefix,
4644
classPrefix: name,
45+
distanceTop: 0,
4746
barHeight: 0,
4847
tipsHeight: 0,
4948
refreshStatus: -1,
@@ -58,15 +57,21 @@ export default class PullDownRefresh extends SuperComponent {
5857
attached() {
5958
const { screenWidth } = systemInfo;
6059
const { loadingTexts, maxBarHeight, loadingBarHeight } = this.properties;
60+
const isCustomLoadingTexts = Array.isArray(loadingTexts) && loadingTexts.length >= 4;
61+
6162
this.setData({
6263
_maxBarHeight: unitConvert(maxBarHeight),
6364
_loadingBarHeight: unitConvert(loadingBarHeight),
64-
loadingTexts:
65-
Array.isArray(loadingTexts) && loadingTexts.length >= 4
66-
? loadingTexts
67-
: ['下拉刷新', '松手刷新', '正在刷新', '刷新完成'],
65+
loadingTexts: isCustomLoadingTexts ? loadingTexts : defaultLoadingTexts,
6866
});
67+
6968
this.pixelRatio = 750 / screenWidth;
69+
70+
getRect(this, `.${name}`).then((rect) => {
71+
this.setData({
72+
distanceTop: rect.top,
73+
});
74+
});
7075
},
7176

7277
detached() {

0 commit comments

Comments
 (0)