js-cloudimage-360-view 2.7.9 → 2.7.12

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +3 -4
  3. package/dist/ci360.service.js +77 -64
  4. package/dist/ci360.utils.js +4 -2
  5. package/dist/index.js +27 -18
  6. package/dist/static/css/hotspots.css +5 -3
  7. package/dist/static/css/style.css +107 -0
  8. package/dist/utils/hotspots/attach-events/hide-popup.js +15 -0
  9. package/dist/utils/hotspots/attach-events/show-popup.js +14 -0
  10. package/dist/utils/hotspots/elements/create-hotspot-icon.js +37 -12
  11. package/dist/utils/hotspots/elements/create-hotspots.js +7 -2
  12. package/dist/utils/hotspots/get-hotspot-popup-node.js +1 -8
  13. package/dist/utils/hotspots/toggle-popup-events.js +23 -0
  14. package/dist/utils/hotspots/update-hotspots.js +2 -15
  15. package/dist/utils/index.js +9 -0
  16. package/dist/utils/load-images/images-from-folder/prepare-images-from-folder.js +10 -12
  17. package/dist/utils/load-images/images-from-list/prepare-images-from-list.js +9 -11
  18. package/dist/utils/load-images/lazyload/init-lazyload.js +49 -0
  19. package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-folder.js +18 -0
  20. package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-list.js +29 -0
  21. package/dist/utils/load-images/load-image-as-promise.js +12 -37
  22. package/dist/utils/load-images/load-images-relative-to-container-size.js +4 -4
  23. package/dist/utils/load-images/load-original-images.js +2 -2
  24. package/dist/utils/load-images/preload-images.js +5 -8
  25. package/dist/utils/load-images/preload-original-images.js +5 -8
  26. package/dist/utils/responsive/get-image-aspect-ratio.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/utils/hotspots/attach-popup-events.js +0 -63
  29. package/dist/utils/load-images/load-image.js +0 -26
package/CHANGELOG.md CHANGED
@@ -25,6 +25,20 @@ Types of changes:
25
25
  - ...
26
26
 
27
27
  -------------
28
+ ## 2.7.12 - 2022-03-19
29
+ ### Changed
30
+ - hotspots init method
31
+
32
+ ## 2.7.11 - 2022-03-17
33
+ ### Fixed
34
+ - canvas aspect ratio
35
+ - initialization of lazyloading
36
+
37
+ ## 2.7.10 - 2022-03-01
38
+ ### Fixed
39
+ - image quality in fullscreen
40
+ - resized image loading
41
+
28
42
  ## 2.7.9 - 2022-02-27
29
43
  ### Fixed
