dtable-ui-component 0.2.3 → 0.2.4
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.
|
@@ -11,22 +11,20 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
11
11
|
|
|
12
12
|
var _super = _createSuper(ImagesLazyLoad);
|
|
13
13
|
|
|
14
|
-
function ImagesLazyLoad(
|
|
14
|
+
function ImagesLazyLoad(_props) {
|
|
15
15
|
var _this;
|
|
16
16
|
|
|
17
17
|
_classCallCheck(this, ImagesLazyLoad);
|
|
18
18
|
|
|
19
|
-
_this = _super.call(this,
|
|
19
|
+
_this = _super.call(this, _props);
|
|
20
20
|
|
|
21
21
|
_this.componentDidMount = function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_this.lazyLoadImages(images);
|
|
22
|
+
_this.lazyLoadImages(_this.props);
|
|
25
23
|
};
|
|
26
24
|
|
|
27
25
|
_this.componentWillReceiveProps = function (nextProps) {
|
|
28
26
|
if (nextProps.images.toString() !== _this.props.images.toString()) {
|
|
29
|
-
_this.lazyLoadImages(nextProps
|
|
27
|
+
_this.lazyLoadImages(nextProps);
|
|
30
28
|
}
|
|
31
29
|
};
|
|
32
30
|
|
|
@@ -37,29 +35,36 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
37
35
|
};
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
_this.lazyLoadImages = function (
|
|
38
|
+
_this.lazyLoadImages = function (props) {
|
|
39
|
+
var images = props.images;
|
|
40
|
+
|
|
41
41
|
if (!Array.isArray(images) || images.length === 0) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
_this.setState({
|
|
46
|
+
images: images,
|
|
47
|
+
loadedCount: 0
|
|
48
|
+
}, function () {
|
|
49
|
+
var server = _this.props.server;
|
|
50
|
+
images.forEach(function (item) {
|
|
51
|
+
var url = getImageThumbnailUrl(item, server);
|
|
52
|
+
|
|
53
|
+
_this.lazyLoadImage(url, function (image) {
|
|
54
|
+
var _this$state = _this.state,
|
|
55
|
+
loadedCount = _this$state.loadedCount,
|
|
56
|
+
loadedImages = _this$state.loadedImages;
|
|
57
|
+
|
|
58
|
+
_this.setState({
|
|
59
|
+
loadedCount: loadedCount + 1,
|
|
60
|
+
loadedImages: loadedImages.concat(image)
|
|
61
|
+
});
|
|
62
|
+
}, function () {
|
|
63
|
+
var loadedCount = _this.state.loadedCount;
|
|
64
|
+
|
|
65
|
+
_this.setState({
|
|
66
|
+
loadedCount: loadedCount + 1
|
|
67
|
+
});
|
|
63
68
|
});
|
|
64
69
|
});
|
|
65
70
|
});
|
|
@@ -95,7 +100,7 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
95
100
|
};
|
|
96
101
|
|
|
97
102
|
_this.state = {
|
|
98
|
-
images:
|
|
103
|
+
images: _props.images,
|
|
99
104
|
loadedImages: [],
|
|
100
105
|
loadedCount: 0
|
|
101
106
|
};
|