pixuireactcomponents 1.5.38 → 1.5.40
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/index.d.ts
CHANGED
|
@@ -19,4 +19,5 @@ export { LoadChecker } from "./src/components/tools/LoadChecker";
|
|
|
19
19
|
export { AntiRepeat } from "./src/components/tools/antiRepeat";
|
|
20
20
|
export { DragList } from "./src/components/react/app/dragList/dragList";
|
|
21
21
|
export { QRCode } from "./src/components/react/app/qrcode/QRCode";
|
|
22
|
+
export { VirtualList } from "./src/components/react/app/virtualList/VirtualList";
|
|
22
23
|
export { Slider, SliderProps } from "./src/components/react/app/slider/Slider";
|
package/index.js
CHANGED
|
@@ -25,3 +25,4 @@ export { LoadChecker } from './src/components/tools/LoadChecker';
|
|
|
25
25
|
export { AntiRepeat } from './src/components/tools/antiRepeat';
|
|
26
26
|
export { DragList } from './src/components/react/app/dragList/dragList';
|
|
27
27
|
export { QRCode } from './src/components/react/app/qrcode/QRCode';
|
|
28
|
+
export { VirtualList } from './src/components/react/app/virtualList/VirtualList';
|
package/lib/loadlib/lib_mgr.js
CHANGED
|
@@ -18,20 +18,20 @@ var MainLibImpl = /** @class */ (function () {
|
|
|
18
18
|
function MainLibImpl() {
|
|
19
19
|
}
|
|
20
20
|
MainLibImpl.prototype.load = function () {
|
|
21
|
-
console.log('loading openplatfrom');
|
|
21
|
+
console.log('component: loading openplatfrom');
|
|
22
22
|
this.lib = loadlib.loadLib('openplatform');
|
|
23
23
|
if (this.lib == undefined) {
|
|
24
|
-
console.log('load failed');
|
|
24
|
+
console.log('component: load failed');
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
console.log('load success');
|
|
28
|
-
console.log('function table start');
|
|
27
|
+
console.log('component: load success');
|
|
28
|
+
console.log('component: function table start');
|
|
29
29
|
for (var k in this.lib) {
|
|
30
30
|
if (k.startsWith('JS_')) {
|
|
31
31
|
console.log("".concat(k));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
console.log('function table end');
|
|
34
|
+
console.log('component: function table end');
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
MainLibImpl.prototype.isLoadSuccess = function () {
|
package/package.json
CHANGED
|
@@ -69,10 +69,6 @@ interface VirtualListProps {
|
|
|
69
69
|
touchBottomThreshold?: number;
|
|
70
70
|
/** 加载更多数据的回调函数 */
|
|
71
71
|
loadMore?: () => Promise<void>;
|
|
72
|
-
/** 顶部区域组件 */
|
|
73
|
-
TopArea?: h.JSX.Element;
|
|
74
|
-
/** 顶部区域尺寸 */
|
|
75
|
-
topAreaSize?: number;
|
|
76
72
|
/** 滚动相关配置属性 */
|
|
77
73
|
scrollProps?: VirtualListScrollProps;
|
|
78
74
|
}
|
|
@@ -104,13 +100,12 @@ export declare class VirtualList extends Component<VirtualListProps, VirtualList
|
|
|
104
100
|
protected isLoading: boolean;
|
|
105
101
|
/** 视窗可见数量 */
|
|
106
102
|
protected visibleCount: number;
|
|
107
|
-
/** 顶部区域高度 */
|
|
108
|
-
protected topHeight: number;
|
|
109
103
|
constructor(props: VirtualListProps);
|
|
110
104
|
componentDidMount(): void;
|
|
111
105
|
shouldComponentUpdate(nextProps: Readonly<VirtualListProps>, nextState: Readonly<VirtualListState>, nextContext: any): boolean;
|
|
112
106
|
componentWillReceiveProps(nextProps: Readonly<VirtualListProps>): void;
|
|
113
107
|
onScroll: (e: Event) => void;
|
|
108
|
+
private HandleScrollProps;
|
|
114
109
|
render(): h.JSX.Element;
|
|
115
110
|
}
|
|
116
111
|
export {};
|
|
@@ -104,8 +104,7 @@ var VirtualList = /** @class */ (function (_super) {
|
|
|
104
104
|
height: props.itemSize,
|
|
105
105
|
width: props.width,
|
|
106
106
|
};
|
|
107
|
-
_this.
|
|
108
|
-
_this.listHeight = props.itemCount * props.itemSize + _this.topHeight;
|
|
107
|
+
_this.listHeight = props.itemCount * props.itemSize;
|
|
109
108
|
_this.state = {
|
|
110
109
|
start: 0,
|
|
111
110
|
end: 0,
|
|
@@ -132,7 +131,7 @@ var VirtualList = /** @class */ (function (_super) {
|
|
|
132
131
|
this.itemCount = this.visibleCount;
|
|
133
132
|
for (var i = 0; i < this.itemCount + this.props.cacheSize * 2; i++) {
|
|
134
133
|
var ref = createRef();
|
|
135
|
-
var itemCrossSize =
|
|
134
|
+
var itemCrossSize = "100%";
|
|
136
135
|
var item = {
|
|
137
136
|
vNode: (h(VirtualListItem, { layout: this.props.layout, index: i, key: i, ref: ref, itemMainSize: this.props.itemSize, itemCrossSize: itemCrossSize, child: this.props.renderItemFunc(i) })),
|
|
138
137
|
isValid: false,
|
|
@@ -153,18 +152,50 @@ var VirtualList = /** @class */ (function (_super) {
|
|
|
153
152
|
this.setState({
|
|
154
153
|
start: 0,
|
|
155
154
|
end: Math.min(this.state.start + this.visibleCount, nextProps.itemCount),
|
|
156
|
-
listHeight: nextProps.itemCount * nextProps.itemSize
|
|
155
|
+
listHeight: nextProps.itemCount * nextProps.itemSize,
|
|
157
156
|
});
|
|
158
157
|
this.ref.scrollTop = 0;
|
|
159
158
|
this.forceUpdate();
|
|
160
159
|
}
|
|
161
160
|
if (nextProps.itemCount !== this.props.itemCount) {
|
|
162
161
|
this.setState({
|
|
163
|
-
listHeight: nextProps.itemCount * nextProps.itemSize
|
|
162
|
+
listHeight: nextProps.itemCount * nextProps.itemSize,
|
|
164
163
|
});
|
|
165
164
|
this.forceUpdate();
|
|
166
165
|
}
|
|
167
166
|
};
|
|
167
|
+
VirtualList.prototype.HandleScrollProps = function () {
|
|
168
|
+
var scrollProps = {
|
|
169
|
+
movementType: 'elastic',
|
|
170
|
+
scrollSensitivity: 1,
|
|
171
|
+
inertiaVersion: 2,
|
|
172
|
+
decelerationRate: 0.135,
|
|
173
|
+
staticVelocityDrag: 100,
|
|
174
|
+
frictionCoefficient: 2.0,
|
|
175
|
+
};
|
|
176
|
+
if (this.props.scrollProps) {
|
|
177
|
+
/* 兼容双问号 */
|
|
178
|
+
if (this.props.scrollProps.movementType !== null && this.props.scrollProps.movementType !== undefined) {
|
|
179
|
+
scrollProps.movementType = this.props.scrollProps.movementType;
|
|
180
|
+
}
|
|
181
|
+
if (this.props.scrollProps.scrollSensitivity !== null && this.props.scrollProps.scrollSensitivity !== undefined) {
|
|
182
|
+
scrollProps.scrollSensitivity = this.props.scrollProps.scrollSensitivity;
|
|
183
|
+
}
|
|
184
|
+
if (this.props.scrollProps.inertiaVersion !== null && this.props.scrollProps.inertiaVersion !== undefined) {
|
|
185
|
+
scrollProps.inertiaVersion = this.props.scrollProps.inertiaVersion;
|
|
186
|
+
}
|
|
187
|
+
if (this.props.scrollProps.decelerationRate !== null && this.props.scrollProps.decelerationRate !== undefined) {
|
|
188
|
+
scrollProps.decelerationRate = this.props.scrollProps.decelerationRate;
|
|
189
|
+
}
|
|
190
|
+
if (this.props.scrollProps.staticVelocityDrag !== null && this.props.scrollProps.staticVelocityDrag !== undefined) {
|
|
191
|
+
scrollProps.staticVelocityDrag = this.props.scrollProps.staticVelocityDrag;
|
|
192
|
+
}
|
|
193
|
+
if (this.props.scrollProps.frictionCoefficient !== null && this.props.scrollProps.frictionCoefficient !== undefined) {
|
|
194
|
+
scrollProps.frictionCoefficient = this.props.scrollProps.frictionCoefficient;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return scrollProps;
|
|
198
|
+
};
|
|
168
199
|
VirtualList.prototype.render = function () {
|
|
169
200
|
var _this = this;
|
|
170
201
|
var start = Math.max(0, this.state.start - this.props.cacheSize);
|
|
@@ -217,33 +248,8 @@ var VirtualList = /** @class */ (function (_super) {
|
|
|
217
248
|
height: "".concat(this.state.listHeight, "px"),
|
|
218
249
|
};
|
|
219
250
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (this.props.scrollProps && this.props.scrollProps.movementType !== null && this.props.scrollProps.movementType !== undefined) {
|
|
223
|
-
movementType = this.props.scrollProps.movementType;
|
|
224
|
-
}
|
|
225
|
-
var scrollSensitivity = 1;
|
|
226
|
-
if (this.props.scrollProps && this.props.scrollProps.scrollSensitivity !== null && this.props.scrollProps.scrollSensitivity !== undefined) {
|
|
227
|
-
scrollSensitivity = this.props.scrollProps.scrollSensitivity;
|
|
228
|
-
}
|
|
229
|
-
var inertiaVersion = 2;
|
|
230
|
-
if (this.props.scrollProps && this.props.scrollProps.inertiaVersion !== null && this.props.scrollProps.inertiaVersion !== undefined) {
|
|
231
|
-
inertiaVersion = this.props.scrollProps.inertiaVersion;
|
|
232
|
-
}
|
|
233
|
-
var decelerationRate = 0.135;
|
|
234
|
-
if (this.props.scrollProps && this.props.scrollProps.decelerationRate !== null && this.props.scrollProps.decelerationRate !== undefined) {
|
|
235
|
-
decelerationRate = this.props.scrollProps.decelerationRate;
|
|
236
|
-
}
|
|
237
|
-
var staticVelocityDrag = 100;
|
|
238
|
-
if (this.props.scrollProps && this.props.scrollProps.staticVelocityDrag !== null && this.props.scrollProps.staticVelocityDrag !== undefined) {
|
|
239
|
-
staticVelocityDrag = this.props.scrollProps.staticVelocityDrag;
|
|
240
|
-
}
|
|
241
|
-
var frictionCoefficient = 2.0;
|
|
242
|
-
if (this.props.scrollProps && this.props.scrollProps.frictionCoefficient !== null && this.props.scrollProps.frictionCoefficient !== undefined) {
|
|
243
|
-
frictionCoefficient = this.props.scrollProps.frictionCoefficient;
|
|
244
|
-
}
|
|
245
|
-
return (h("div", { key: "VirtualListRoot", id: 'VirtualListRoot', "movement-type": movementType, "scroll-sensitivity": scrollSensitivity, "inertia-version": inertiaVersion, "deceleration-rate": decelerationRate, "static-velocity-drag": staticVelocityDrag, "friction-coefficient": frictionCoefficient, ref: this.ref, onScroll: this.onScroll, style: __assign({ position: 'relative', overflow: 'scroll', flexDirection: this.props.layout === 'horizontal' ? 'row' : 'column', width: this.props.width, height: this.props.height }, this.props.style) },
|
|
246
|
-
this.props.TopArea,
|
|
251
|
+
var scrollProps = this.HandleScrollProps();
|
|
252
|
+
return (h("div", { key: "VirtualListRoot", id: 'VirtualListRoot', className: 'VirtualListRoot', "movement-type": scrollProps.movementType, "scroll-sensitivity": scrollProps.scrollSensitivity, "inertia-version": scrollProps.inertiaVersion, "deceleration-rate": scrollProps.decelerationRate, "static-velocity-drag": scrollProps.staticVelocityDrag, "friction-coefficient": scrollProps.frictionCoefficient, ref: this.ref, onScroll: this.onScroll, style: __assign({ position: 'relative', overflow: 'scroll', flexDirection: this.props.layout === 'horizontal' ? 'row' : 'column', width: this.props.width, height: this.props.height }, this.props.style) },
|
|
247
253
|
h("div", { key: "VirtualList", id: 'VirtualList', style: VirtualListStyle }, this.itemCache.map(function (item) { return item.vNode; }))));
|
|
248
254
|
};
|
|
249
255
|
return VirtualList;
|
|
@@ -34,12 +34,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
import path from 'path';
|
|
38
37
|
import { sha1 } from './Sha1';
|
|
39
38
|
import { LibMgr } from '../../../lib/loadlib/lib_mgr';
|
|
40
39
|
var assetPrefix = 'cacheAsset';
|
|
41
|
-
var OPLib = LibMgr.getInstance().getMainLib();
|
|
42
|
-
console.log('new lib test');
|
|
43
40
|
/**
|
|
44
41
|
* 缓存资源到本地,仅jssdk环境可用
|
|
45
42
|
*/
|
|
@@ -55,8 +52,10 @@ export var assetCache;
|
|
|
55
52
|
assetCache.cache = function (url, force, retryTimes) {
|
|
56
53
|
if (retryTimes === void 0) { retryTimes = 3; }
|
|
57
54
|
return __awaiter(_this, void 0, void 0, function () {
|
|
55
|
+
var OPLib;
|
|
58
56
|
var _this = this;
|
|
59
57
|
return __generator(this, function (_a) {
|
|
58
|
+
OPLib = LibMgr.getInstance().getMainLib();
|
|
60
59
|
console.log('cacheAsset---', url);
|
|
61
60
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
62
61
|
var urlWithoutParams, localPath, xhr;
|
|
@@ -140,6 +139,7 @@ export var assetCache;
|
|
|
140
139
|
});
|
|
141
140
|
};
|
|
142
141
|
assetCache.getFileCachePath = function (url) {
|
|
142
|
+
var OPLib = LibMgr.getInstance().getMainLib();
|
|
143
143
|
console.log('getCachePath', url);
|
|
144
144
|
if (!OPLib.isLoadSuccess()) {
|
|
145
145
|
console.log('非jssdk环境');
|
|
@@ -204,18 +204,21 @@ export var assetCache;
|
|
|
204
204
|
});
|
|
205
205
|
};
|
|
206
206
|
var getLocalPath = function (url) {
|
|
207
|
+
var OPLib = LibMgr.getInstance().getMainLib();
|
|
207
208
|
console.log('getLocalPath', url);
|
|
208
209
|
var cachePath = OPLib.getCachePath();
|
|
209
210
|
if (!cachePath) {
|
|
210
211
|
console.warn('getLocalPath failed', url);
|
|
211
212
|
return '';
|
|
212
213
|
}
|
|
213
|
-
var filePath =
|
|
214
|
+
var filePath = "".concat(cachePath, "/assetcache");
|
|
214
215
|
//检查assetcache文件夹
|
|
215
216
|
if (!OPLib.dirExists(filePath)) {
|
|
216
217
|
OPLib.makeDir(filePath);
|
|
217
218
|
}
|
|
218
|
-
var
|
|
219
|
-
|
|
219
|
+
var cleanUrl = url.split('?')[0].split('#')[0];
|
|
220
|
+
var ext = cleanUrl.includes('.') ? cleanUrl.slice(cleanUrl.lastIndexOf('.')) : '';
|
|
221
|
+
var fileName = sha1(assetPrefix + url).substring(0, 20) + ext;
|
|
222
|
+
return "".concat(filePath, "/").concat(fileName);
|
|
220
223
|
};
|
|
221
224
|
})(assetCache || (assetCache = {}));
|