30
44
  - typo in documentation
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Release](https://img.shields.io/badge/release-v2.7.9-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
1
+ [![Release](https://img.shields.io/badge/release-v2.7.12-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
 
@@ -23,12 +23,14 @@ require("./static/css/hotspots.css");
23
23
 
24
24
  var _utils = require("./utils");
25
25
 
26
+ var _togglePopupEvents = require("./utils/hotspots/toggle-popup-events");
27
+
26
28
  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; }
27
29
 
28
30
  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; }
29
31
 
30
32
  var CI360Viewer = /*#__PURE__*/function () {
31
- function CI360Viewer(container, fullscreen, hotspotConfig) {
33
+ function CI360Viewer(container, fullscreen, hotspotsConfigs) {
32
34
  (0, _classCallCheck2.default)(this, CI360Viewer);
33
35
  this.container = container;
34
36
  this.movementStart = {
@@ -52,7 +54,7 @@ var CI360Viewer = /*#__PURE__*/function () {
52
54
  this.devicePixelRatio = Math.round(window.devicePixelRatio || 1);
53
55
  this.isMobile = !!('ontouchstart' in window || navigator.msMaxTouchPoints);
54
56
  this.id = container.id;
55
- this.hotspotConfig = hotspotConfig && (0, _utils.generateHotspotsConfigs)(hotspotConfig);
57
+ this.hotspotsConfigs = hotspotsConfigs && (0, _utils.generateHotspotsConfigs)(hotspotsConfigs);
56
58
  this.isMagnifyOpen = false;
57
59
  this.isDragged = false;
58
60
  this.startPointerZoom = false;
@@ -71,6 +73,18 @@ var CI360Viewer = /*#__PURE__*/function () {
71
73
  }
72
74
 
73
75
  (0, _createClass2.default)(CI360Viewer, [{
76
+ key: "isReady",
77
+ value: function isReady() {
78
+ var loadedXImages = this.imagesX.filter(function (image) {
79
+ return image;
80
+ });
81
+ var loadedYImages = this.imagesY.filter(function (image) {
82
+ return image;
83
+ });
84
+ var totalAmount = this.amountX + this.amountY;
85
+ return loadedXImages.length + loadedYImages.length === totalAmount;
86
+ }
87
+ }, {
74
88
  key: "mouseDown",
75
89
  value: function mouseDown(event) {
76
90
  if (!this.imagesLoaded) return;
@@ -96,6 +110,10 @@ var CI360Viewer = /*#__PURE__*/function () {
96
110
  this.isClicked = true;
97
111
  this.isDragged = false;
98
112
 
113
+ if (this.hotspotsConfigs) {
114
+ (0, _togglePopupEvents.togglePopupEvents)(this.hotspotsConfigs, event, true);
115
+ }
116
+
99
117
  if (isMouseOnHotspotElement) {
100
118
  this.isClicked = false;
101
119
  }
@@ -117,6 +135,10 @@ var CI360Viewer = /*#__PURE__*/function () {
117
135
  this.show360ViewCircleIcon();
118
136
  }
119
137
 
138
+ if (this.hotspotsConfigs) {
139
+ (0, _togglePopupEvents.togglePopupEvents)(this.hotspotsConfigs);
140
+ }
141
+
120
142
  if (this.pointerZoom && !this.fullscreenView) {
121
143
  setTimeout(function () {
122
144
  _this.isZoomReady = true;
@@ -222,7 +244,7 @@ var CI360Viewer = /*#__PURE__*/function () {
222
244
 
223
245
  var _zoomSteps = (0, _utils.generateZoomInSteps)(this.pointerZoom);
224
246
 
225
- if (this.hotspotConfig) {
247
+ if (this.hotspotsConfigs) {
226
248
  (0, _utils.hideHotspotsIcons)();
227
249
  }
228
250
 
@@ -248,10 +270,10 @@ var CI360Viewer = /*#__PURE__*/function () {
248
270
  }
249
271
 
250
272
  var loadedOriginalXImages = this.originalImagesX.filter(function (image) {
251
- return !!image;
273
+ return image;
252
274
  });
253
275
  var loadedOriginalYImages = this.originalImagesY.filter(function (image) {
254
- return !!image;
276
+ return image;
255
277
  });
256
278
  var totalAmount = this.amountX + this.amountY;
257
279
  var totalLoadedImages = loadedOriginalXImages.length + loadedOriginalYImages.length;
@@ -277,7 +299,7 @@ var CI360Viewer = /*#__PURE__*/function () {
277
299
 
278
300
  if (this.allowSpinY) {
279
301
  var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
280
- (0, _utils.preloadOriginalImages)(this.srcXConfig, srcY, this.onOriginalImageLoad.bind(this, _constants.ORIENTATIONS.Y, event));
302
+ (0, _utils.preloadOriginalImages)(this.srcYConfig, srcY, this.onOriginalImageLoad.bind(this, _constants.ORIENTATIONS.Y, event));
281
303
  }
282
304
  }
283
305
  }, {
@@ -665,6 +687,10 @@ var CI360Viewer = /*#__PURE__*/function () {
665
687
  this.container.height = window.innerHeight * this.devicePixelRatio;
666
688
  this.container.style.height = window.innerHeight + 'px';
667
689
  this.container.style.maxWidth = 'unset';
690
+ this.canvas.width = window.innerWidth * this.devicePixelRatio;
691
+ this.canvas.style.width = window.innerWidth + 'px';
692
+ this.canvas.height = window.innerHeight * this.devicePixelRatio;
693
+ this.canvas.style.height = window.innerHeight + 'px';
668
694
  return;
669
695
  }
670
696
 
@@ -683,10 +709,10 @@ var CI360Viewer = /*#__PURE__*/function () {
683
709
  }
684
710
 
685
711
  var loadedResizedXImages = this.resizedImagesX.filter(function (image) {
686
- return !!image;
712
+ return image;
687
713
  });
688
714
  var loadedResizedYImages = this.resizedImagesY.filter(function (image) {
689
- return !!image;
715
+ return image;
690
716
  });
691
717
  var isAllImagesLoaded = loadedResizedXImages.length + loadedResizedYImages.length === this.amountX + this.amountY;
692
718
 
@@ -711,17 +737,18 @@ var CI360Viewer = /*#__PURE__*/function () {
711
737
  }, {
712
738
  key: "requestResizedImages",
713
739
  value: function requestResizedImages() {
740
+ if (!this.isReady()) return;
714
741
  var responsive = this.ciParams.ciToken;
715
742
  var firstImage = this.imagesX[0];
716
743
  this.update();
744
+ if (!responsive || this.container.offsetWidth < firstImage.width * 1.5) return;
717
745
  this.speedFactor = (0, _utils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
718
746
  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);
747
+ (0, _utils.preloadImages)(this.srcXConfig, srcX, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.X));
721
748
 
722
749
  if (this.allowSpinY) {
723
750
  var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
724
- (0, _utils.preloadImages)(this.srcYConfig, srcY, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.Y), true);
751
+ (0, _utils.preloadImages)(this.srcYConfig, srcY, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.Y));
725
752
  }
726
753
  }
727
754
  }, {
@@ -749,8 +776,8 @@ var CI360Viewer = /*#__PURE__*/function () {
749
776
  if (this.mouseTracked) {
750
777
  this.updateImageScale(ctx);
751
778
  } else {
752
- if (this.hotspotConfig && !this.autoplay) {
753
- (0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
779
+ if (this.hotspotsConfigs && !this.autoplay) {
780
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection, this.isClicked);
754
781
  }
755
782
 
756
783
  ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
@@ -795,6 +822,7 @@ var CI360Viewer = /*#__PURE__*/function () {
795
822
  value: function onFirstImageLoaded(image) {
796
823
  if (!this.hide360Logo && !this.lazyload) this.add360ViewIcon();
797
824
  var ctx = this.canvas.getContext("2d");
825
+ ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
798
826
  this.updateContainerAndCanvasSize(image);
799
827
 
800
828
  if (this.fullscreenView) {
@@ -834,8 +862,8 @@ var CI360Viewer = /*#__PURE__*/function () {
834
862
  this.addFullscreenIcon();
835
863
  }
836
864
 
837
- if (this.hotspotConfig && !this.autoplay) {
838
- (0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
865
+ if (this.hotspotsConfigs && !this.autoplay) {
866
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection);
839
867
  }
840
868
  }
841
869
  }, {
@@ -867,6 +895,10 @@ var CI360Viewer = /*#__PURE__*/function () {
867
895
  }
868
896
 
869
897
  this.initControls();
898
+
899
+ if (this.hotspotsConfigs && !this.autoplay) {
900
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection);
901
+ }
870
902
  }
871
903
  }, {
872
904
  key: "magnify",
@@ -903,7 +935,7 @@ var CI360Viewer = /*#__PURE__*/function () {
903
935
  event.stopPropagation();
904
936
  if (this.mouseTracked) this.togglePointerZoom();
905
937
  var fullscreenContainer = (0, _utils.createFullscreenModal)(this.container);
906
- new CI360Viewer(fullscreenContainer, true, this.hotspotConfig);
938
+ new CI360Viewer(fullscreenContainer, true, this.hotspotsConfigs);
907
939
  }
908
940
  }, {
909
941
  key: "setFullscreenEvents",
@@ -962,9 +994,9 @@ var CI360Viewer = /*#__PURE__*/function () {
962
994
  var viewIndex = viewers.findIndex(function (view) {
963
995
  return view.id === _this5.container.id;
964
996
  });
997
+ container.removeChild(this.innerBox);
965
998
  container = container.cloneNode(true);
966
999
  container.className = container.className.replace(' initialized', '');
967
- container.innerHTML = '';
968
1000
  oldElement.parentNode.replaceChild(container, oldElement);
969
1001
  return viewers.splice(viewIndex, 1, new CI360Viewer(container));
970
1002
  }
@@ -1159,10 +1191,10 @@ var CI360Viewer = /*#__PURE__*/function () {
1159
1191
  onEventEnd: onEventEnd
1160
1192
  };
1161
1193
  var controlsElements = (0, _utils.initControls)(controlsConfig, controlsTriggers);
1162
- this.topElem = controlsElements.top || {};
1163
- this.bottomElem = controlsElements.bottom || {};
1164
- this.leftElem = controlsElements.left || {};
1165
- this.rightElem = controlsElements.right || {};
1194
+ this.topElem = controlsElements.top;
1195
+ this.bottomElem = controlsElements.bottom;
1196
+ this.leftElem = controlsElements.left;
1197
+ this.rightElem = controlsElements.right;
1166
1198
  }
1167
1199
  }, {
1168
1200
  key: "attachEvents",
@@ -1272,8 +1304,6 @@ var CI360Viewer = /*#__PURE__*/function () {
1272
1304
  this.disableDrag = disableDrag;
1273
1305
  this.fullscreen = fullscreen;
1274
1306
  this.magnifier = !this.isMobile && magnifier > 1 ? Math.min(magnifier, 5) : 0;
1275
- this.lazyloadX = lazyload;
1276
- this.lazyloadY = lazyload;
1277
1307
  this.lazySelector = lazySelector;
1278
1308
  this.spinReverse = spinReverse;
1279
1309
  this.controlReverse = controlReverse;
@@ -1306,10 +1336,6 @@ var CI360Viewer = /*#__PURE__*/function () {
1306
1336
  this.addMagnifier();
1307
1337
  }
1308
1338
 
1309
- if (this.info) {
1310
- this.showImageInfo(ctx);
1311
- }
1312
-
1313
1339
  if (this.bottomCircle && !this.fullscreenView) {
1314
1340
  this.add360ViewCircleIcon();
1315
1341
  }
@@ -1330,8 +1356,8 @@ var CI360Viewer = /*#__PURE__*/function () {
1330
1356
  this.canvas = (0, _utils.createCanvas)(this.innerBox);
1331
1357
  this.loader = (0, _utils.createLoader)(this.innerBox);
1332
1358
 
1333
- if (this.hotspotConfig && !this.fullscreenView) {
1334
- (0, _utils.createHotspots)(container, this.hotspotConfig);
1359
+ if (this.hotspotsConfigs && !this.fullscreenView) {
1360
+ (0, _utils.createHotspots)(container, this.hotspotsConfigs);
1335
1361
  }
1336
1362
 
1337
1363
  (0, _utils.applyStylesToContainer)(this.container);
@@ -1343,7 +1369,6 @@ var CI360Viewer = /*#__PURE__*/function () {
1343
1369
  innerBox: this.innerBox,
1344
1370
  apiVersion: apiVersion,
1345
1371
  ciParams: ciParams,
1346
- lazyload: lazyload,
1347
1372
  lazySelector: lazySelector,
1348
1373
  amount: this.amountX,
1349
1374
  indexZeroBase: indexZeroBase,
@@ -1356,26 +1381,6 @@ var CI360Viewer = /*#__PURE__*/function () {
1356
1381
  amount: this.amountY
1357
1382
  });
1358
1383
  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({}, _this7.srcXConfig), {}, {
1363
- lazyload: false
1364
- });
1365
-
1366
- var lazyloadYConfig = _objectSpread(_objectSpread({}, _this7.srcYConfig), {}, {
1367
- lazyload: false
1368
- });
1369
-
1370
- if (orientation === _constants.ORIENTATIONS.Y) {
1371
- _this7.lazyloadY = false;
1372
- (0, _utils.preloadImages)(lazyloadXConfig, srcX, onImageLoad.bind(_this7, _constants.ORIENTATIONS.X));
1373
- } else {
1374
- _this7.lazyloadX = false;
1375
- _this7.lazyloadInitImageX = image;
1376
- (0, _utils.preloadImages)(lazyloadYConfig, srcY, onImageLoad.bind(_this7, _constants.ORIENTATIONS.Y));
1377
- }
1378
- };
1379
1384
 
1380
1385
  var onImageLoad = function onImageLoad(orientation, image, index) {
1381
1386
  if (orientation !== _constants.ORIENTATIONS.Y) {
@@ -1385,40 +1390,48 @@ var CI360Viewer = /*#__PURE__*/function () {
1385
1390
  }
1386
1391
 
1387
1392
  var loadedXImages = _this7.imagesX.filter(function (image) {
1388
- return !!image;
1393
+ return image;
1389
1394
  });
1390
1395
 
1391
1396
  var loadedYImages = _this7.imagesY.filter(function (image) {
1392
- return !!image;
1397
+ return image;
1393
1398
  });
1394
1399
 
1395
1400
  var totalAmount = _this7.amountX + _this7.amountY;
1396
- var totalLoadedImages = _this7.imagesX.length + _this7.imagesY.length;
1397
- var isFirstImageLoaded = index === 0 && orientation !== _constants.ORIENTATIONS.Y;
1398
- var isAllImagesLoaded = loadedXImages.length + loadedYImages.length === _this7.amountX + _this7.amountY;
1401
+ var totalLoadedImages = loadedXImages.length + loadedYImages.length;
1402
+ var isFirstImageLoaded = !index && orientation !== _constants.ORIENTATIONS.Y;
1399
1403
  var percentage = Math.round(totalLoadedImages / totalAmount * 100);
1400
1404
 
1401
1405
  _this7.updatePercentageInLoader(percentage);
1402
1406
 
1403
- if (_this7.lazyloadX || _this7.lazyloadY) return initLazyload(image, orientation);
1404
-
1405
1407
  if (isFirstImageLoaded) {
1406
1408
  _this7.onFirstImageLoaded(image);
1407
1409
  }
1408
1410
 
1409
- if (isAllImagesLoaded) {
1411
+ if (_this7.isReady()) {
1410
1412
  _this7.onAllImagesLoaded();
1413
+ }
1414
+ };
1411
1415
 
1412
- if (lazyload) {
1413
- _this7.innerBox.removeChild(_this7.lazyloadInitImageX);
1414
- }
1416
+ var loadImages = function loadImages() {
1417
+ (0, _utils.preloadImages)(_this7.srcXConfig, srcX, onImageLoad.bind(_this7, _constants.ORIENTATIONS.X));
1418
+
1419
+ if (_this7.allowSpinY) {
1420
+ var srcY = (0, _utils.generateImagesPath)(_this7.srcYConfig);
1421
+ (0, _utils.preloadImages)(_this7.srcYConfig, srcY, onImageLoad.bind(_this7, _constants.ORIENTATIONS.Y));
1415
1422
  }
1416
1423
  };
1417
1424
 
1418
- (0, _utils.preloadImages)(this.srcXConfig, srcX, onImageLoad.bind(this, _constants.ORIENTATIONS.X));
1425
+ if (lazyload) {
1426
+ var onFirstImageLoad = function onFirstImageLoad(image) {
1427
+ _this7.innerBox.removeChild(image);
1419
1428
 
1420
- if (this.allowSpinY) {
1421
- (0, _utils.preloadImages)(this.srcYConfig, srcY, onImageLoad.bind(this, _constants.ORIENTATIONS.Y));
1429
+ loadImages();
1430
+ };
1431
+
1432
+ (0, _utils.initLazyload)(srcX, this.srcXConfig, onFirstImageLoad);
1433
+ } else {
1434
+ loadImages();
1422
1435
  }
1423
1436
 
1424
1437
  this.attachEvents(draggable, swipeable, keys);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setView360Icon = exports.get360ViewProps = exports.debounce = exports.attr = void 0;
6
+ exports.setView360Icon = exports.isTrue = exports.get360ViewProps = exports.debounce = exports.attr = void 0;
7
7
 
8
8
  var _constants = require("./constants");
9
9
 
@@ -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
  };
@@ -59,6 +59,8 @@ var isTrue = function isTrue(image, type) {
59
59
  return imgProp !== null && imgProp !== 'false' || imgDataProp !== null && imgDataProp !== 'false';
60
60
  };
61
61
 
62
+ exports.isTrue = isTrue;
63
+
62
64
  var attr = function attr(element, attribute) {
63
65
  return element.getAttribute(attribute);
64
66
  };
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ var _ci = _interopRequireDefault(require("./ci360.service"));
12
12
 
13
13
  var _ci2 = require("./ci360.utils");
14
14
 
15
- function setContainerId(container) {
15
+ function getContainerWithId(container) {
16
16
  var containerId = container.id;
17
17
 
18
18
  if (!containerId) {
@@ -27,12 +27,13 @@ function setContainerId(container) {
27
27
  function init() {
28
28
  var viewers = [];
29
29
  var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
30
- var hotspotsConfigs = window.CI360.hotspots || {};
31
- [].slice.call(view360Array).forEach(function (container) {
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));
30
+ [].slice.call(view360Array).forEach(function (_container) {
31
+ var container = getContainerWithId(_container);
32
+ var isHotspotsEnabled = (0, _ci2.isTrue)(container, 'hotspots');
33
+
34
+ if (!isHotspotsEnabled) {
35
+ viewers.push(new _ci.default(container));
36
+ }
36
37
  });
37
38
  window.CI360._viewers = viewers;
38
39
  }
@@ -61,7 +62,7 @@ function getActiveIndexByID(id, oriantation) {
61
62
  return currentViewer && currentViewer.activeImageX - 1;
62
63
  }
63
64
 
64
- function addView(id) {
65
+ function add(id) {
65
66
  var view360Array = Array.from(document.querySelectorAll('.cloudimage-360:not(.initialized)'));
66
67
 
67
68
  if (view360Array.length && id) {
@@ -77,15 +78,11 @@ function update() {
77
78
  var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
78
79
 
79
80
  if (id) {
80
- try {
81
- var view = window.CI360._viewers.filter(function (viewer) {
82
- return viewer.id === id;
83
- })[0];
84
-
85
- view.updateView(forceUpdate, window.CI360._viewers);
86
- } catch (_unused) {
87
- console.warn("Cloudimage-360: there is no view with such id '".concat(id, "', you may need to run window.addView('").concat(id, "') before run update'"));
88
- }
81
+ var view = window.CI360._viewers.filter(function (viewer) {
82
+ return viewer.id === id;
83
+ })[0];
84
+
85
+ view.updateView(forceUpdate, window.CI360._viewers);
89
86
  } else {
90
87
  window.CI360._viewers.forEach(function (viewer) {
91
88
  viewer.updateView(forceUpdate, window.CI360._viewers);
@@ -97,12 +94,24 @@ function isNoViewers() {
97
94
  return !(window.CI360._viewers && window.CI360._viewers.length > 0);
98
95
  }
99
96
 
97
+ function addHotspots(instanceId, config) {
98
+ var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
99
+ var container = Array.from(view360Array).find(function (view) {
100
+ return view.id === instanceId;
101
+ });
102
+
103
+ if (container) {
104
+ window.CI360._viewers.push(new _ci.default(container, false, config));
105
+ }
106
+ }
107
+
100
108
  window.CI360 = window.CI360 || {};
101
109
  window.CI360.init = init;
102
110
  window.CI360.destroy = destroy;
103
111
  window.CI360.getActiveIndexByID = getActiveIndexByID;
104
112
  window.CI360.update = update;
105
- window.CI360.addView = addView;
113
+ window.CI360.add = add;
114
+ window.CI360.addHotspots = addHotspots;
106
115
 
107
116
  if (!window.CI360.notInitOnLoad) {
108
117
  init();
@@ -35,7 +35,7 @@
35
35
  border: 1px solid #FFFFFF33;
36
36
  border-radius: 50%;
37
37
  box-sizing: border-box;
38
- transition: opacity 800ms ease-in-out;
38
+ transition: opacity 300ms ease-in-out;
39
39
  cursor: auto;
40
40
  }
41
41
 
@@ -61,7 +61,7 @@
61
61
  .cloudimage-360-hotspot-custom-icon::after {
62
62
  content: '+';
63
63
  position: absolute;
64
- width: 8px;
64
+ line-height: 20px;
65
65
  left: 50%;
66
66
  top: 100%;
67
67
  color: #FFF;
@@ -131,6 +131,8 @@
131
131
  .cloudimage-360-images-carousel .cloudimage-360-carousel-image {
132
132
  display: none;
133
133
  min-height: 187px;
134
+ max-width: 100%;
135
+ max-height: 100%;
134
136
  }
135
137
 
136
138
  .cloudimage-360-images-carousel .cloudimage-360-carousel-image.active-image {
@@ -194,10 +196,10 @@
194
196
  padding: 4px 8px;
195
197
  transition: background-color 200ms ease-in-out;
196
198
  border-radius: 2px;
199
+ text-decoration: none;
197
200
  }
198
201
 
199
202
  .cloudimage-360-modal-more-details:hover {
200
- text-decoration: none;
201
203
  color: #76AD01;
202
204
  background-color: #e1f5d8;
203
205
  }
@@ -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,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hidePopup = void 0;
7
+
8
+ var hidePopup = function hidePopup(popup, isVisible) {
9
+ if (!isVisible) {
10
+ popup.removeAttribute('data-show');
11
+ popup.removeAttribute('data-cloudimage-360-show');
12
+ }
13
+ };
14
+
15
+ exports.hidePopup = hidePopup;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.showPopup = void 0;
7
+
8
+ var showPopup = function showPopup(popup, popperInstance) {
9
+ popup.setAttribute('data-show', '');
10
+ popup.setAttribute('data-cloudimage-360-show', '');
11
+ popperInstance.update();
12
+ };
13
+
14
+ exports.showPopup = showPopup;