js-cloudimage-360-view 2.7.5 → 2.7.8

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 (48) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +50 -22
  3. package/dist/ci360.service.js +100 -44
  4. package/dist/ci360.utils.js +5 -3
  5. package/dist/index.js +6 -1
  6. package/dist/static/css/hotspots.css +222 -0
  7. package/dist/utils/{common → class-names}/add-class.js +0 -0
  8. package/dist/utils/{common → class-names}/remove-class.js +0 -0
  9. package/dist/utils/container-elements/index.js +9 -1
  10. package/dist/utils/container-elements/remove-child-from-parent.js +16 -0
  11. package/dist/utils/controls/init-controls.js +1 -1
  12. package/dist/utils/{hotspot → hotspots}/attach-popup-events.js +1 -1
  13. package/dist/utils/{hotspot → hotspots}/configs-error-handler.js +7 -10
  14. package/dist/utils/{hotspot → hotspots}/create-popper-instace.js +0 -0
  15. package/dist/utils/{hotspot → hotspots}/elements/create-carousel-dot.js +1 -1
  16. package/dist/utils/{hotspot → hotspots}/elements/create-carousel-image.js +0 -0
  17. package/dist/utils/{hotspot → hotspots}/elements/create-hotspot-icon.js +4 -5
  18. package/dist/utils/{hotspot → hotspots}/elements/create-hotspot-popup-link.js +0 -0
  19. package/dist/utils/{hotspot → hotspots}/elements/create-hotspots.js +0 -0
  20. package/dist/utils/{hotspot → hotspots}/elements/create-images-carousel.js +0 -0
  21. package/dist/utils/{hotspot → hotspots}/elements/create-modal-description.js +0 -0
  22. package/dist/utils/{hotspot → hotspots}/elements/create-modal-title.js +0 -0
  23. package/dist/utils/hotspots/elements/create-model-elements.js +66 -0
  24. package/dist/utils/{hotspot → hotspots}/elements/create-popup-arrow.js +0 -0
  25. package/dist/utils/{hotspot → hotspots}/elements/create-popup.js +10 -7
  26. package/dist/utils/hotspots/elements/create-read-more-btn.js +17 -0
  27. package/dist/utils/{hotspot/fill-previous-coord-with-previous.js → hotspots/fill-empty-coord-with-previous.js} +3 -3
  28. package/dist/utils/hotspots/generate-hotspots-configs.js +58 -0
  29. package/dist/utils/{hotspot → hotspots}/generate-popup-config.js +3 -8
  30. package/dist/utils/{hotspot → hotspots}/get-hotspot-icon.js +0 -0
  31. package/dist/utils/{hotspot → hotspots}/get-hotspot-orientation.js +0 -0
  32. package/dist/utils/{hotspot → hotspots}/get-hotspot-popup-node.js +4 -2
  33. package/dist/utils/{hotspot → hotspots}/get-popup-node.js +1 -1
  34. package/dist/utils/{hotspot → hotspots}/hide-hotspot-icon.js +0 -0
  35. package/dist/utils/{hotspot → hotspots}/hide-hotspots-icons.js +0 -0
  36. package/dist/utils/{hotspot → hotspots}/is-mouse-on-hotspot.js +0 -0
  37. package/dist/utils/{hotspot → hotspots}/prepare-hotspots-positions.js +3 -3
  38. package/dist/utils/{hotspot → hotspots}/set-current-slide.js +0 -0
  39. package/dist/utils/{hotspot → hotspots}/update-hotspot-icon-position.js +0 -0
  40. package/dist/utils/{hotspot → hotspots}/update-hotspots.js +10 -9
  41. package/dist/utils/index.js +31 -40
  42. package/dist/utils/responsive/get-image-aspect-ratio.js +39 -0
  43. package/package.json +1 -1
  44. package/dist/utils/hotspot/elements/create-model-elements.js +0 -49
  45. package/dist/utils/hotspot/generate-hotspots-configs.js +0 -41
  46. package/dist/utils/hotspot/get-hotspot-variant.js +0 -20
  47. package/dist/utils/responsive/get-container-responsive-height.js +0 -20
  48. package/dist/utils/responsive/get-container-responsive-width.js +0 -20
package/CHANGELOG.md CHANGED
@@ -25,7 +25,23 @@ Types of changes:
25
25
  - ...
26
26
 
27
27
  -------------
