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(props) {
14
+ function ImagesLazyLoad(_props) {
15
15
  var _this;
16
16
 
17
17
  _classCallCheck(this, ImagesLazyLoad);
18
18
 
19
- _this = _super.call(this, props);
19
+ _this = _super.call(this, _props);
20
20
 
21
21
  _this.componentDidMount = function () {
22
- var images = _this.state.images;
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.images);
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 (images) {
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
- var server = _this.props.server;
46
- images.forEach(function (item) {
47
- var url = getImageThumbnailUrl(item, server);
48
-
49
- _this.lazyLoadImage(url, function (image) {
50
- var _this$state = _this.state,
51
- loadedCount = _this$state.loadedCount,
52
- loadedImages = _this$state.loadedImages;
53
-
54
- _this.setState({
55
- loadedCount: loadedCount + 1,
56
- loadedImages: loadedImages.concat(image)
57
- });
58
- }, function () {
59
- var loadedCount = _this.state.loadedCount;
60
-
61
- _this.setState({
62
- loadedCount: loadedCount + 1
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: props.images,
103
+ images: _props.images,
99
104
  loadedImages: [],
100
105
  loadedCount: 0
101
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "0.0.9",