js-cloudimage-360-view 2.7.8 → 2.7.11

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/CHANGELOG.md CHANGED
@@ -25,6 +25,20 @@ Types of changes:
25
25
  - ...
26
26
 
27
27
  -------------
28
+ ## 2.7.11 - 2022-03-17
29
+ ### Fixed
30
+ - canvas aspect ratio
31
+ - initialization of lazyloading
32
+
33
+ ## 2.7.10 - 2022-03-01
34
+ ### Fixed
35
+ - image quality in fullscreen
36
+ - resized image loading
37
+
38
+ ## 2.7.9 - 2022-02-27
39
+ ### Fixed
40
+ - typo in documentation
41
+
28
42
  ## 2.7.8 - 2022-02-27
29
43
  ### Added
30
44
  - possibility to add new view to CI360 views
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Release](https://img.shields.io/badge/release-v2.7.8-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
1
+ [![Release](https://img.shields.io/badge/release-v2.7.11-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
2
2
  [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)](#contributing)
3
3
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
4
  [![Scaleflex team](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg)](https://www.scaleflex.it/en/home)
@@ -106,14 +106,14 @@ window.CI360.init();
106
106
  > <script>window.CI360.init(); // initialize the plugin when you need</script>
107
107
  > ```
108
108
 
109
- ### addView
109
+ ### add
110
110
 
111
111
  ###### Type: **Function**
112
112
 
113
113
  add new view by id to cloudimage 360 views.
114
114
 
115
115
  ```javascript
116
- window.CI360.addView(idOfView: string);
116
+ window.CI360.add(idOfView: string);
117
117
  ```
118
118
 
119
119
  ### update
@@ -241,7 +241,6 @@ data-api-version="v7"
241
241
  ```javascript
242
242
  data-api-version="null"
243
243
  ```
244
- ### data-filename (or filename)
245
244
  ### data-filename-x (or filename-x)
246
245
  ### ~~data-filename (or filename)~~ [deprecated]
247
246
 
@@ -71,6 +71,18 @@ var CI360Viewer = /*#__PURE__*/function () {
71
71
  }
72
72
 
73
73
  (0, _createClass2.default)(CI360Viewer, [{
74
+ key: "isReady",
75
+ value: function isReady() {
76
+ var loadedXImages = this.imagesX.filter(function (image) {
77
+ return image;
78
+ });
79
+ var loadedYImages = this.imagesY.filter(function (image) {
80
+ return image;
81
+ });
82
+ var totalAmount = this.amountX + this.amountY;
83
+ return loadedXImages.length + loadedYImages.length === totalAmount;
84
+ }
85
+ }, {
74
86
  key: "mouseDown",
75
87
  value: function mouseDown(event) {
76
88
  if (!this.imagesLoaded) return;
@@ -248,10 +260,10 @@ var CI360Viewer = /*#__PURE__*/function () {
248
260
  }
249
261
 
250
262
  var loadedOriginalXImages = this.originalImagesX.filter(function (image) {
251
- return !!image;
263
+ return image;
252
264
  });
253
265
  var loadedOriginalYImages = this.originalImagesY.filter(function (image) {
254
- return !!image;
266
+ return image;
255
267
  });
256
268
  var totalAmount = this.amountX + this.amountY;
257
269
  var totalLoadedImages = loadedOriginalXImages.length + loadedOriginalYImages.length;
@@ -277,7 +289,7 @@ var CI360Viewer = /*#__PURE__*/function () {
277
289
 
278
290
  if (this.allowSpinY) {
279
291
  var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
280
- (0, _utils.preloadOriginalImages)(this.srcXConfig, srcY, this.onOriginalImageLoad.bind(this, _constants.ORIENTATIONS.Y, event));
292
+ (0, _utils.preloadOriginalImages)(this.srcYConfig, srcY, this.onOriginalImageLoad.bind(this, _constants.ORIENTATIONS.Y, event));
281
293
  }
282
294
  }
283
295
  }, {
@@ -665,6 +677,10 @@ var CI360Viewer = /*#__PURE__*/function () {
665
677
  this.container.height = window.innerHeight * this.devicePixelRatio;
666
678
  this.container.style.height = window.innerHeight + 'px';
667
679
  this.container.style.maxWidth = 'unset';
680
+ this.canvas.width = window.innerWidth * this.devicePixelRatio;
681
+ this.canvas.style.width = window.innerWidth + 'px';
682
+ this.canvas.height = window.innerHeight * this.devicePixelRatio;
683
+ this.canvas.style.height = window.innerHeight + 'px';
668
684
  return;
669
685
  }
670
686
 
@@ -683,10 +699,10 @@ var CI360Viewer = /*#__PURE__*/function () {
683
699
  }
684
700
 
685
701
  var loadedResizedXImages = this.resizedImagesX.filter(function (image) {
686
- return !!image;
702
+ return image;
687
703
  });
688
704
  var loadedResizedYImages = this.resizedImagesY.filter(function (image) {
689
- return !!image;
705
+ return image;
690
706
  });
691
707
  var isAllImagesLoaded = loadedResizedXImages.length + loadedResizedYImages.length === this.amountX + this.amountY;
692
708
 
@@ -711,17 +727,18 @@ var CI360Viewer = /*#__PURE__*/function () {
711
727
  }, {
712
728
  key: "requestResizedImages",
713
729
  value: function requestResizedImages() {
730
+ if (!this.isReady()) return;
714
731
  var responsive = this.ciParams.ciToken;
715
732
  var firstImage = this.imagesX[0];
716
733
  this.update();
734
+ if (!responsive || this.container.offsetWidth < firstImage.width * 1.5) return;
717
735
  this.speedFactor = (0, _utils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
718
736
  var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
719
- if (!responsive || this.container.offsetWidth < firstImage.width * 1.5) return;
720
- (0, _utils.preloadImages)(this.srcXConfig, srcX, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.X), true);
737
+ (0, _utils.preloadImages)(this.srcXConfig, srcX, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.X));
721
738
 
722
739
  if (this.allowSpinY) {
723
740
  var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
724
- (0, _utils.preloadImages)(this.srcYConfig, srcY, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.Y), true);
741
+ (0, _utils.preloadImages)(this.srcYConfig, srcY, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.Y));
725
742
  }
726
743
  }
727
744
  }, {
@@ -795,13 +812,10 @@ var CI360Viewer = /*#__PURE__*/function () {
795
812
  value: function onFirstImageLoaded(image) {
796
813
  if (!this.hide360Logo && !this.lazyload) this.add360ViewIcon();
797
814
  var ctx = this.canvas.getContext("2d");
815
+ ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
816
+ this.updateContainerAndCanvasSize(image);
798
817
 
799
818
  if (this.fullscreenView) {
800
- this.canvas.width = window.innerWidth * this.devicePixelRatio;
801
- this.canvas.style.width = window.innerWidth + 'px';
802
- this.canvas.height = window.innerHeight * this.devicePixelRatio;
803
- this.canvas.style.height = window.innerHeight + 'px';
804
-
805
819
  var _contain2 = (0, _utils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
806
820
  offsetX = _contain2.offsetX,
807
821
  offsetY = _contain2.offsetY,
@@ -815,10 +829,6 @@ var CI360Viewer = /*#__PURE__*/function () {
815
829
  this.addCloseFullscreenView();
816
830
  ctx.drawImage(image, offsetX, offsetY, width, height);
817
831
  } else {
818
- this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
819
- this.canvas.style.width = this.container.offsetWidth + 'px';
820
- this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
821
- this.canvas.style.height = this.container.offsetHeight + 'px';
822
832
  ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
823
833
  }
824
834
 
@@ -956,19 +966,33 @@ var CI360Viewer = /*#__PURE__*/function () {
956
966
  window.clearTimeout(this.loopTimeoutId);
957
967
  }
958
968
  }, {
959
- key: "updatePlugin",
960
- value: function updatePlugin(forceUpdate) {
969
+ key: "updateView",
970
+ value: function updateView(forceUpdate, viewers) {
971
+ var _this5 = this;
972
+
961
973
  var container = this.container;
962
974
  var imageProps = (0, _ci.get360ViewProps)(container);
963
- var srcPropsChanged = (0, _utils.isSrcPropsChanged)(this, imageProps);
964
- var reloadPlugin = srcPropsChanged || forceUpdate;
975
+ var srcPropsChanged = (0, _utils.isPropsChangeRequireReload)(this, imageProps);
976
+ var reInitView = srcPropsChanged || forceUpdate;
977
+
978
+ if (reInitView) {
979
+ var oldElement = this.container;
980
+ var viewIndex = viewers.findIndex(function (view) {
981
+ return view.id === _this5.container.id;
982
+ });
983
+ container.removeChild(this.innerBox);
984
+ container = container.cloneNode(true);
985
+ container.className = container.className.replace(' initialized', '');
986
+ oldElement.parentNode.replaceChild(container, oldElement);
987
+ return viewers.splice(viewIndex, 1, new CI360Viewer(container));
988
+ }
989
+
965
990
  container.style.position = 'relative';
966
991
  container.style.width = '100%';
967
992
  container.style.cursor = 'default';
968
993
  container.setAttribute('draggable', 'false');
969
- if (reloadPlugin) container.innerHTML = '';
970
994
  this.stop();
971
- this.init(container, !reloadPlugin, reloadPlugin);
995
+ this.init(container, true);
972
996
  }
973
997
  }, {
974
998
  key: "destroy",
@@ -1091,52 +1115,52 @@ var CI360Viewer = /*#__PURE__*/function () {
1091
1115
  }, {
1092
1116
  key: "initControls",
1093
1117
  value: function initControls() {
1094
- var _this5 = this;
1118
+ var _this6 = this;
1095
1119
 
1096
1120
  var onLeftStart = function onLeftStart(event) {
1097
1121
  event.stopPropagation();
1098
1122
 
1099
- _this5.onSpin();
1123
+ _this6.onSpin();
1100
1124
 
1101
- _this5.left();
1125
+ _this6.left();
1102
1126
 
1103
- _this5.loopTimeoutId = window.setInterval(_this5.left.bind(_this5), _this5.autoplaySpeed);
1127
+ _this6.loopTimeoutId = window.setInterval(_this6.left.bind(_this6), _this6.autoplaySpeed);
1104
1128
  };
1105
1129
 
1106
1130
  var onRightStart = function onRightStart(event) {
1107
1131
  event.stopPropagation();
1108
1132
 
1109
- _this5.onSpin();
1133
+ _this6.onSpin();
1110
1134
 
1111
- _this5.right();
1135
+ _this6.right();
1112
1136
 
1113
- _this5.loopTimeoutId = window.setInterval(_this5.right.bind(_this5), _this5.autoplaySpeed);
1137
+ _this6.loopTimeoutId = window.setInterval(_this6.right.bind(_this6), _this6.autoplaySpeed);
1114
1138
  };
1115
1139
 
1116
1140
  var onTopStart = function onTopStart(event) {
1117
1141
  event.stopPropagation();
1118
1142
 
1119
- _this5.onSpin();
1143
+ _this6.onSpin();
1120
1144
 
1121
- _this5.top();
1145
+ _this6.top();
1122
1146
 
1123
- _this5.loopTimeoutId = window.setInterval(_this5.top.bind(_this5), _this5.autoplaySpeed);
1147
+ _this6.loopTimeoutId = window.setInterval(_this6.top.bind(_this6), _this6.autoplaySpeed);
1124
1148
  };
1125
1149
 
1126
1150
  var onBottomStart = function onBottomStart(event) {
1127
1151
  event.stopPropagation();
1128
1152
 
1129
- _this5.onSpin();
1153
+ _this6.onSpin();
1130
1154
 
1131
- _this5.bottom();
1155
+ _this6.bottom();
1132
1156
 
1133
- _this5.loopTimeoutId = window.setInterval(_this5.bottom.bind(_this5), _this5.autoplaySpeed);
1157
+ _this6.loopTimeoutId = window.setInterval(_this6.bottom.bind(_this6), _this6.autoplaySpeed);
1134
1158
  };
1135
1159
 
1136
1160
  var onEventEnd = function onEventEnd() {
1137
- _this5.onFinishSpin();
1161
+ _this6.onFinishSpin();
1138
1162
 
1139
- window.clearTimeout(_this5.loopTimeoutId);
1163
+ window.clearTimeout(_this6.loopTimeoutId);
1140
1164
  };
1141
1165
 
1142
1166
  var controlsConfig = {
@@ -1153,10 +1177,10 @@ var CI360Viewer = /*#__PURE__*/function () {
1153
1177
  onEventEnd: onEventEnd
1154
1178
  };
1155
1179
  var controlsElements = (0, _utils.initControls)(controlsConfig, controlsTriggers);
1156
- this.topElem = controlsElements.top || {};
1157
- this.bottomElem = controlsElements.bottom || {};
1158
- this.leftElem = controlsElements.left || {};
1159
- this.rightElem = controlsElements.right || {};
1180
+ this.topElem = controlsElements.top;
1181
+ this.bottomElem = controlsElements.bottom;
1182
+ this.leftElem = controlsElements.left;
1183
+ this.rightElem = controlsElements.right;
1160
1184
  }
1161
1185
  }, {
1162
1186
  key: "attachEvents",
@@ -1189,10 +1213,9 @@ var CI360Viewer = /*#__PURE__*/function () {
1189
1213
  }, {
1190
1214
  key: "init",
1191
1215
  value: function init(container) {
1192
- var _this6 = this;
1216
+ var _this7 = this;
1193
1217
 
1194
1218
  var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1195
- var reload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1196
1219
 
1197
1220
  var _get360ViewProps = (0, _ci.get360ViewProps)(container),
1198
1221
  folder = _get360ViewProps.folder,
@@ -1267,8 +1290,6 @@ var CI360Viewer = /*#__PURE__*/function () {
1267
1290
  this.disableDrag = disableDrag;
1268
1291
  this.fullscreen = fullscreen;
1269
1292
  this.magnifier = !this.isMobile && magnifier > 1 ? Math.min(magnifier, 5) : 0;
1270
- this.lazyloadX = lazyload;
1271
- this.lazyloadY = lazyload;
1272
1293
  this.lazySelector = lazySelector;
1273
1294
  this.spinReverse = spinReverse;
1274
1295
  this.controlReverse = controlReverse;
@@ -1282,13 +1303,9 @@ var CI360Viewer = /*#__PURE__*/function () {
1282
1303
  this.pointerZoom = pointerZoom > 1 ? Math.min(pointerZoom, 3) : 0;
1283
1304
  this.keysReverse = keysReverse;
1284
1305
  this.info = imageInfo;
1306
+ this.keys = keys;
1285
1307
  this.ratio = ratio && JSON.parse(ratio);
1286
1308
 
1287
- if (reload) {
1288
- new CI360Viewer(this.container);
1289
- return;
1290
- }
1291
-
1292
1309
  if (update) {
1293
1310
  (0, _utils.removeChildFromParent)(this.innerBox, this.iconsContainer);
1294
1311
  (0, _utils.removeChildFromParent)(this.innerBox, this.boxShadowEl);
@@ -1305,10 +1322,6 @@ var CI360Viewer = /*#__PURE__*/function () {
1305
1322
  this.addMagnifier();
1306
1323
  }
1307
1324
 
1308
- if (this.info) {
1309
- this.showImageInfo(ctx);
1310
- }
1311
-
1312
1325
  if (this.bottomCircle && !this.fullscreenView) {
1313
1326
  this.add360ViewCircleIcon();
1314
1327
  }
@@ -1321,8 +1334,7 @@ var CI360Viewer = /*#__PURE__*/function () {
1321
1334
  this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
1322
1335
  }
1323
1336
 
1324
- this.onAllImagesLoaded();
1325
- return;
1337
+ return this.onAllImagesLoaded();
1326
1338
  }
1327
1339
 
1328
1340
  this.innerBox = (0, _utils.createInnerBox)(this.container);
@@ -1343,7 +1355,6 @@ var CI360Viewer = /*#__PURE__*/function () {
1343
1355
  innerBox: this.innerBox,
1344
1356
  apiVersion: apiVersion,
1345
1357
  ciParams: ciParams,
1346
- lazyload: lazyload,
1347
1358
  lazySelector: lazySelector,
1348
1359
  amount: this.amountX,
1349
1360
  indexZeroBase: indexZeroBase,
@@ -1356,71 +1367,57 @@ var CI360Viewer = /*#__PURE__*/function () {
1356
1367
  amount: this.amountY
1357
1368
  });
1358
1369
  var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
1359
- var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
1360
-
1361
- var initLazyload = function initLazyload(image, orientation) {
1362
- var lazyloadXConfig = _objectSpread(_objectSpread({}, _this6.srcXConfig), {}, {
1363
- lazyload: false
1364
- });
1365
-
1366
- var lazyloadYConfig = _objectSpread(_objectSpread({}, _this6.srcYConfig), {}, {
1367
- lazyload: false
1368
- });
1369
-
1370
- if (orientation === _constants.ORIENTATIONS.Y) {
1371
- _this6.lazyloadY = false;
1372
- (0, _utils.preloadImages)(lazyloadXConfig, srcX, onImageLoad.bind(_this6, _constants.ORIENTATIONS.X));
1373
- } else {
1374
- _this6.lazyloadX = false;
1375
- _this6.lazyloadInitImageX = image;
1376
- (0, _utils.preloadImages)(lazyloadYConfig, srcY, onImageLoad.bind(_this6, _constants.ORIENTATIONS.Y));
1377
- }
1378
- };
1379
1370
 
1380
1371
  var onImageLoad = function onImageLoad(orientation, image, index) {
1381
1372
  if (orientation !== _constants.ORIENTATIONS.Y) {
1382
- _this6.imagesX[index] = image;
1373
+ _this7.imagesX[index] = image;
1383
1374
  } else {
1384
- _this6.imagesY[index] = image;
1375
+ _this7.imagesY[index] = image;
1385
1376
  }
1386
1377
 
1387
- var loadedXImages = _this6.imagesX.filter(function (image) {
1388
- return !!image;
1378
+ var loadedXImages = _this7.imagesX.filter(function (image) {
1379
+ return image;
1389
1380
  });
1390
1381
 
1391
- var loadedYImages = _this6.imagesY.filter(function (image) {
1392
- return !!image;
1382
+ var loadedYImages = _this7.imagesY.filter(function (image) {
1383
+ return image;
1393
1384
  });
1394
1385
 
1395
- var totalAmount = _this6.amountX + _this6.amountY;
1396
- var totalLoadedImages = _this6.imagesX.length + _this6.imagesY.length;
1397
- var isFirstImageLoaded = index === 0 && orientation !== _constants.ORIENTATIONS.Y;
1398
- var isAllImagesLoaded = loadedXImages.length + loadedYImages.length === _this6.amountX + _this6.amountY;
1386
+ var totalAmount = _this7.amountX + _this7.amountY;
1387
+ var totalLoadedImages = loadedXImages.length + loadedYImages.length;
1388
+ var isFirstImageLoaded = !index && orientation !== _constants.ORIENTATIONS.Y;
1399
1389
  var percentage = Math.round(totalLoadedImages / totalAmount * 100);
1400
1390
 
1401
- _this6.updatePercentageInLoader(percentage);
1402
-
1403
- if (_this6.lazyloadX || _this6.lazyloadY) return initLazyload(image, orientation);
1391
+ _this7.updatePercentageInLoader(percentage);
1404
1392
 
1405
1393
  if (isFirstImageLoaded) {
1406
- _this6.updateContainerAndCanvasSize(image);
1394
+ _this7.onFirstImageLoaded(image);
1395
+ }
1407
1396
 
1408
- _this6.onFirstImageLoaded(image);
1397
+ if (_this7.isReady()) {
1398
+ _this7.onAllImagesLoaded();
1409
1399
  }
1400
+ };
1410
1401
 
1411
- if (isAllImagesLoaded) {
1412
- _this6.onAllImagesLoaded();
1402
+ var loadImages = function loadImages() {
1403
+ (0, _utils.preloadImages)(_this7.srcXConfig, srcX, onImageLoad.bind(_this7, _constants.ORIENTATIONS.X));
1413
1404
 
1414
- if (lazyload) {
1415
- _this6.innerBox.removeChild(_this6.lazyloadInitImageX);
1416
- }
1405
+ if (_this7.allowSpinY) {
1406
+ var srcY = (0, _utils.generateImagesPath)(_this7.srcYConfig);
1407
+ (0, _utils.preloadImages)(_this7.srcYConfig, srcY, onImageLoad.bind(_this7, _constants.ORIENTATIONS.Y));
1417
1408
  }
1418
1409
  };
1419
1410
 
1420
- (0, _utils.preloadImages)(this.srcXConfig, srcX, onImageLoad.bind(this, _constants.ORIENTATIONS.X));
1411
+ if (lazyload) {
1412
+ var onFirstImageLoad = function onFirstImageLoad(image) {
1413
+ _this7.innerBox.removeChild(image);
1421
1414
 
1422
- if (this.allowSpinY) {
1423
- (0, _utils.preloadImages)(this.srcYConfig, srcY, onImageLoad.bind(this, _constants.ORIENTATIONS.Y));
1415
+ loadImages();
1416
+ };
1417
+
1418
+ (0, _utils.initLazyload)(srcX, this.srcXConfig, onFirstImageLoad);
1419
+ } else {
1420
+ loadImages();
1424
1421
  }
1425
1422
 
1426
1423
  this.attachEvents(draggable, swipeable, keys);
@@ -46,7 +46,7 @@ var get360ViewProps = function get360ViewProps(image) {
46
46
  stopAtEdges: isTrue(image, 'stop-at-edges'),
47
47
  hide360Logo: isTrue(image, 'hide-360-logo'),
48
48
  logoSrc: attr(image, 'logo-src') || 'https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg',
49
- ratio: attr(image, 'ratio') || attr(image, 'data-ratio') || null,
49
+ ratio: attr(image, 'ratio') || attr(image, 'data-ratio'),
50
50
  imageInfo: attr(image, 'info') || attr(image, 'data-info') || isTrue(image, 'info')
51
51
  };
52
52
  };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PROPS_REQUIRE_RELOAD = void 0;
7
+ var PROPS_REQUIRE_RELOAD = ['folder', //images source
8
+ 'filenameX', //images source
9
+ 'filenameY', //images source
10
+ 'apiVersion', //images source
11
+ 'imageListX', //images source
12
+ 'imageListY', //images source
13
+ 'indexZeroBase', //images source
14
+ 'lazySelector', //images source
15
+ 'keys', // events
16
+ 'stopAtEdges', // events
17
+ 'disableDrag', // events
18
+ 'controlReverse', // events
19
+ 'disableDrag' // events
20
+ ];
21
+ exports.PROPS_REQUIRE_RELOAD = PROPS_REQUIRE_RELOAD;
package/dist/index.js CHANGED
@@ -12,14 +12,27 @@ var _ci = _interopRequireDefault(require("./ci360.service"));
12
12
 
13
13
  var _ci2 = require("./ci360.utils");
14
14
 
15
+ function setContainerId(container) {
16
+ var containerId = container.id;
17
+
18
+ if (!containerId) {
19
+ var uniqueId = Math.floor(Math.random() * 10000);
20
+ var generatedContainerId = "cloudimage-360-view-".concat(uniqueId);
21
+ container.id = generatedContainerId;
22
+ }
23
+
24
+ return container;
25
+ }
26
+
15
27
  function init() {
16
28
  var viewers = [];
17
29
  var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
18
30
  var hotspotsConfigs = window.CI360.hotspots || {};
19
31
  [].slice.call(view360Array).forEach(function (container) {
20
- var hotspotInstanceName = (0, _ci2.attr)(container, 'hotspot-instance') || (0, _ci2.attr)(container, 'data-hotspot-instance');
21
- var hotspotConfig = hotspotsConfigs[hotspotInstanceName] ? hotspotsConfigs[hotspotInstanceName] : null;
22
- viewers.push(new _ci.default(container, false, hotspotConfig));
32
+ var containerWithId = setContainerId(container);
33
+ var hotspotInstanceName = (0, _ci2.attr)(containerWithId, 'hotspot-instance') || (0, _ci2.attr)(containerWithId, 'data-hotspot-instance');
34
+ var hotspotConfig = hotspotsConfigs === null || hotspotsConfigs === void 0 ? void 0 : hotspotsConfigs[hotspotInstanceName];
35
+ viewers.push(new _ci.default(containerWithId, false, hotspotConfig));
23
36
  });
24
37
  window.CI360._viewers = viewers;
25
38
  }
@@ -48,25 +61,32 @@ function getActiveIndexByID(id, oriantation) {
48
61
  return currentViewer && currentViewer.activeImageX - 1;
49
62
  }
50
63
 
64
+ function add(id) {
65
+ var view360Array = Array.from(document.querySelectorAll('.cloudimage-360:not(.initialized)'));
66
+
67
+ if (view360Array.length && id) {
68
+ var newViewContainer = view360Array.filter(function (viewer) {
69
+ return viewer.id === id;
70
+ })[0];
71
+ newViewContainer && window.CI360._viewers.push(new _ci.default(newViewContainer));
72
+ }
73
+ }
74
+
51
75
  function update() {
52
76
  var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
53
77
  var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
54
78
 
55
79
  if (id) {
56
- try {
57
- var view = window.CI360._viewers.filter(function (viewer) {
58
- return viewer.id === id;
59
- })[0];
60
-
61
- return view.updatePlugin(forceUpdate);
62
- } catch (_unused) {
63
- console.error("Cloudimage-360: there is no view with such id '".concat(id, "'"));
64
- }
80
+ var view = window.CI360._viewers.filter(function (viewer) {
81
+ return viewer.id === id;
82
+ })[0];
83
+
84
+ view.updateView(forceUpdate, window.CI360._viewers);
85
+ } else {
86
+ window.CI360._viewers.forEach(function (viewer) {
87
+ viewer.updateView(forceUpdate, window.CI360._viewers);
88
+ });
65
89
  }
66
-
67
- return window.CI360._viewers.forEach(function (viewer) {
68
- viewer.updatePlugin(forceUpdate);
69
- });
70
90
  }
71
91
 
72
92
  function isNoViewers() {
@@ -78,6 +98,7 @@ window.CI360.init = init;
78
98
  window.CI360.destroy = destroy;
79
99
  window.CI360.getActiveIndexByID = getActiveIndexByID;
80
100
  window.CI360.update = update;
101
+ window.CI360.add = add;
81
102
 
82
103
  if (!window.CI360.notInitOnLoad) {
83
104
  init();
@@ -118,4 +118,111 @@
118
118
  height: 250px;
119
119
  top: -75px;
120
120
  right: -85px;
121
+ }
122
+
123
+ .cloudimage-360 .cloudimage-360-left,
124
+ .cloudimage-360 .cloudimage-360-right {
125
+ padding: 8px;
126
+ background: rgb(244, 244, 244);
127
+ border: none;
128
+ border-radius: 4px;
129
+ }
130
+
131
+ .cloudimage-360 .cloudimage-360-left:focus,
132
+ .cloudimage-360 .cloudimage-360-right:focus {
133
+ outline: none;
134
+ }
135
+
136
+ .cloudimage-360 .cloudimage-360-left {
137
+ display: none;
138
+ position: absolute;
139
+ z-index: 100;
140
+ top: calc(50% - 15px);
141
+ left: 20px;
142
+ }
143
+
144
+ .cloudimage-360 .cloudimage-360-right {
145
+ display: none;
146
+ position: absolute;
147
+ z-index: 100;
148
+ top: calc(50% - 15px);
149
+ right: 20px;
150
+ }
151
+
152
+ .cloudimage-360 .cloudimage-360-left:before,
153
+ .cloudimage-360 .cloudimage-360-right:before {
154
+ content: '';
155
+ display: block;
156
+ width: 30px;
157
+ height: 30px;
158
+ background: 50% 50% / cover no-repeat;
159
+ }
160
+
161
+ .cloudimage-360 .cloudimage-360-left:before {
162
+ background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-left.svg');
163
+ }
164
+
165
+ .cloudimage-360 .cloudimage-360-right:before {
166
+ background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-right.svg');
167
+ }
168
+
169
+ .cloudimage-360 .cloudimage-360-left.not-active,
170
+ .cloudimage-360 .cloudimage-360-right.not-active {
171
+ opacity: 0.4;
172
+ cursor: default;
173
+ pointer-events: none;
174
+ }
175
+
176
+ .cloudimage-360 .cloudimage-360-top,
177
+ .cloudimage-360 .cloudimage-360-bottom {
178
+ padding: 8px;
179
+ background: rgb(244, 244, 244);
180
+ border: none;
181
+ border-radius: 4px;
182
+ }
183
+
184
+ .cloudimage-360 .cloudimage-360-top:focus,
185
+ .cloudimage-360 .cloudimage-360-bottom:focus {
186
+ outline: none;
187
+ }
188
+
189
+ .cloudimage-360 .cloudimage-360-top {
190
+ display: none;
191
+ position: absolute;
192
+ z-index: 100;
193
+ left: calc(50% - 15px);
194
+ top: 20px;
195
+ transform: rotate(90deg);
196
+ }
197
+
198
+ .cloudimage-360 .cloudimage-360-bottom {
199
+ display: none;
200
+ position: absolute;
201
+ z-index: 100;
202
+ left: calc(50% - 15px);
203
+ bottom: 20px;
204
+ transform: rotate(90deg);
205
+ }
206
+
207
+ .cloudimage-360 .cloudimage-360-top:before,
208
+ .cloudimage-360 .cloudimage-360-bottom:before {
209
+ content: '';
210
+ display: block;
211
+ width: 30px;
212
+ height: 30px;
213
+ background: 50% 50% / cover no-repeat;
214
+ }
215
+
216
+ .cloudimage-360 .cloudimage-360-top:before {
217
+ background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-left.svg');
218
+ }
219
+
220
+ .cloudimage-360 .cloudimage-360-bottom:before {
221
+ background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-right.svg');
222
+ }
223
+
224
+ .cloudimage-360 .cloudimage-360-top.not-active,
225
+ .cloudimage-360 .cloudimage-360-bottom.not-active {
226
+ opacity: 0.4;
227
+ cursor: default;
121
228
  }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isPropsChangeRequireReload = void 0;
7
+
8
+ var _propsRequireReload = require("../../constants/props-require-reload");
9
+
10
+ var isPropsChangeRequireReload = function isPropsChangeRequireReload(currentProps, changedProps) {
11
+ return Object.keys(changedProps).reduce(function (acc, current) {
12
+ var isPropChanged = currentProps[current] !== changedProps[current];
13
+ var isSrcProp = _propsRequireReload.PROPS_REQUIRE_RELOAD.indexOf(current) !== -1;
14
+
15
+ if (isSrcProp && isPropChanged) {
16
+ acc = true;
17
+ }
18
+
19
+ return acc;
20
+ }, false);
21
+ };
22
+
23
+ exports.isPropsChangeRequireReload = isPropsChangeRequireReload;
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- isSrcPropsChanged: true,
7
+ isPropsChangeRequireReload: true,
8
8
  generateImagesPath: true,
9
9
  preloadImages: true,
10
10
  preloadOriginalImages: true,
11
+ initLazyload: true,
11
12
  contain: true,
12
13
  getImageAspectRatio: true,
13
14
  getCurrentOriginalImage: true,
@@ -112,6 +113,12 @@ Object.defineProperty(exports, "initControls", {
112
113
  return _initControls.initControls;
113
114
  }
114
115
  });
116
+ Object.defineProperty(exports, "initLazyload", {
117
+ enumerable: true,
118
+ get: function get() {
119
+ return _initLazyload.initLazyload;
120
+ }
121
+ });
115
122
  Object.defineProperty(exports, "isCompletedOneCycle", {
116
123
  enumerable: true,
117
124
  get: function get() {
@@ -124,10 +131,10 @@ Object.defineProperty(exports, "isMouseOnHotspot", {
124
131
  return _isMouseOnHotspot.isMouseOnHotspot;
125
132
  }
126
133
  });
127
- Object.defineProperty(exports, "isSrcPropsChanged", {
134
+ Object.defineProperty(exports, "isPropsChangeRequireReload", {
128
135
  enumerable: true,
129
136
  get: function get() {
130
- return _isSrcPropsChanged.isSrcPropsChanged;
137
+ return _isPropsChangeRequireReload.isPropsChangeRequireReload;
131
138
  }
132
139
  });
133
140
  Object.defineProperty(exports, "loop", {
@@ -167,7 +174,7 @@ Object.defineProperty(exports, "updateHotspots", {
167
174
  }
168
175
  });
169
176
 
170
- var _isSrcPropsChanged = require("./image-src/is-src-props-changed");
177
+ var _isPropsChangeRequireReload = require("./image-src/is-props-change-require-reload");
171
178
 
172
179
  var _generateImagesPath = require("./image-src/generate-images-path");
173
180
 
@@ -175,6 +182,8 @@ var _preloadImages = require("./load-images/preload-images");
175
182
 
176
183
  var _preloadOriginalImages = require("./load-images/preload-original-images");
177
184
 
185
+ var _initLazyload = require("./load-images/lazyload/init-lazyload");
186
+
178
187
  var _contain = require("./responsive/contain");
179
188
 
180
189
  var _getImageAspectRatio = require("./responsive/get-image-aspect-ratio");
@@ -13,24 +13,22 @@ var _regex = require("../../../constants/regex");
13
13
 
14
14
  var _pad = require("../pad");
15
15
 
16
- var prepareImagesFromFolder = function prepareImagesFromFolder(imagesSrc, srcConfig) {
16
+ var prepareImagesFromFolder = function prepareImagesFromFolder(imagesSrc, srcConfig, loadOriginalImages) {
17
17
  var _ref = srcConfig || {},
18
18
  amount = _ref.amount,
19
19
  indexZeroBase = _ref.indexZeroBase;
20
20
 
21
- var resultSrc = [];
22
- var originalSrc = [];
23
- (0, _toConsumableArray2.default)(new Array(amount)).forEach(function (_item, index) {
21
+ return (0, _toConsumableArray2.default)(new Array(amount)).map(function (_item, index) {
24
22
  var nextZeroFilledIndex = (0, _pad.pad)(index + 1, indexZeroBase);
25
- var imageResultSrc = imagesSrc.replace('{index}', nextZeroFilledIndex);
26
- var imageOriginalSrc = imageResultSrc.replace(_regex.ORGINAL_SIZE_REGEX, '').replace(_regex.AND_SYMBOL_REGEX, '?');
27
- resultSrc.push(imageResultSrc);
28
- originalSrc.push(imageOriginalSrc);
23
+ var imageSrc = imagesSrc.replace('{index}', nextZeroFilledIndex);
24
+
25
+ if (loadOriginalImages) {
26
+ var imageOriginalSrc = imageSrc.replace(_regex.ORGINAL_SIZE_REGEX, '').replace(_regex.AND_SYMBOL_REGEX, '?');
27
+ return imageOriginalSrc;
28
+ }
29
+
30
+ return imageSrc;
29
31
  });
30
- return {
31
- resultSrc: resultSrc,
32
- originalSrc: originalSrc
33
- };
34
32
  };
35
33
 
36
34
  exports.prepareImagesFromFolder = prepareImagesFromFolder;
@@ -15,23 +15,21 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
15
15
 
16
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
17
 
18
- var prepareImagesFromList = function prepareImagesFromList(images, srcConfig) {
18
+ var prepareImagesFromList = function prepareImagesFromList(images, srcConfig, loadOriginalImages) {
19
19
  var folder = srcConfig.folder;
20
- var resultSrc = [];
21
- var originalSrc = [];
22
- images.forEach(function (src) {
20
+ return images.map(function (src) {
23
21
  var nextSrcConfig = _objectSpread({}, srcConfig);
24
22
 
25
23
  nextSrcConfig.folder = /(http(s?)):\/\//gi.test(src) ? '' : folder;
26
24
  nextSrcConfig.filename = src;
27
- var lastIndex = resultSrc.lastIndexOf('//');
28
- resultSrc.push((0, _generateImagesPath.generateImagesPath)(nextSrcConfig));
29
- originalSrc.push(resultSrc.slice(lastIndex));
25
+
26
+ if (loadOriginalImages) {
27
+ var lastIndex = resultSrc.lastIndexOf('//');
28
+ return resultSrc.slice(lastIndex);
29
+ }
30
+
31
+ return (0, _generateImagesPath.generateImagesPath)(nextSrcConfig);
30
32
  });
31
- return {
32
- resultSrc: resultSrc,
33
- originalSrc: originalSrc
34
- };
35
33
  };
36
34
 
37
35
  exports.prepareImagesFromList = prepareImagesFromList;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initLazyload = void 0;
7
+
8
+ var _prepareFirstImageFromFolder = require("./prepare-first-image/prepare-first-image-from-folder");
9
+
10
+ var _prepareFirstImageFromList = require("./prepare-first-image/prepare-first-image-from-list");
11
+
12
+ var initLazyload = function initLazyload(imagesSrc, srcConfig, cb) {
13
+ var _ref = srcConfig || {},
14
+ imageList = _ref.imageList,
15
+ lazySelector = _ref.lazySelector,
16
+ innerBox = _ref.innerBox;
17
+
18
+ var firstImageSrc;
19
+
20
+ if (imageList) {
21
+ try {
22
+ var images = JSON.parse(imageList);
23
+ firstImageSrc = (0, _prepareFirstImageFromList.prepareFirstImageFromList)(images, srcConfig);
24
+ } catch (error) {
25
+ console.error("Wrong format in image-list attribute: ".concat(error.message));
26
+ }
27
+ } else {
28
+ firstImageSrc = (0, _prepareFirstImageFromFolder.prepareFirstImageFromFolder)(imagesSrc, srcConfig);
29
+ }
30
+
31
+ var image = new Image();
32
+ image.setAttribute('data-src', firstImageSrc);
33
+ image.style.position = 'absolute';
34
+ image.style.top = 0;
35
+ image.style.left = 0;
36
+ image.style.width = '100%';
37
+ image.style.maxWidth = '100%';
38
+ image.style.maxHeight = '100%';
39
+ if (lazySelector) image.className = lazySelector;
40
+ innerBox.appendChild(image);
41
+
42
+ if (cb) {
43
+ image.onload = function () {
44
+ return cb(image);
45
+ };
46
+ }
47
+ };
48
+
49
+ exports.initLazyload = initLazyload;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.prepareFirstImageFromFolder = void 0;
7
+
8
+ var _pad = require("../../pad");
9
+
10
+ var prepareFirstImageFromFolder = function prepareFirstImageFromFolder(imagesSrcs, srcConfig) {
11
+ var _ref = srcConfig || {},
12
+ indexZeroBase = _ref.indexZeroBase;
13
+
14
+ var nextZeroFilledIndex = (0, _pad.pad)(1, indexZeroBase);
15
+ return imagesSrcs.replace('{index}', nextZeroFilledIndex);
16
+ };
17
+
18
+ exports.prepareFirstImageFromFolder = prepareFirstImageFromFolder;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.prepareFirstImageFromList = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _generateImagesPath = require("../../../image-src/generate-images-path");
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+
18
+ var prepareFirstImageFromList = function prepareFirstImageFromList(images, srcConfig) {
19
+ var folder = srcConfig.folder;
20
+ var firstImageSrc = images[0];
21
+
22
+ var nextSrcConfig = _objectSpread({}, srcConfig);
23
+
24
+ nextSrcConfig.folder = /(http(s?)):\/\//gi.test(firstImageSrc) ? '' : folder;
25
+ nextSrcConfig.filename = firstImageSrc;
26
+ return (0, _generateImagesPath.generateImagesPath)(nextSrcConfig);
27
+ };
28
+
29
+ exports.prepareFirstImageFromList = prepareFirstImageFromList;
@@ -11,59 +11,34 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
11
11
 
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
13
 
14
- var _orientations = require("../../constants/orientations");
15
-
16
14
  var loadImageAsPromise = /*#__PURE__*/function () {
17
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(src, index, srcConfig) {
18
- var onImageLoadCallback,
19
- _ref2,
20
- lazyload,
21
- lazySelector,
22
- fullscreenView,
23
- innerBox,
24
- orientation,
25
- image,
26
- _args = arguments;
27
-
15
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(src, index, cb) {
16
+ var image;
28
17
  return _regenerator.default.wrap(function _callee$(_context) {
29
18
  while (1) {
30
19
  switch (_context.prev = _context.next) {
31
20
  case 0:
32
- onImageLoadCallback = _args.length > 3 && _args[3] !== undefined ? _args[3] : function () {};
33
- _ref2 = srcConfig || {}, lazyload = _ref2.lazyload, lazySelector = _ref2.lazySelector, fullscreenView = _ref2.fullscreenView, innerBox = _ref2.innerBox, orientation = _ref2.orientation;
34
21
  image = new Image();
35
-
36
- if (lazyload && !fullscreenView) {
37
- image.setAttribute('data-src', src);
38
- image.className = image.className.length ? "".concat(image.className, " ").concat(lazySelector) : lazySelector;
39
-
40
- if (index === 0 && orientation !== _orientations.ORIENTATIONS.Y) {
41
- image.style.position = 'absolute';
42
- image.style.top = '0';
43
- image.style.left = '0';
44
- innerBox.appendChild(image);
45
- }
46
-
47
- image.onload = function () {
48
- return onImageLoadCallback(image, index);
49
- };
50
- } else {
51
- image.src = src;
52
- }
53
-
22
+ image.src = src;
54
23
  return _context.abrupt("return", new Promise(function (reslove) {
55
24
  image.onload = function () {
56
- onImageLoadCallback(image, index);
57
25
  reslove(image);
26
+
27
+ if (cb) {
28
+ cb(image, index);
29
+ }
58
30
  };
59
31
 
60
32
  image.onerror = function () {
61
- onImageLoadCallback(image, index);
62
33
  reslove(image);
34
+
35
+ if (cb) {
36
+ cb(image, index);
37
+ }
63
38
  };
64
39
  }));
65
40
 
66
- case 5:
41
+ case 3:
67
42
  case "end":
68
43
  return _context.stop();
69
44
  }
@@ -14,7 +14,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
14
14
  var _loadImageAsPromise = require("./load-image-as-promise");
15
15
 
16
16
  var loadImagesRelativeToContainerSize = /*#__PURE__*/function () {
17
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(imagesSrcs, srcConfig, onImageLoadCallback) {
17
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(imagesSrcs, cb) {
18
18
  return _regenerator.default.wrap(function _callee2$(_context2) {
19
19
  while (1) {
20
20
  switch (_context2.prev = _context2.next) {
@@ -27,7 +27,7 @@ var loadImagesRelativeToContainerSize = /*#__PURE__*/function () {
27
27
  switch (_context.prev = _context.next) {
28
28
  case 0:
29
29
  _context.next = 2;
30
- return (0, _loadImageAsPromise.loadImageAsPromise)(src, index, srcConfig, onImageLoadCallback);
30
+ return (0, _loadImageAsPromise.loadImageAsPromise)(src, index, cb);
31
31
 
32
32
  case 2:
33
33
  case "end":
@@ -37,7 +37,7 @@ var loadImagesRelativeToContainerSize = /*#__PURE__*/function () {
37
37
  }, _callee);
38
38
  }));
39
39
 
40
- return function (_x4, _x5) {
40
+ return function (_x3, _x4) {
41
41
  return _ref2.apply(this, arguments);
42
42
  };
43
43
  }()));
@@ -50,7 +50,7 @@ var loadImagesRelativeToContainerSize = /*#__PURE__*/function () {
50
50
  }, _callee2);
51
51
  }));
52
52
 
53
- return function loadImagesRelativeToContainerSize(_x, _x2, _x3) {
53
+ return function loadImagesRelativeToContainerSize(_x, _x2) {
54
54
  return _ref.apply(this, arguments);
55
55
  };
56
56
  }();
@@ -14,7 +14,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
14
14
  var _loadImageAsPromise = require("./load-image-as-promise");
15
15
 
16
16
  var loadOriginalImages = /*#__PURE__*/function () {
17
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(imagesSrcs, onImageLoadCallback) {
17
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(imagesSrcs, cb) {
18
18
  return _regenerator.default.wrap(function _callee2$(_context2) {
19
19
  while (1) {
20
20
  switch (_context2.prev = _context2.next) {
@@ -27,7 +27,7 @@ var loadOriginalImages = /*#__PURE__*/function () {
27
27
  switch (_context.prev = _context.next) {
28
28
  case 0:
29
29
  _context.next = 2;
30
- return (0, _loadImageAsPromise.loadImageAsPromise)(src, index, null, onImageLoadCallback);
30
+ return (0, _loadImageAsPromise.loadImageAsPromise)(src, index, cb);
31
31
 
32
32
  case 2:
33
33
  case "end":
@@ -12,27 +12,24 @@ var _prepareImagesFromFolder = require("./images-from-folder/prepare-images-from
12
12
  var _prepareImagesFromList = require("./images-from-list/prepare-images-from-list");
13
13
 
14
14
  /* eslint-disable no-console */
15
- var preloadImages = function preloadImages(srcConfig, imagesSrc, onImageLoadCallback) {
15
+ var preloadImages = function preloadImages(srcConfig, imagesSrc, cb) {
16
16
  var _ref = srcConfig || {},
17
17
  imageList = _ref.imageList;
18
18
 
19
- var imagesSets = {};
19
+ var imagesSrcs = [];
20
20
 
21
21
  if (imageList) {
22
22
  try {
23
23
  var images = JSON.parse(imageList);
24
- imagesSets = (0, _prepareImagesFromList.prepareImagesFromList)(images, srcConfig);
24
+ imagesSrcs = (0, _prepareImagesFromList.prepareImagesFromList)(images, srcConfig);
25
25
  } catch (error) {
26
26
  console.error("Wrong format in image-list attribute: ".concat(error.message));
27
27
  }
28
28
  } else {
29
- imagesSets = (0, _prepareImagesFromFolder.prepareImagesFromFolder)(imagesSrc, srcConfig);
29
+ imagesSrcs = (0, _prepareImagesFromFolder.prepareImagesFromFolder)(imagesSrc, srcConfig);
30
30
  }
31
31
 
32
- var _ref2 = imagesSets || {},
33
- resultSrc = _ref2.resultSrc;
34
-
35
- (0, _loadImagesRelativeToContainerSize.loadImagesRelativeToContainerSize)(resultSrc, srcConfig, onImageLoadCallback);
32
+ (0, _loadImagesRelativeToContainerSize.loadImagesRelativeToContainerSize)(imagesSrcs, cb);
36
33
  };
37
34
 
38
35
  exports.preloadImages = preloadImages;
@@ -12,27 +12,24 @@ var _prepareImagesFromList = require("./images-from-list/prepare-images-from-lis
12
12
  var _loadOriginalImages = require("./load-original-images");
13
13
 
14
14
  /* eslint-disable no-console */
15
- var preloadOriginalImages = function preloadOriginalImages(srcConfig, imagesSrc, onImageLoadCallback) {
15
+ var preloadOriginalImages = function preloadOriginalImages(srcConfig, imagesSrc, cb) {
16
16
  var _ref = srcConfig || {},
17
17
  imageList = _ref.imageList;
18
18
 
19
- var imagesSets = {};
19
+ var imagesSrcs = [];
20
20
 
21
21
  if (imageList) {
22
22
  try {
23
23
  var images = JSON.parse(imageList);
24
- imagesSets = (0, _prepareImagesFromList.prepareImagesFromList)(images, srcConfig);
24
+ imagesSrcs = (0, _prepareImagesFromList.prepareImagesFromList)(images, srcConfig, true);
25
25
  } catch (error) {
26
26
  console.error("Wrong format in image-list attribute: ".concat(error.message));
27
27
  }
28
28
  } else {
29
- imagesSets = (0, _prepareImagesFromFolder.prepareImagesFromFolder)(imagesSrc, srcConfig);
29
+ imagesSrcs = (0, _prepareImagesFromFolder.prepareImagesFromFolder)(imagesSrc, srcConfig, true);
30
30
  }
31
31
 
32
- var _ref2 = imagesSets || {},
33
- originalSrc = _ref2.originalSrc;
34
-
35
- (0, _loadOriginalImages.loadOriginalImages)(originalSrc, onImageLoadCallback);
32
+ (0, _loadOriginalImages.loadOriginalImages)(imagesSrcs, cb);
36
33
  };
37
34
 
38
35
  exports.preloadOriginalImages = preloadOriginalImages;
@@ -17,7 +17,7 @@ var getImageAspectRatio = function getImageAspectRatio(image, providedRatio) {
17
17
  imageAspectRatio = providedRatio;
18
18
  }
19
19
 
20
- if ((0, _typeof2.default)(providedRatio) === 'object') {
20
+ if (providedRatio && (0, _typeof2.default)(providedRatio) === 'object') {
21
21
  var mediaQueries = Object.keys(providedRatio).sort(function (a, b) {
22
22
  return a - b;
23
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-cloudimage-360-view",
3
- "version": "2.7.8",
3
+ "version": "2.7.11",
4
4
  "main": "dist/index.js",
5
5
  "description": "",
6
6
  "author": "scaleflex",
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.IMAGE_SRC_PROPS = void 0;
7
- var IMAGE_SRC_PROPS = ['folder', 'filenameX', 'filenameY', 'apiVersion', 'imageListX', 'imageListY', 'indexZeroBase', 'amountX', 'amountY', 'lazySelector'];
8
- exports.IMAGE_SRC_PROPS = IMAGE_SRC_PROPS;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isSrcPropsChanged = void 0;
7
-
8
- var _imageSrcProps = require("../../constants/image-src-props");
9
-
10
- var isSrcPropsChanged = function isSrcPropsChanged(currentProps, changedProps) {
11
- return Object.keys(changedProps).reduce(function (acc, current) {
12
- var isPropChanged = currentProps[current] !== changedProps[current];
13
- var isSrcProp = _imageSrcProps.IMAGE_SRC_PROPS.indexOf(current) !== -1;
14
-
15
- if (isSrcProp && isPropChanged) {
16
- acc = true;
17
- }
18
-
19
- return acc;
20
- }, false);
21
- };
22
-
23
- exports.isSrcPropsChanged = isSrcPropsChanged;
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.loadImage = void 0;
7
-
8
- var loadImage = function loadImage(src, index, srcConfig) {
9
- var _ref = srcConfig || {},
10
- lazyload = _ref.lazyload,
11
- lazySelector = _ref.lazySelector,
12
- fullscreenView = _ref.fullscreenView;
13
-
14
- var image = new Image();
15
-
16
- if (lazyload && !fullscreenView) {
17
- image.setAttribute('data-src', src);
18
- image.className = image.className.length ? "".concat(image.className, " ").concat(lazySelector) : lazySelector;
19
- } else {
20
- image.src = src;
21
- }
22
-
23
- return image;
24
- };
25
-
26
- exports.loadImage = loadImage;