28
- ## 2.7.5 - 2022-01-08
28
+ ## 2.7.8 - 2022-02-27
29
+ ### Added
30
+ - possibility to add new view to CI360 views
31
+ ### Fixed
32
+ - re-render method
33
+
34
+ ## 2.7.7 - 2022-02-24
35
+ ### Fixed
36
+ - container width on mobile
37
+ - re-render method
38
+
39
+ ## 2.7.6 - 2022-02-20
40
+ ### Fixed
41
+ - drag speed
42
+ - responsive canvas width and height
43
+
44
+ ## 2.7.5 - 2022-02-08
29
45
  ### Added
30
46
  - update method to re-render or re-init the plugin
31
47
  ### Fixed
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Release](https://img.shields.io/badge/release-v2.7.5-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
1
+ [![Release](https://img.shields.io/badge/release-v2.7.8-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)
@@ -6,16 +6,9 @@
6
6
  [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Engage%20your%20customers%20with%20a%20stunning%20360%20viewvof%20your%20products&url=https://scaleflex.github.io/js-cloudimage-360-view/&via=cloudimage&hashtags=images,cloudimage)
7
7
 
8
8
  <p align="center">
9
- <a href="https://www.cloudimage.io/#gh-light-mode-only">
10
- <img
9
+ <img
11
10
  alt="The Lounge"
12
11
  src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
13
- </a>
14
- <a href="https://www.cloudimage.io/#gh-dark-mode-only">
15
- <img
16
- alt="The Lounge"
17
- src="https://scaleflex.cloudimg.io/v7/cloudimage.io/cloudimage-logo-light.png?vh=b798ab&w=350">
18
- </a>
19
12
  </p>
20
13
 
21
14
  <h1 align="center">
@@ -112,6 +105,17 @@ window.CI360.init();
112
105
  > <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2/js-cloudimage-360-view.min.js"></script>
113
106
  > <script>window.CI360.init(); // initialize the plugin when you need</script>
114
107
  > ```
108
+
109
+ ### addView
110
+
111
+ ###### Type: **Function**
112
+
113
+ add new view by id to cloudimage 360 views.
114
+
115
+ ```javascript
116
+ window.CI360.addView(idOfView: string);
117
+ ```
118
+
115
119
  ### update
116
120
 
117
121
  ###### Type: **Function**
@@ -308,25 +312,49 @@ Open 360 spin view in full screen modal.
308
312
 
309
313
  Magnifier to zoom image.
310
314
 
311
- ### ~~data-ratio (or ratio)~~ [deprecated]
315
+ ### data-ratio (or ratio)
312
316
 
313
317
 
314
- ###### ~~Type: **Number** (height / width) | Default: **none** | _optional_~~
315
-
316
- ~~Prevents page from jumping.~~
317
- ### data-width (or width)
318
-
319
- ###### Type: **Number** | Default: **none** | _optional_
318
+ ###### Type: **Number** (width / height) or JSON object | Default: **none** | _optional_
319
+ #### `ratio`: string
320
320
 
321
- Set a responsive width for the container.
322
- It will maintain the aspect ratio in respect to width
323
- ### data-height (or height)
321
+ Setting the height relative to the container width according to the provided ratio</br>
322
+ In the following example, the height should be 0.3 the container width
324
323
 
325
- ###### Type: **Number** | Default: **none** | _optional_
324
+ ```html
325
+ <div
326
+ id="cloudimage-360-car"
327
+ class="cloudimage-360"
328
+ data-folder="https://scaleflex.airstore.io/demo/360-car/"
329
+ data-filename-x="iris-{index}.jpeg"
330
+ data-amount-x="36"
331
+ data-ratio="2"
332
+ ></div>
333
+ ```
334
+ <a href="https://codesandbox.io/s/js-cloudimage-360-view-g4wyt1?file=/index.html"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
335
+ #### `ratio`: JSON
336
+ Setting the height relative to the container width at any window size.
326
337
 
327
- Set a responsive height for the container.
328
- It will maintain the aspect ratio in respect to height
338
+ In the following example, the height should be 1.3 the container width at window size less than or equal to 567px
339
+ and 2.22 at window size less than or equal to 768px.
329
340
 
341
+ ```html
342
+ <div
343
+ id="cloudimage-360-car"
344
+ class="cloudimage-360"
345
+ data-folder="https://scaleflex.airstore.io/demo/360-car/"
346
+ data-filename-x="iris-{index}.jpeg"
347
+ data-amount-x="36"
348
+ data-ratio='{
349
+ "576": "1.3",
350
+ "768": "2.22",
351
+ "992": "2.23",
352
+ "1200": "3",
353
+ "2400": "3.2"
354
+ }'
355
+ ></div>
356
+ ```
357
+ <a href="https://codesandbox.io/s/js-cloudimage-360-view-5tssb7?file=/index.html"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
330
358
  ### data-autoplay-reverse (or autoplay-reverse)
331
359
 
332
360
  ###### Type: **Bool** | Default: **false** | _optional_
@@ -19,6 +19,8 @@ var _constants = require("./constants/");
19
19
 
20
20
  require("./static/css/style.css");
21
21
 
22
+ require("./static/css/hotspots.css");
23
+
22
24
  var _utils = require("./utils");
23
25
 
24
26
  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; }
@@ -26,7 +28,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
26
28
  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; }
27
29
 
28
30
  var CI360Viewer = /*#__PURE__*/function () {
29
- function CI360Viewer(container, fullscreen) {
31
+ function CI360Viewer(container, fullscreen, hotspotConfig) {
30
32
  (0, _classCallCheck2.default)(this, CI360Viewer);
31
33
  this.container = container;
32
34
  this.movementStart = {
@@ -50,7 +52,7 @@ var CI360Viewer = /*#__PURE__*/function () {
50
52
  this.devicePixelRatio = Math.round(window.devicePixelRatio || 1);
51
53
  this.isMobile = !!('ontouchstart' in window || navigator.msMaxTouchPoints);
52
54
  this.id = container.id;
53
- this.init(container);
55
+ this.hotspotConfig = hotspotConfig && (0, _utils.generateHotspotsConfigs)(hotspotConfig);
54
56
  this.isMagnifyOpen = false;
55
57
  this.isDragged = false;
56
58
  this.startPointerZoom = false;
@@ -65,13 +67,14 @@ var CI360Viewer = /*#__PURE__*/function () {
65
67
  y: 0
66
68
  };
67
69
  this.isStartedLoadOriginalImages = false;
70
+ this.init(container);
68
71
  }
69
72
 
70
73
  (0, _createClass2.default)(CI360Viewer, [{
71
74
  key: "mouseDown",
72
75
  value: function mouseDown(event) {
73
76
  if (!this.imagesLoaded) return;
74
- event.preventDefault();
77
+ var isMouseOnHotspotElement = (0, _utils.isMouseOnHotspot)();
75
78
  var pageX = event.pageX,
76
79
  pageY = event.pageY;
77
80
  this.hideInitialIcons();
@@ -92,6 +95,10 @@ var CI360Viewer = /*#__PURE__*/function () {
92
95
  };
93
96
  this.isClicked = true;
94
97
  this.isDragged = false;
98
+
99
+ if (isMouseOnHotspotElement) {
100
+ this.isClicked = false;
101
+ }
95
102
  }
96
103
  }, {
97
104
  key: "mouseUp",
@@ -215,6 +222,10 @@ var CI360Viewer = /*#__PURE__*/function () {
215
222
 
216
223
  var _zoomSteps = (0, _utils.generateZoomInSteps)(this.pointerZoom);
217
224
 
225
+ if (this.hotspotConfig) {
226
+ (0, _utils.hideHotspotsIcons)();
227
+ }
228
+
218
229
  _zoomSteps.forEach(function (step) {
219
230
  setTimeout(function () {
220
231
  _this2.zoomIntensity = step;
@@ -273,6 +284,7 @@ var CI360Viewer = /*#__PURE__*/function () {
273
284
  key: "touchStart",
274
285
  value: function touchStart(event) {
275
286
  if (!this.imagesLoaded) return;
287
+ var isMouseOnHotspotElement = (0, _utils.isMouseOnHotspot)();
276
288
  this.hideInitialIcons();
277
289
 
278
290
  if (this.autoplay || this.loopTimeoutId) {
@@ -289,6 +301,10 @@ var CI360Viewer = /*#__PURE__*/function () {
289
301
  y: event.touches[0].clientY
290
302
  };
291
303
  this.isClicked = true;
304
+
305
+ if (isMouseOnHotspotElement) {
306
+ this.isClicked = false;
307
+ }
292
308
  }
293
309
  }, {
294
310
  key: "touchEnd",
@@ -639,13 +655,9 @@ var CI360Viewer = /*#__PURE__*/function () {
639
655
  (0, _utils.loop)(this.autoplayBehavior, this.spinY, reversed, loopTriggers);
640
656
  }
641
657
  }, {
642
- key: "updateContainerSize",
643
- value: function updateContainerSize(image) {
644
- var parentEl = this.container.parentNode || {};
645
- var imageAspectRatio = image.width / image.height;
646
- var isProvidedHeightLessThanWidth = this.containerHeight < this.containerWidth;
647
- var containerWidth = (0, _utils.getContainerResponsiveWidth)(parentEl, this.containerWidth);
648
- var containerHeight = (0, _utils.getContainerResponsiveHeight)(this.container, containerWidth, this.containerHeight);
658
+ key: "updateContainerAndCanvasSize",
659
+ value: function updateContainerAndCanvasSize(image) {
660
+ var imageAspectRatio = (0, _utils.getImageAspectRatio)(image, this.ratio);
649
661
 
650
662
  if (this.fullscreenView) {
651
663
  this.container.width = window.innerWidth * this.devicePixelRatio;
@@ -656,24 +668,10 @@ var CI360Viewer = /*#__PURE__*/function () {
656
668
  return;
657
669
  }
658
670
 
659
- if (this.containerWidth && this.containerHeight) {
660
- this.container.style.width = containerWidth + 'px';
661
- this.container.style.height = containerHeight / imageAspectRatio + 'px';
662
- return;
663
- }
664
-
665
- if (!this.containerWidth && !this.containerHeight) {
666
- this.container.style.height = containerHeight / imageAspectRatio + 'px';
667
- return;
668
- }
669
-
670
- if ((isProvidedHeightLessThanWidth || !this.containerWidth) && this.containerHeight) {
671
- this.container.style.maxWidth = containerHeight * imageAspectRatio + 'px';
672
- this.container.style.height = containerHeight + 'px';
673
- } else {
674
- this.container.style.maxWidth = containerWidth + 'px';
675
- this.container.style.height = containerWidth / imageAspectRatio + 'px';
676
- }
671
+ this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
672
+ this.canvas.style.width = this.container.offsetWidth + 'px';
673
+ this.canvas.height = this.container.offsetWidth / imageAspectRatio * this.devicePixelRatio;
674
+ this.canvas.style.height = this.container.offsetWidth / imageAspectRatio + 'px';
677
675
  }
678
676
  }, {
679
677
  key: "onResizedImageLoad",
@@ -698,12 +696,23 @@ var CI360Viewer = /*#__PURE__*/function () {
698
696
  this.update();
699
697
  }
700
698
  }
699
+ }, {
700
+ key: "showImageInfo",
701
+ value: function showImageInfo(ctx) {
702
+ ctx.font = "".concat(this.fullscreenView ? 28 : 14, "px serif");
703
+ ctx.fillStyle = this.info === 'white' ? '#FFF' : '#000';
704
+ var imageDimension = "image-dimension: ".concat(this.container.offsetWidth, "x").concat(this.container.offsetHeight, "px");
705
+ var currentXImage = 'active-index-x: ' + this.activeImageX;
706
+ var currentYImage = 'active-index-y: ' + this.activeImageY;
707
+ var imageIndex = [currentXImage, currentYImage].join(' | ');
708
+ ctx.fillText(imageDimension, 20, this.container.offsetHeight - 35);
709
+ ctx.fillText(imageIndex, 20, this.container.offsetHeight - 10);
710
+ }
701
711
  }, {
702
712
  key: "requestResizedImages",
703
713
  value: function requestResizedImages() {
704
714
  var responsive = this.ciParams.ciToken;
705
715
  var firstImage = this.imagesX[0];
706
- this.updateContainerSize(firstImage);
707
716
  this.update();
708
717
  this.speedFactor = (0, _utils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
709
718
  var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
@@ -726,10 +735,7 @@ var CI360Viewer = /*#__PURE__*/function () {
726
735
 
727
736
  var ctx = this.canvas.getContext("2d");
728
737
  ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
729
- this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
730
- this.canvas.style.width = this.container.offsetWidth + 'px';
731
- this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
732
- this.canvas.style.height = this.container.offsetHeight + 'px';
738
+ this.updateContainerAndCanvasSize(image);
733
739
 
734
740
  if (this.fullscreenView) {
735
741
  var _contain = (0, _utils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
@@ -743,9 +749,17 @@ var CI360Viewer = /*#__PURE__*/function () {
743
749
  if (this.mouseTracked) {
744
750
  this.updateImageScale(ctx);
745
751
  } else {
752
+ if (this.hotspotConfig && !this.autoplay) {
753
+ (0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
754
+ }
755
+
746
756
  ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
747
757
  }
748
758
  }
759
+
760
+ if (this.info) {
761
+ this.showImageInfo(ctx);
762
+ }
749
763
  }
750
764
  }, {
751
765
  key: "updateImageScale",
@@ -798,6 +812,7 @@ var CI360Viewer = /*#__PURE__*/function () {
798
812
  x: offsetX,
799
813
  y: offsetY
800
814
  };
815
+ this.addCloseFullscreenView();
801
816
  ctx.drawImage(image, offsetX, offsetY, width, height);
802
817
  } else {
803
818
  this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
@@ -807,8 +822,8 @@ var CI360Viewer = /*#__PURE__*/function () {
807
822
  ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
808
823
  }
809
824
 
810
- if (this.fullscreenView) {
811
- this.addCloseFullscreenView();
825
+ if (this.info) {
826
+ this.showImageInfo(ctx);
812
827
  }
813
828
 
814
829
  if (this.magnifier) {
@@ -816,7 +831,7 @@ var CI360Viewer = /*#__PURE__*/function () {
816
831
  }
817
832
 
818
833
  if (this.boxShadow && !this.fullscreenView) {
819
- (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
834
+ this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
820
835
  }
821
836
 
822
837
  if (this.bottomCircle && !this.fullscreenView) {
@@ -826,6 +841,10 @@ var CI360Viewer = /*#__PURE__*/function () {
826
841
  if (this.fullscreen && !this.fullscreenView) {
827
842
  this.addFullscreenIcon();
828
843
  }
844
+
845
+ if (this.hotspotConfig && !this.autoplay) {
846
+ (0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
847
+ }
829
848
  }
830
849
  }, {
831
850
  key: "onAllImagesLoaded",
@@ -892,7 +911,7 @@ var CI360Viewer = /*#__PURE__*/function () {
892
911
  event.stopPropagation();
893
912
  if (this.mouseTracked) this.togglePointerZoom();
894
913
  var fullscreenContainer = (0, _utils.createFullscreenModal)(this.container);
895
- new CI360Viewer(fullscreenContainer, true);
914
+ new CI360Viewer(fullscreenContainer, true, this.hotspotConfig);
896
915
  }
897
916
  }, {
898
917
  key: "setFullscreenEvents",
@@ -1214,9 +1233,10 @@ var CI360Viewer = /*#__PURE__*/function () {
1214
1233
  controlReverse = _get360ViewProps.controlReverse,
1215
1234
  hide360Logo = _get360ViewProps.hide360Logo,
1216
1235
  logoSrc = _get360ViewProps.logoSrc,
1217
- containerWidth = _get360ViewProps.containerWidth,
1218
- containerHeight = _get360ViewProps.containerHeight,
1219
- pointerZoom = _get360ViewProps.pointerZoom;
1236
+ pointerZoom = _get360ViewProps.pointerZoom,
1237
+ ratio = _get360ViewProps.ratio,
1238
+ _get360ViewProps$imag = _get360ViewProps.imageInfo,
1239
+ imageInfo = _get360ViewProps$imag === void 0 ? 'black' : _get360ViewProps$imag;
1220
1240
 
1221
1241
  var ciParams = {
1222
1242
  ciToken: ciToken,
@@ -1252,17 +1272,17 @@ var CI360Viewer = /*#__PURE__*/function () {
1252
1272
  this.lazySelector = lazySelector;
1253
1273
  this.spinReverse = spinReverse;
1254
1274
  this.controlReverse = controlReverse;
1255
- this.dragSpeed = Math.max(magnifier, 50);
1275
+ this.dragSpeed = Math.max(dragSpeed, 50);
1256
1276
  this.autoplaySpeed = this.speed * 36 / this.amountX;
1257
1277
  this.stopAtEdges = stopAtEdges;
1258
1278
  this.hide360Logo = hide360Logo;
1259
1279
  this.logoSrc = logoSrc;
1260
1280
  this.ciParams = ciParams;
1261
1281
  this.apiVersion = apiVersion;
1262
- this.containerWidth = containerWidth;
1263
- this.containerHeight = containerHeight;
1264
1282
  this.pointerZoom = pointerZoom > 1 ? Math.min(pointerZoom, 3) : 0;
1265
1283
  this.keysReverse = keysReverse;
1284
+ this.info = imageInfo;
1285
+ this.ratio = ratio && JSON.parse(ratio);
1266
1286
 
1267
1287
  if (reload) {
1268
1288
  new CI360Viewer(this.container);
@@ -1270,6 +1290,37 @@ var CI360Viewer = /*#__PURE__*/function () {
1270
1290
  }
1271
1291
 
1272
1292
  if (update) {
1293
+ (0, _utils.removeChildFromParent)(this.innerBox, this.iconsContainer);
1294
+ (0, _utils.removeChildFromParent)(this.innerBox, this.boxShadowEl);
1295
+ (0, _utils.removeChildFromParent)(this.innerBox, this.view360Icon);
1296
+ this.remove360ViewCircleIcon();
1297
+ this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
1298
+
1299
+ if (!this.hide360Logo && !this.lazyload && this.logoSrc) {
1300
+ this.add360ViewIcon();
1301
+ (0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
1302
+ }
1303
+
1304
+ if (this.magnifier) {
1305
+ this.addMagnifier();
1306
+ }
1307
+
1308
+ if (this.info) {
1309
+ this.showImageInfo(ctx);
1310
+ }
1311
+
1312
+ if (this.bottomCircle && !this.fullscreenView) {
1313
+ this.add360ViewCircleIcon();
1314
+ }
1315
+
1316
+ if (this.fullscreen && !this.fullscreenView) {
1317
+ this.addFullscreenIcon();
1318
+ }
1319
+
1320
+ if (this.boxShadow && !this.fullscreenView) {
1321
+ this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
1322
+ }
1323
+
1273
1324
  this.onAllImagesLoaded();
1274
1325
  return;
1275
1326
  }
@@ -1278,6 +1329,11 @@ var CI360Viewer = /*#__PURE__*/function () {
1278
1329
  this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
1279
1330
  this.canvas = (0, _utils.createCanvas)(this.innerBox);
1280
1331
  this.loader = (0, _utils.createLoader)(this.innerBox);
1332
+
1333
+ if (this.hotspotConfig && !this.fullscreenView) {
1334
+ (0, _utils.createHotspots)(container, this.hotspotConfig);
1335
+ }
1336
+
1281
1337
  (0, _utils.applyStylesToContainer)(this.container);
1282
1338
  this.srcXConfig = {
1283
1339
  folder: folder,
@@ -1347,7 +1403,7 @@ var CI360Viewer = /*#__PURE__*/function () {
1347
1403
  if (_this6.lazyloadX || _this6.lazyloadY) return initLazyload(image, orientation);
1348
1404
 
1349
1405
  if (isFirstImageLoaded) {
1350
- _this6.updateContainerSize(image);
1406
+ _this6.updateContainerAndCanvasSize(image);
1351
1407
 
1352
1408
  _this6.onFirstImageLoaded(image);
1353
1409
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setView360Icon = exports.get360ViewProps = exports.debounce = void 0;
6
+ exports.setView360Icon = exports.get360ViewProps = exports.debounce = exports.attr = void 0;
7
7
 
8
8
  var _constants = require("./constants");
9
9
 
@@ -46,8 +46,8 @@ 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
- containerWidth: parseInt(attr(image, 'width') || attr(image, 'data-width'), 10) || 0,
50
- containerHeight: parseInt(attr(image, 'height') || attr(image, 'data-height'), 10) || 0
49
+ ratio: attr(image, 'ratio') || attr(image, 'data-ratio') || null,
50
+ imageInfo: attr(image, 'info') || attr(image, 'data-info') || isTrue(image, 'info')
51
51
  };
52
52
  };
53
53
 
@@ -63,6 +63,8 @@ var attr = function attr(element, attribute) {
63
63
  return element.getAttribute(attribute);
64
64
  };
65
65
 
66
+ exports.attr = attr;
67
+
66
68
  var setView360Icon = function setView360Icon(view360Icon, logoSrc) {
67
69
  view360Icon.style.background = "rgba(255,255,255,0.8) url('".concat(logoSrc, "') 50% 50% / contain no-repeat");
68
70
  };
package/dist/index.js CHANGED
@@ -10,11 +10,16 @@ require("core-js/features/array/includes");
10
10
 
11
11
  var _ci = _interopRequireDefault(require("./ci360.service"));
12
12
 
13
+ var _ci2 = require("./ci360.utils");
14
+
13
15
  function init() {
14
16
  var viewers = [];
15
17
  var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
18
+ var hotspotsConfigs = window.CI360.hotspots || {};
16
19
  [].slice.call(view360Array).forEach(function (container) {
17
- viewers.push(new _ci.default(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));
18
23
  });
19
24
  window.CI360._viewers = viewers;
20
25
  }