js-cloudimage-360-view 3.1.1 → 3.2.1

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,10 @@ Types of changes:
25
25
  - ...
26
26
 
27
27
  -------------
28
+ ## 3.2.0 - 2023-09-25
29
+ ### Added
30
+ - Possibility to add hotspots dynamically
31
+
28
32
  ## 3.1.1 - 2023-04-19
29
33
  ### Fixed
30
34
  - Remove CVE vulnerabilities
package/README.md CHANGED
@@ -12,11 +12,6 @@
12
12
  alt="cloudimage logo"
13
13
  src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
14
14
  </a>
15
- <!-- <a href="https://www.cloudimage.io/#gh-dark-mode-only">
16
- <img
17
- alt="cloudimage logo"
18
- src="https://scaleflex.cloudimg.io/v7/cloudimage.io/cloudimage-logo-light.png?vh=b798ab&w=350">
19
- </a> -->
20
15
  </p>
21
16
 
22
17
  <h1 align="center">
@@ -855,7 +855,7 @@ var CI360Viewer = /*#__PURE__*/function () {
855
855
  }
856
856
  }, {
857
857
  key: "updateView",
858
- value: function updateView(forceUpdate, viewers) {
858
+ value: function updateView(forceUpdate, viewers, hotspotConfigs) {
859
859
  var _this5 = this;
860
860
  var container = this.container;
861
861
  var imageProps = (0, _ci.get360ViewProps)(container);
@@ -877,7 +877,7 @@ var CI360Viewer = /*#__PURE__*/function () {
877
877
  container.style.cursor = 'default';
878
878
  container.setAttribute('draggable', 'false');
879
879
  this.stop();
880
- this.init(container, true);
880
+ this.init(container, true, hotspotConfigs);
881
881
  }
882
882
  }, {
883
883
  key: "destroy",
@@ -1079,6 +1079,7 @@ var CI360Viewer = /*#__PURE__*/function () {
1079
1079
  value: function init(container) {
1080
1080
  var _this7 = this;
1081
1081
  var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1082
+ var hotspotsConfigs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1082
1083
  var _get360ViewProps = (0, _ci.get360ViewProps)(container),
1083
1084
  folder = _get360ViewProps.folder,
1084
1085
  apiVersion = _get360ViewProps.apiVersion,
@@ -1190,6 +1191,10 @@ var CI360Viewer = /*#__PURE__*/function () {
1190
1191
  if (this.boxShadow && !this.fullscreenView) {
1191
1192
  this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
1192
1193
  }
1194
+ if (hotspotsConfigs && !this.fullscreenView) {
1195
+ this.hotspotsConfigs = (0, _utils.generateHotspotsConfigs)(hotspotsConfigs);
1196
+ (0, _utils.createHotspots)(container, this.hotspotsConfigs);
1197
+ }
1193
1198
  return this.onAllImagesLoaded();
1194
1199
  }
1195
1200
  this.innerBox = (0, _utils.createInnerBox)(this.container);
package/dist/index.js CHANGED
@@ -56,11 +56,19 @@ function add(id) {
56
56
  function update() {
57
57
  var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
58
58
  var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
59
+ var hotspotConfigs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
59
60
  if (id) {
60
61
  var view = window.CI360._viewers.filter(function (viewer) {
61
62
  return viewer.id === id;
62
63
  })[0];
63
- view.updateView(forceUpdate, window.CI360._viewers);
64
+ if (hotspotConfigs) {
65
+ var view360Array = document.querySelectorAll('.cloudimage-360');
66
+ var _container2 = Array.from(view360Array).find(function (view) {
67
+ return view.id === id;
68
+ });
69
+ _container2.setAttribute('data-hotspots', true);
70
+ }
71
+ view.updateView(forceUpdate, window.CI360._viewers, hotspotConfigs);
64
72
  } else {
65
73
  window.CI360._viewers.forEach(function (viewer) {
66
74
  viewer.updateView(forceUpdate, window.CI360._viewers);
@@ -72,11 +80,14 @@ function isNoViewers() {
72
80
  }
73
81
  function addHotspots(instanceId, config) {
74
82
  var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
75
- var container = Array.from(view360Array).find(function (view) {
83
+ var notInitializedContainer = Array.from(view360Array).find(function (view) {
76
84
  return view.id === instanceId;
77
85
  });
78
- if (container) {
79
- window.CI360._viewers.push(new _ci.default(container, false, config));
86
+ if (notInitializedContainer) {
87
+ container.setAttribute('data-hotspots', true);
88
+ return window.CI360._viewers.push(new _ci.default(container, false, config));
89
+ } else {
90
+ update(instanceId, false, config);
80
91
  }
81
92
  }
82
93
  window.CI360 = window.CI360 || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-cloudimage-360-view",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "main": "dist/index.js",
5
5
  "description": "",
6
6
  "author": "scaleflex",