@tarojs/components-react 4.0.1-alpha.1 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -8
- package/dist/components/button/index.js +103 -78
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/icon/index.js +17 -26
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/image/index.js +101 -76
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/input/index.js +206 -183
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/pull-down-refresh/index.js +211 -195
- package/dist/components/pull-down-refresh/index.js.map +1 -1
- package/dist/components/scroll-view/index.js +167 -137
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/components/swiper/index.js +268 -248
- package/dist/components/swiper/index.js.map +1 -1
- package/dist/components/text/index.js +31 -22
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/view/index.js +97 -72
- package/dist/components/view/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/utils/index.js +15 -26
- package/dist/utils/index.js.map +1 -1
- package/package.json +18 -19
- package/dist/solid/components/button/index.js +0 -95
- package/dist/solid/components/button/index.js.map +0 -1
- package/dist/solid/components/button/style/index.scss.js +0 -4
- package/dist/solid/components/button/style/index.scss.js.map +0 -1
- package/dist/solid/components/icon/index.js +0 -39
- package/dist/solid/components/icon/index.js.map +0 -1
- package/dist/solid/components/icon/style/index.scss.js +0 -4
- package/dist/solid/components/icon/style/index.scss.js.map +0 -1
- package/dist/solid/components/image/index.js +0 -94
- package/dist/solid/components/image/index.js.map +0 -1
- package/dist/solid/components/input/index.js +0 -256
- package/dist/solid/components/input/index.js.map +0 -1
- package/dist/solid/components/input/style/index.scss.js +0 -4
- package/dist/solid/components/input/style/index.scss.js.map +0 -1
- package/dist/solid/components/pull-down-refresh/index.js +0 -334
- package/dist/solid/components/pull-down-refresh/index.js.map +0 -1
- package/dist/solid/components/pull-down-refresh/style/index.css.js +0 -4
- package/dist/solid/components/pull-down-refresh/style/index.css.js.map +0 -1
- package/dist/solid/components/scroll-view/index.js +0 -188
- package/dist/solid/components/scroll-view/index.js.map +0 -1
- package/dist/solid/components/scroll-view/style/index.css.js +0 -4
- package/dist/solid/components/scroll-view/style/index.css.js.map +0 -1
- package/dist/solid/components/swiper/index.js +0 -307
- package/dist/solid/components/swiper/index.js.map +0 -1
- package/dist/solid/components/swiper/style/index.css.js +0 -4
- package/dist/solid/components/swiper/style/index.css.js.map +0 -1
- package/dist/solid/components/text/index.js +0 -32
- package/dist/solid/components/text/index.js.map +0 -1
- package/dist/solid/components/text/style/index.css.js +0 -4
- package/dist/solid/components/text/style/index.css.js.map +0 -1
- package/dist/solid/components/view/index.js +0 -88
- package/dist/solid/components/view/index.js.map +0 -1
- package/dist/solid/index.css +0 -1
- package/dist/solid/index.js +0 -13
- package/dist/solid/index.js.map +0 -1
- package/dist/solid/utils/hooks.solid.js +0 -54
- package/dist/solid/utils/hooks.solid.js.map +0 -1
- package/dist/solid/utils/index.js +0 -58
- package/dist/solid/utils/index.js.map +0 -1
- package/dist/utils/hooks.react.js +0 -15
- package/dist/utils/hooks.react.js.map +0 -1
- package/types/index.d.ts +0 -17
- /package/dist/{solid/components/image → components/view}/style/index.css.js +0 -0
- /package/dist/{solid/components/image → components/view}/style/index.css.js.map +0 -0
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
3
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
4
|
+
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
|
|
5
|
+
import _inherits from '@babel/runtime/helpers/inherits';
|
|
6
|
+
import _createSuper from '@babel/runtime/helpers/createSuper';
|
|
1
7
|
import { __rest } from 'tslib';
|
|
2
8
|
import './style/index.css.js';
|
|
3
9
|
import Taro from '@tarojs/taro';
|
|
4
10
|
import classNames from 'classnames';
|
|
5
|
-
import
|
|
6
|
-
import { createForwardRefComponent } from '../../utils/index.js';
|
|
7
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
11
|
+
import React from 'react';
|
|
8
12
|
|
|
9
13
|
function setTransform(nodeStyle, value) {
|
|
10
14
|
nodeStyle.transform = value;
|
|
11
15
|
nodeStyle.webkitTransform = value;
|
|
12
16
|
nodeStyle.MozTransform = value;
|
|
13
17
|
}
|
|
14
|
-
|
|
18
|
+
var isWebView = typeof navigator !== 'undefined' && /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
|
|
15
19
|
var PullDownState;
|
|
16
20
|
(function (PullDownState) {
|
|
17
21
|
PullDownState["activate"] = "activate";
|
|
@@ -26,103 +30,113 @@ var INDICATOR;
|
|
|
26
30
|
INDICATOR["release"] = "loading";
|
|
27
31
|
INDICATOR["finish"] = "finish";
|
|
28
32
|
})(INDICATOR || (INDICATOR = {}));
|
|
29
|
-
|
|
33
|
+
var supportsPassive = false;
|
|
30
34
|
try {
|
|
31
|
-
|
|
32
|
-
get() {
|
|
35
|
+
var opts = Object.defineProperty({}, 'passive', {
|
|
36
|
+
get: function get() {
|
|
33
37
|
supportsPassive = true;
|
|
34
38
|
}
|
|
35
39
|
});
|
|
36
|
-
window.addEventListener('cancel', ()
|
|
40
|
+
window.addEventListener('cancel', function () {
|
|
41
|
+
return {};
|
|
42
|
+
}, opts);
|
|
37
43
|
} catch (e) {} // eslint-disable-line no-empty
|
|
38
|
-
|
|
44
|
+
var willPreventDefault = supportsPassive ? {
|
|
39
45
|
passive: false
|
|
40
46
|
} : false;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
var PullDownRefresh = /*#__PURE__*/function (_React$Component) {
|
|
48
|
+
_inherits(PullDownRefresh, _React$Component);
|
|
49
|
+
var _super = _createSuper(PullDownRefresh);
|
|
50
|
+
function PullDownRefresh() {
|
|
51
|
+
var _this;
|
|
52
|
+
_classCallCheck(this, PullDownRefresh);
|
|
53
|
+
_this = _super.apply(this, arguments);
|
|
44
54
|
// https://github.com/yiminghe/zscroller/blob/2d97973287135745818a0537712235a39a6a62a1/src/Scroller.js#L355
|
|
45
55
|
// currSt: `activate` / `deactivate` / `release` / `finish`
|
|
46
|
-
|
|
56
|
+
_this.state = {
|
|
47
57
|
currSt: PullDownState.deactivate,
|
|
48
58
|
dragOnEdge: false
|
|
49
59
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
_this._ScreenY = 0;
|
|
61
|
+
_this._startScreenY = 0;
|
|
62
|
+
_this._lastScreenY = 0;
|
|
63
|
+
_this._isMounted = false;
|
|
64
|
+
_this.listeners = [];
|
|
65
|
+
_this.triggerPullDownRefresh = function (flag) {
|
|
56
66
|
// 在初始化时、用代码 自动 触发 pullDownRefresh
|
|
57
67
|
// 添加this._isMounted的判断,否则组建一实例化,currSt就会是finish
|
|
58
|
-
if (!
|
|
68
|
+
if (!_this.state.dragOnEdge && _this._isMounted) {
|
|
59
69
|
if (flag) {
|
|
60
|
-
|
|
70
|
+
_this._lastScreenY = _this.props.distanceToRefresh + 1;
|
|
61
71
|
// change dom need after setState
|
|
62
|
-
|
|
72
|
+
_this.setState({
|
|
63
73
|
currSt: PullDownState.release
|
|
64
|
-
}, ()
|
|
74
|
+
}, function () {
|
|
75
|
+
return _this.setContentStyle(_this._lastScreenY);
|
|
76
|
+
});
|
|
65
77
|
} else {
|
|
66
|
-
|
|
78
|
+
_this.setState({
|
|
67
79
|
currSt: PullDownState.finish
|
|
68
|
-
}, ()
|
|
80
|
+
}, function () {
|
|
81
|
+
return _this.reset();
|
|
82
|
+
});
|
|
69
83
|
}
|
|
70
84
|
}
|
|
71
85
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
touchstart:
|
|
76
|
-
touchmove:
|
|
77
|
-
touchend:
|
|
78
|
-
touchcancel:
|
|
86
|
+
_this.init = function () {
|
|
87
|
+
var ele = _this.scrollContainer;
|
|
88
|
+
_this._to = {
|
|
89
|
+
touchstart: _this.onTouchStart.bind(_assertThisInitialized(_this), ele),
|
|
90
|
+
touchmove: _this.onTouchMove.bind(_assertThisInitialized(_this), ele),
|
|
91
|
+
touchend: _this.onTouchEnd.bind(_assertThisInitialized(_this), ele),
|
|
92
|
+
touchcancel: _this.onTouchEnd.bind(_assertThisInitialized(_this), ele)
|
|
79
93
|
};
|
|
80
|
-
Object.keys(
|
|
81
|
-
ele.addEventListener(key,
|
|
94
|
+
Object.keys(_this._to).forEach(function (key) {
|
|
95
|
+
ele.addEventListener(key, _this._to[key], willPreventDefault);
|
|
82
96
|
});
|
|
83
97
|
};
|
|
84
|
-
|
|
85
|
-
if (!
|
|
86
|
-
|
|
87
|
-
Object.keys(
|
|
88
|
-
ele.removeEventListener(key,
|
|
98
|
+
_this.destroy = function () {
|
|
99
|
+
if (!_this._to) return;
|
|
100
|
+
var ele = _this.scrollContainer;
|
|
101
|
+
Object.keys(_this._to).forEach(function (key) {
|
|
102
|
+
ele.removeEventListener(key, _this._to[key]);
|
|
89
103
|
});
|
|
90
104
|
};
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
_this.onTouchStart = function (_, e) {
|
|
106
|
+
_this._ScreenY = _this._startScreenY = e.touches[0].screenY;
|
|
93
107
|
// 一开始 refreshing 为 true 时 this._lastScreenY 有值
|
|
94
|
-
|
|
108
|
+
_this._lastScreenY = _this._lastScreenY || 0;
|
|
95
109
|
};
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
_this.isEdge = function (ele) {
|
|
111
|
+
var container = _this.scrollContainer;
|
|
98
112
|
if (container && container === document.body) {
|
|
99
113
|
// In chrome61 `document.body.scrollTop` is invalid
|
|
100
|
-
|
|
114
|
+
var scrollNode = document.scrollingElement ? document.scrollingElement : document.body;
|
|
101
115
|
return scrollNode.scrollTop <= 0;
|
|
102
116
|
}
|
|
103
117
|
return ele.scrollTop <= 0;
|
|
104
118
|
};
|
|
105
|
-
|
|
106
|
-
if (Math.abs(
|
|
119
|
+
_this.damping = function (dy) {
|
|
120
|
+
if (Math.abs(_this._lastScreenY) > _this.props.damping) {
|
|
107
121
|
return 0;
|
|
108
122
|
}
|
|
109
|
-
|
|
123
|
+
var ratio = Math.abs(_this._ScreenY - _this._startScreenY) / window.screen.height;
|
|
110
124
|
dy *= (1 - ratio) * 0.6;
|
|
111
125
|
return dy;
|
|
112
126
|
};
|
|
113
|
-
|
|
127
|
+
_this.onTouchMove = function (ele, e) {
|
|
114
128
|
// 使用 pageY 对比有问题
|
|
115
|
-
|
|
129
|
+
var _screenY = e.touches[0].screenY;
|
|
116
130
|
// 拖动方向不符合的不处理
|
|
117
|
-
if (
|
|
131
|
+
if (_this._startScreenY > _screenY) {
|
|
118
132
|
return;
|
|
119
133
|
}
|
|
120
|
-
if (
|
|
121
|
-
if (!
|
|
134
|
+
if (_this.isEdge(ele)) {
|
|
135
|
+
if (!_this.state.dragOnEdge) {
|
|
122
136
|
// 当用户开始往上滑的时候isEdge还是false的话,会导致this._ScreenY不是想要的,只有当isEdge为true时,再上滑,才有意义
|
|
123
137
|
// 下面这行代码解决了上面这个问题
|
|
124
|
-
|
|
125
|
-
|
|
138
|
+
_this._ScreenY = _this._startScreenY = e.touches[0].screenY;
|
|
139
|
+
_this.setState({
|
|
126
140
|
dragOnEdge: true
|
|
127
141
|
});
|
|
128
142
|
}
|
|
@@ -132,21 +146,21 @@ class PullDownRefresh extends React__default.Component {
|
|
|
132
146
|
// add stopPropagation with fastclick will trigger content onClick event. why?
|
|
133
147
|
// ref https://github.com/ant-design/ant-design-mobile/issues/2141
|
|
134
148
|
// e.stopPropagation();
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (Math.abs(
|
|
140
|
-
if (
|
|
149
|
+
var _diff = Math.round(_screenY - _this._ScreenY);
|
|
150
|
+
_this._ScreenY = _screenY;
|
|
151
|
+
_this._lastScreenY += _this.damping(_diff);
|
|
152
|
+
_this.setContentStyle(_this._lastScreenY);
|
|
153
|
+
if (Math.abs(_this._lastScreenY) < _this.props.distanceToRefresh) {
|
|
154
|
+
if (_this.state.currSt !== PullDownState.deactivate) {
|
|
141
155
|
// console.log('back to the distance');
|
|
142
|
-
|
|
156
|
+
_this.setState({
|
|
143
157
|
currSt: PullDownState.deactivate
|
|
144
158
|
});
|
|
145
159
|
}
|
|
146
160
|
} else {
|
|
147
|
-
if (
|
|
161
|
+
if (_this.state.currSt === PullDownState.deactivate) {
|
|
148
162
|
// console.log('reach to the distance');
|
|
149
|
-
|
|
163
|
+
_this.setState({
|
|
150
164
|
currSt: PullDownState.activate
|
|
151
165
|
});
|
|
152
166
|
}
|
|
@@ -154,167 +168,169 @@ class PullDownRefresh extends React__default.Component {
|
|
|
154
168
|
// https://github.com/ant-design/ant-design-mobile/issues/573#issuecomment-339560829
|
|
155
169
|
// iOS UIWebView issue, It seems no problem in WKWebView
|
|
156
170
|
if (isWebView && e.changedTouches[0].clientY < 0) {
|
|
157
|
-
|
|
171
|
+
_this.onTouchEnd();
|
|
158
172
|
}
|
|
159
173
|
}
|
|
160
174
|
};
|
|
161
|
-
|
|
175
|
+
_this.onTouchEnd = function () {
|
|
162
176
|
var _a, _b;
|
|
163
|
-
if (
|
|
164
|
-
|
|
177
|
+
if (_this.state.dragOnEdge) {
|
|
178
|
+
_this.setState({
|
|
165
179
|
dragOnEdge: false
|
|
166
180
|
});
|
|
167
181
|
}
|
|
168
|
-
if (
|
|
169
|
-
|
|
182
|
+
if (_this.state.currSt === PullDownState.activate) {
|
|
183
|
+
_this.setState({
|
|
170
184
|
currSt: PullDownState.release
|
|
171
185
|
});
|
|
172
|
-
(_b = (_a =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
} else if (
|
|
176
|
-
|
|
177
|
-
|
|
186
|
+
(_b = (_a = _this.props).onRefresh) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
187
|
+
_this._lastScreenY = _this.props.distanceToRefresh + 1;
|
|
188
|
+
_this.setContentStyle(_this._lastScreenY);
|
|
189
|
+
} else if (_this.state.currSt === 'release') {
|
|
190
|
+
_this._lastScreenY = _this.props.distanceToRefresh + 1;
|
|
191
|
+
_this.setContentStyle(_this._lastScreenY);
|
|
178
192
|
} else {
|
|
179
|
-
|
|
193
|
+
_this.reset();
|
|
180
194
|
}
|
|
181
195
|
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
196
|
+
_this.reset = function () {
|
|
197
|
+
_this._lastScreenY = 0;
|
|
198
|
+
_this.setContentStyle(0);
|
|
185
199
|
};
|
|
186
|
-
|
|
200
|
+
_this.setContentStyle = function (ty) {
|
|
187
201
|
// TODO: Why sometimes do not have `this.contentRef` ?
|
|
188
|
-
if (
|
|
202
|
+
if (_this.contentRef) {
|
|
189
203
|
// translate3d 不清理 会影响内部元素定位
|
|
190
204
|
if (ty) {
|
|
191
|
-
setTransform(
|
|
205
|
+
setTransform(_this.contentRef.style, "translate3d(0px,".concat(ty, "px,0)"));
|
|
192
206
|
} else {
|
|
193
|
-
setTransform(
|
|
207
|
+
setTransform(_this.contentRef.style, '');
|
|
194
208
|
}
|
|
195
209
|
}
|
|
196
210
|
};
|
|
211
|
+
return _this;
|
|
197
212
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.init();
|
|
204
|
-
this._isMounted = true;
|
|
205
|
-
this.listeners = [['__taroStartPullDownRefresh', _ref => {
|
|
206
|
-
let {
|
|
207
|
-
successHandler,
|
|
208
|
-
errorHandler
|
|
209
|
-
} = _ref;
|
|
210
|
-
try {
|
|
211
|
-
this.triggerPullDownRefresh(true);
|
|
212
|
-
successHandler({
|
|
213
|
-
errMsg: 'startPullDownRefresh: ok'
|
|
214
|
-
});
|
|
215
|
-
} catch (e) {
|
|
216
|
-
errorHandler({
|
|
217
|
-
errMsg: 'startPullDownRefresh: fail'
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}], ['__taroStopPullDownRefresh', _ref2 => {
|
|
221
|
-
let {
|
|
222
|
-
successHandler,
|
|
223
|
-
errorHandler
|
|
224
|
-
} = _ref2;
|
|
225
|
-
try {
|
|
226
|
-
this.triggerPullDownRefresh(false);
|
|
227
|
-
successHandler({
|
|
228
|
-
errMsg: 'stopPullDownRefresh: ok'
|
|
229
|
-
});
|
|
230
|
-
} catch (e) {
|
|
231
|
-
errorHandler({
|
|
232
|
-
errMsg: 'stopPullDownRefresh: fail'
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}]];
|
|
236
|
-
this.listeners.forEach(_ref3 => {
|
|
237
|
-
let [evtName, callback] = _ref3;
|
|
238
|
-
Taro.eventCenter.on(evtName, callback);
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
componentWillUnmount() {
|
|
242
|
-
this.destroy();
|
|
243
|
-
this.listeners.forEach(_ref4 => {
|
|
244
|
-
let [evtName, callback] = _ref4;
|
|
245
|
-
Taro.eventCenter.off(evtName, callback);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
componentDidUpdate(_, prevState) {
|
|
249
|
-
var _a, _b, _c, _d;
|
|
250
|
-
if (prevState.currSt !== this.state.currSt) {
|
|
251
|
-
const pageEl = this.scrollContainer;
|
|
252
|
-
switch (this.state.currSt) {
|
|
253
|
-
case PullDownState.release:
|
|
254
|
-
(_b = (_a = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _a === void 0 ? void 0 : _a.onPullDownRefresh) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
255
|
-
break;
|
|
256
|
-
case PullDownState.deactivate:
|
|
257
|
-
(_d = (_c = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _c === void 0 ? void 0 : _c.onPullIntercept) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
258
|
-
}
|
|
213
|
+
_createClass(PullDownRefresh, [{
|
|
214
|
+
key: "scrollContainer",
|
|
215
|
+
get: function get() {
|
|
216
|
+
var _a, _b;
|
|
217
|
+
return ((_a = this.contentRef) === null || _a === void 0 ? void 0 : _a.parentElement) || ((_b = this.contentRef) === null || _b === void 0 ? void 0 : _b.closest('.taro_page_stationed')) || document.querySelector('.taro_page_stationed') || document.querySelector('.taro_page') || document.querySelector('.taro_router') || document.querySelector('.taro-tabbar__panel') || document.body;
|
|
259
218
|
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
219
|
+
}, {
|
|
220
|
+
key: "componentDidMount",
|
|
221
|
+
value: function componentDidMount() {
|
|
222
|
+
var _this2 = this;
|
|
223
|
+
this.init();
|
|
224
|
+
this._isMounted = true;
|
|
225
|
+
this.listeners = [['__taroStartPullDownRefresh', function (_ref) {
|
|
226
|
+
var successHandler = _ref.successHandler,
|
|
227
|
+
errorHandler = _ref.errorHandler;
|
|
228
|
+
try {
|
|
229
|
+
_this2.triggerPullDownRefresh(true);
|
|
230
|
+
successHandler({
|
|
231
|
+
errMsg: 'startPullDownRefresh: ok'
|
|
232
|
+
});
|
|
233
|
+
} catch (e) {
|
|
234
|
+
errorHandler({
|
|
235
|
+
errMsg: 'startPullDownRefresh: fail'
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}], ['__taroStopPullDownRefresh', function (_ref2) {
|
|
239
|
+
var successHandler = _ref2.successHandler,
|
|
240
|
+
errorHandler = _ref2.errorHandler;
|
|
241
|
+
try {
|
|
242
|
+
_this2.triggerPullDownRefresh(false);
|
|
243
|
+
successHandler({
|
|
244
|
+
errMsg: 'stopPullDownRefresh: ok'
|
|
245
|
+
});
|
|
246
|
+
} catch (e) {
|
|
247
|
+
errorHandler({
|
|
248
|
+
errMsg: 'stopPullDownRefresh: fail'
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}]];
|
|
252
|
+
this.listeners.forEach(function (_ref3) {
|
|
253
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
254
|
+
evtName = _ref4[0],
|
|
255
|
+
callback = _ref4[1];
|
|
256
|
+
Taro.eventCenter.on(evtName, callback);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}, {
|
|
260
|
+
key: "componentWillUnmount",
|
|
261
|
+
value: function componentWillUnmount() {
|
|
262
|
+
this.destroy();
|
|
263
|
+
this.listeners.forEach(function (_ref5) {
|
|
264
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
265
|
+
evtName = _ref6[0],
|
|
266
|
+
callback = _ref6[1];
|
|
267
|
+
Taro.eventCenter.off(evtName, callback);
|
|
293
268
|
});
|
|
294
|
-
};
|
|
295
|
-
if (this.scrollContainer) {
|
|
296
|
-
return renderRefresh(`${prefixCls}-content ${prefixCls}-down`);
|
|
297
269
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
270
|
+
}, {
|
|
271
|
+
key: "componentDidUpdate",
|
|
272
|
+
value: function componentDidUpdate(_, prevState) {
|
|
273
|
+
var _a, _b, _c, _d;
|
|
274
|
+
if (prevState.currSt !== this.state.currSt) {
|
|
275
|
+
var pageEl = this.scrollContainer;
|
|
276
|
+
switch (this.state.currSt) {
|
|
277
|
+
case PullDownState.release:
|
|
278
|
+
(_b = (_a = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _a === void 0 ? void 0 : _a.onPullDownRefresh) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
279
|
+
break;
|
|
280
|
+
case PullDownState.deactivate:
|
|
281
|
+
(_d = (_c = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _c === void 0 ? void 0 : _c.onPullIntercept) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
302
282
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}, {
|
|
286
|
+
key: "render",
|
|
287
|
+
value: function render() {
|
|
288
|
+
var _this3 = this;
|
|
289
|
+
var props = Object.assign({}, this.props);
|
|
290
|
+
delete props.damping;
|
|
291
|
+
delete props.indicator;
|
|
292
|
+
delete props.distanceToRefresh;
|
|
293
|
+
delete props.onRefresh;
|
|
294
|
+
var className = props.className,
|
|
295
|
+
prefixCls = props.prefixCls,
|
|
296
|
+
children = props.children,
|
|
297
|
+
restProps = __rest(props, ["className", "prefixCls", "children"]);
|
|
298
|
+
var renderRefresh = function renderRefresh(cls) {
|
|
299
|
+
var _this3$state = _this3.state,
|
|
300
|
+
currSt = _this3$state.currSt,
|
|
301
|
+
dragOnEdge = _this3$state.dragOnEdge;
|
|
302
|
+
var cla = classNames(cls, !dragOnEdge && "".concat(prefixCls, "-transition"));
|
|
303
|
+
var showIndicator = currSt === 'activate' || currSt === 'release';
|
|
304
|
+
return React.createElement("div", {
|
|
305
|
+
className: "".concat(prefixCls, "-content-wrapper")
|
|
306
|
+
}, React.createElement("div", {
|
|
307
|
+
className: cla,
|
|
308
|
+
ref: function ref(el) {
|
|
309
|
+
_this3.contentRef = el;
|
|
310
|
+
}
|
|
311
|
+
}, showIndicator && React.createElement("div", {
|
|
312
|
+
className: "".concat(prefixCls, "-indicator")
|
|
313
|
+
}, React.createElement("div", null), React.createElement("div", null), React.createElement("div", null)), children));
|
|
314
|
+
};
|
|
315
|
+
if (this.scrollContainer) {
|
|
316
|
+
return renderRefresh("".concat(prefixCls, "-content ").concat(prefixCls, "-down"));
|
|
317
|
+
}
|
|
318
|
+
return React.createElement("pull-down-refresh", Object.assign({
|
|
319
|
+
ref: function ref(el) {
|
|
320
|
+
_this3.containerRef = el;
|
|
321
|
+
},
|
|
322
|
+
className: classNames(className, prefixCls, "".concat(prefixCls, "-down"))
|
|
323
|
+
}, restProps), renderRefresh("".concat(prefixCls, "-content")));
|
|
324
|
+
}
|
|
325
|
+
}]);
|
|
326
|
+
return PullDownRefresh;
|
|
327
|
+
}(React.Component);
|
|
311
328
|
PullDownRefresh.defaultProps = {
|
|
312
329
|
prefixCls: 'rmc-pull-to-refresh',
|
|
313
330
|
distanceToRefresh: 50,
|
|
314
331
|
damping: 100,
|
|
315
332
|
indicator: INDICATOR
|
|
316
333
|
};
|
|
317
|
-
var index = createForwardRefComponent(PullDownRefresh);
|
|
318
334
|
|
|
319
|
-
export {
|
|
335
|
+
export { PullDownRefresh as default };
|
|
320
336
|
//# sourceMappingURL=index.js.map
|