js-cloudimage-360-view 3.0.0-beta.2 → 3.0.2

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 (95) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/LICENSE +13 -1
  3. package/README.md +404 -145
  4. package/dist/ci360.service.js +878 -1163
  5. package/dist/ci360.utils.js +28 -204
  6. package/dist/constants/auto-play-behavior.js +13 -0
  7. package/dist/constants/falsy-values.js +8 -0
  8. package/dist/constants/index.js +43 -0
  9. package/dist/constants/orientations.js +12 -0
  10. package/dist/constants/props-require-reload.js +21 -0
  11. package/dist/constants/regex.js +10 -0
  12. package/dist/index.js +73 -12
  13. package/dist/static/css/hotspots.css +222 -0
  14. package/dist/static/css/style.css +116 -7
  15. package/dist/utils/auto-play/get-speed-factor.js +14 -0
  16. package/dist/utils/auto-play/is-completed-one-cycle.js +32 -0
  17. package/dist/utils/auto-play/loop.js +67 -0
  18. package/dist/utils/class-names/add-class.js +18 -0
  19. package/dist/utils/class-names/remove-class.js +16 -0
  20. package/dist/utils/container-elements/apply-styles-to-container.js +16 -0
  21. package/dist/utils/container-elements/create-360-view-circle-icon.js +16 -0
  22. package/dist/utils/container-elements/create-360-view-icon.js +15 -0
  23. package/dist/utils/container-elements/create-box-shadow.js +16 -0
  24. package/dist/utils/container-elements/create-canvas.js +16 -0
  25. package/dist/utils/container-elements/create-close-fullscreen-icon.js +14 -0
  26. package/dist/utils/container-elements/create-fullscreen-icon.js +14 -0
  27. package/dist/utils/container-elements/create-fullscreen-modal.js +20 -0
  28. package/dist/utils/container-elements/create-icons-container.js +15 -0
  29. package/dist/utils/container-elements/create-inner-box.js +15 -0
  30. package/dist/utils/container-elements/create-loader.js +15 -0
  31. package/dist/utils/container-elements/create-magnifier-icon.js +14 -0
  32. package/dist/utils/container-elements/index.js +109 -0
  33. package/dist/utils/container-elements/remove-child-from-parent.js +16 -0
  34. package/dist/utils/controls/get-item-skipped.js +13 -0
  35. package/dist/utils/controls/init-controls.js +77 -0
  36. package/dist/utils/hotspots/attach-events/hide-popup.js +15 -0
  37. package/dist/utils/hotspots/attach-events/show-popup.js +14 -0
  38. package/dist/utils/hotspots/configs-error-handler.js +27 -0
  39. package/dist/utils/hotspots/create-popper-instace.js +32 -0
  40. package/dist/utils/hotspots/elements/create-carousel-dot.js +26 -0
  41. package/dist/utils/hotspots/elements/create-carousel-image.js +22 -0
  42. package/dist/utils/hotspots/elements/create-hotspot-icon.js +66 -0
  43. package/dist/utils/hotspots/elements/create-hotspot-popup-link.js +23 -0
  44. package/dist/utils/hotspots/elements/create-hotspots.js +25 -0
  45. package/dist/utils/hotspots/elements/create-images-carousel.js +27 -0
  46. package/dist/utils/hotspots/elements/create-modal-description.js +15 -0
  47. package/dist/utils/hotspots/elements/create-modal-title.js +15 -0
  48. package/dist/utils/hotspots/elements/create-model-elements.js +66 -0
  49. package/dist/utils/hotspots/elements/create-popup-arrow.js +16 -0
  50. package/dist/utils/hotspots/elements/create-popup.js +67 -0
  51. package/dist/utils/hotspots/elements/create-read-more-btn.js +17 -0
  52. package/dist/utils/hotspots/fill-empty-coord-with-previous.js +26 -0
  53. package/dist/utils/hotspots/generate-hotspots-configs.js +58 -0
  54. package/dist/utils/hotspots/generate-popup-config.js +29 -0
  55. package/dist/utils/hotspots/get-hotspot-icon.js +14 -0
  56. package/dist/utils/hotspots/get-hotspot-orientation.js +21 -0
  57. package/dist/utils/hotspots/get-hotspot-popup-node.js +14 -0
  58. package/dist/utils/hotspots/get-popup-node.js +14 -0
  59. package/dist/utils/hotspots/hide-hotspot-icon.js +13 -0
  60. package/dist/utils/hotspots/hide-hotspots-icons.js +18 -0
  61. package/dist/utils/hotspots/is-mouse-on-hotspot.js +14 -0
  62. package/dist/utils/hotspots/prepare-hotspots-positions.js +28 -0
  63. package/dist/utils/hotspots/set-current-slide.js +23 -0
  64. package/dist/utils/hotspots/toggle-popup-events.js +23 -0
  65. package/dist/utils/hotspots/update-hotspot-icon-position.js +21 -0
  66. package/dist/utils/hotspots/update-hotspots.js +48 -0
  67. package/dist/utils/image-src/generate-images-path.js +42 -0
  68. package/dist/utils/image-src/is-props-change-require-reload.js +23 -0
  69. package/dist/utils/index.js +237 -0
  70. package/dist/utils/load-images/images-from-folder/prepare-images-from-folder.js +34 -0
  71. package/dist/utils/load-images/images-from-list/prepare-images-from-list.js +35 -0
  72. package/dist/utils/load-images/lazyload/init-lazyload.js +49 -0
  73. package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-folder.js +18 -0
  74. package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-list.js +29 -0
  75. package/dist/utils/load-images/load-image-as-promise.js +54 -0
  76. package/dist/utils/load-images/load-images-relative-to-container-size.js +58 -0
  77. package/dist/utils/load-images/load-original-images.js +58 -0
  78. package/dist/utils/load-images/pad.js +14 -0
  79. package/dist/utils/load-images/preload-images.js +35 -0
  80. package/dist/utils/load-images/preload-original-images.js +35 -0
  81. package/dist/utils/magnify/get-current-original-image.js +29 -0
  82. package/dist/utils/magnify/get-cursor-position.js +24 -0
  83. package/dist/utils/magnify/magnify.js +54 -0
  84. package/dist/utils/magnify/move-magnifier.js +47 -0
  85. package/dist/utils/responsive/contain.js +11 -0
  86. package/dist/utils/responsive/fit.js +33 -0
  87. package/dist/utils/responsive/get-image-aspect-ratio.js +39 -0
  88. package/dist/utils/responsive/get-responsive-width-of-container.js +14 -0
  89. package/dist/utils/responsive/get-size-according-to-pixel-ratio.js +17 -0
  90. package/dist/utils/responsive/get-size-limit.js +14 -0
  91. package/dist/utils/spin-y/get-moving-direction.js +21 -0
  92. package/dist/utils/zoom/generate-zoom-in-steps.js +20 -0
  93. package/dist/utils/zoom/generate-zoom-out-steps.js +20 -0
  94. package/package.json +13 -8
  95. package/dist/ci360.constants.js +0 -36
@@ -1,155 +1,316 @@
1
- 'use strict';
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
4
 
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
8
+ exports.default = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
6
15
 
7
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
16
+ var _ci = require("./ci360.utils");
8
17
 
9
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
18
+ var _constants = require("./constants/");
10
19
 
11
- var _ci = require('./ci360.utils');
20
+ require("./static/css/style.css");
12
21
 
13
- var _ci2 = require('./ci360.constants');
22
+ require("./static/css/hotspots.css");
14
23
 
15
- require('./static/css/style.css');
24
+ var _utils = require("./utils");
16
25
 
17
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
26
+ var _togglePopupEvents = require("./utils/hotspots/toggle-popup-events");
18
27
 
19
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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; }
20
29
 
21
- var CI360Viewer = function () {
22
- function CI360Viewer(container, fullscreen, ratio) {
23
- _classCallCheck(this, CI360Viewer);
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; }
24
31
 
32
+ var CI360Viewer = /*#__PURE__*/function () {
33
+ function CI360Viewer(container, fullscreen, hotspotsConfigs) {
34
+ (0, _classCallCheck2.default)(this, CI360Viewer);
25
35
  this.container = container;
26
- this.movementStart = { x: 0, y: 0 };
36
+ this.movementStart = {
37
+ x: 0,
38
+ y: 0
39
+ };
27
40
  this.isStartSpin = false;
28
- this.movingDirection = _ci2.ORIENTATIONS.CENTER;
41
+ this.movingDirection = _constants.ORIENTATIONS.CENTER;
29
42
  this.isClicked = false;
30
43
  this.loadedImagesX = 0;
31
44
  this.loadedImagesY = 0;
32
45
  this.imagesLoaded = false;
33
46
  this.reversed = false;
34
47
  this.fullscreenView = !!fullscreen;
35
- this.ratio = ratio;
36
48
  this.imagesX = [];
37
49
  this.imagesY = [];
38
- this.resizedImagesX = [];
39
- this.resizedImagesY = [];
40
50
  this.originalImagesX = [];
41
51
  this.originalImagesY = [];
52
+ this.resizedImagesX = [];
53
+ this.resizedImagesY = [];
42
54
  this.devicePixelRatio = Math.round(window.devicePixelRatio || 1);
43
55
  this.isMobile = !!('ontouchstart' in window || navigator.msMaxTouchPoints);
44
56
  this.id = container.id;
45
- this.init(container);
46
- this.clickedToZoom = false;
57
+ this.hotspotsConfigs = hotspotsConfigs && (0, _utils.generateHotspotsConfigs)(hotspotsConfigs);
47
58
  this.isMagnifyOpen = false;
59
+ this.isDragged = false;
48
60
  this.startPointerZoom = false;
49
61
  this.zoomIntensity = 0;
50
62
  this.mouseTracked = false;
51
- this.intialPositions = { x: 0, y: 0 };
52
- this.pointerCurrentPosition = { x: 0, y: 0 };
53
- this.startPinchZoom = false;
54
- this.prevDistanceBetweenFingers = 0;
63
+ this.intialPositions = {
64
+ x: 0,
65
+ y: 0
66
+ };
67
+ this.pointerCurrentPosition = {
68
+ x: 0,
69
+ y: 0
70
+ };
71
+ this.isStartedLoadOriginalImages = false;
72
+ this.init(container);
55
73
  }
56
74
 
57
- _createClass(CI360Viewer, [{
58
- key: 'mouseDown',
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
+ }, {
88
+ key: "mouseDown",
59
89
  value: function mouseDown(event) {
60
- event.preventDefault();
61
-
90
+ if (!this.imagesLoaded) return;
91
+ var isMouseOnHotspotElement = (0, _utils.isMouseOnHotspot)();
62
92
  var pageX = event.pageX,
63
93
  pageY = event.pageY;
64
-
65
-
66
- if (!this.imagesLoaded) return;
67
-
68
94
  this.hideInitialIcons();
69
95
 
70
96
  if (this.autoplay || this.loopTimeoutId) {
71
97
  this.stop();
72
98
  this.autoplay = false;
99
+ this.isZoomReady = true;
73
100
  }
74
101
 
75
- this.intialPositions = { x: pageX, y: pageY };
76
- this.movementStart = { x: pageX, y: pageY };
102
+ this.intialPositions = {
103
+ x: pageX,
104
+ y: pageY
105
+ };
106
+ this.movementStart = {
107
+ x: pageX,
108
+ y: pageY
109
+ };
77
110
  this.isClicked = true;
78
- this.clickedToZoom = true;
79
- this.container.style.cursor = 'grabbing';
111
+ this.isDragged = false;
112
+
113
+ if (this.hotspotsConfigs) {
114
+ (0, _togglePopupEvents.togglePopupEvents)(this.hotspotsConfigs, event, true);
115
+ }
116
+
117
+ if (isMouseOnHotspotElement) {
118
+ this.isClicked = false;
119
+ }
120
+
121
+ if (this.hotspotsConfigs) {
122
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection);
123
+ }
80
124
  }
81
125
  }, {
82
- key: 'mouseUp',
126
+ key: "mouseUp",
83
127
  value: function mouseUp() {
84
- if (!this.imagesLoaded || !this.isClicked) return;
128
+ var _this = this;
85
129
 
86
- this.movementStart = { x: 0, y: 0 };
130
+ if (!this.imagesLoaded || !this.isClicked) return;
131
+ this.movementStart = {
132
+ x: 0,
133
+ y: 0
134
+ };
87
135
  this.isStartSpin = false;
88
136
  this.isClicked = false;
89
- this.container.style.cursor = 'grab';
90
137
 
91
- if (this.bottomCircle && !this.zoomIntensity) {
138
+ if (this.bottomCircle && !this.mouseTracked) {
92
139
  this.show360ViewCircleIcon();
93
140
  }
141
+
142
+ if (this.hotspotsConfigs) {
143
+ (0, _togglePopupEvents.togglePopupEvents)(this.hotspotsConfigs);
144
+ }
145
+
146
+ if (this.pointerZoom && !this.fullscreenView) {
147
+ setTimeout(function () {
148
+ _this.isZoomReady = true;
149
+ }, 50);
150
+
151
+ if (this.mouseTracked) {
152
+ this.container.style.cursor = 'zoom-out';
153
+ } else {
154
+ this.container.style.cursor = 'zoom-in';
155
+ }
156
+ } else {
157
+ this.container.style.cursor = 'grab';
158
+ }
159
+ }
160
+ }, {
161
+ key: "mouseClick",
162
+ value: function mouseClick(event) {
163
+ if (!this.pointerZoom || this.fullscreenView) return;
164
+ this.setCursorPosition(event);
165
+ this.hideInitialIcons();
166
+
167
+ if (!this.isStartedLoadOriginalImages && !this.isDragged && this.isZoomReady) {
168
+ this.prepareOriginalImages(event);
169
+ }
170
+
171
+ if (this.isAllOriginalImagesLoaded && !this.isDragged && this.isZoomReady) {
172
+ this.togglePointerZoom(event);
173
+ }
174
+
175
+ ;
94
176
  }
95
177
  }, {
96
- key: 'mouseMove',
178
+ key: "mouseMove",
97
179
  value: function mouseMove(event) {
98
180
  if (!this.imagesLoaded) return;
99
-
100
181
  var pageX = event.pageX,
101
182
  pageY = event.pageY;
102
183
 
103
-
104
184
  if (this.mouseTracked) {
105
185
  this.setCursorPosition(event);
186
+
187
+ if (!this.isClicked) {
188
+ this.update();
189
+ }
106
190
  }
107
191
 
108
192
  if (this.isClicked) {
109
- var nextPositions = { x: pageX, y: pageY };
110
-
111
- this.updateMovingDirection(this.intialPositions, nextPositions);
193
+ var nextPositions = {
194
+ x: pageX,
195
+ y: pageY
196
+ };
197
+ this.container.style.cursor = 'grabbing';
198
+ this.isDragged = true;
199
+ this.movingDirection = (0, _utils.getMovingDirection)(this.isStartSpin, this.allowSpinY, this.intialPositions, nextPositions, this.movingDirection);
112
200
  this.onMoveHandler(event);
113
- } else if (this.zoomIntensity) {
114
- this.update();
115
201
  }
116
202
  }
117
203
  }, {
118
- key: 'updateMovingDirection',
119
- value: function updateMovingDirection(prevPosition, nextPositions) {
120
- if (this.isStartSpin) return;
121
-
122
- var differenceInPositionX = Math.abs(prevPosition.x - nextPositions.x);
123
- var differenceInPositionY = Math.abs(prevPosition.y - nextPositions.y);
124
- var sensitivity = 10;
204
+ key: "mouseLeave",
205
+ value: function mouseLeave() {
206
+ if (!this.imagesLoaded) return;
125
207
 
126
- if (differenceInPositionX > sensitivity) this.movingDirection = _ci2.ORIENTATIONS.X;
208
+ if (this.pointerZoom && this.mouseTracked) {
209
+ this.togglePointerZoom();
210
+ }
127
211
 
128
- if (differenceInPositionY > sensitivity && this.allowSpinY) this.movingDirection = _ci2.ORIENTATIONS.Y;
212
+ if (this.isMagnifyOpen) {
213
+ this.closeMagnifier();
214
+ }
129
215
  }
130
216
  }, {
131
- key: 'mouseScroll',
132
- value: function mouseScroll(event) {
133
- if (this.disablePointerZoom || this.isMagnifyOpen) return;
217
+ key: "togglePointerZoom",
218
+ value: function togglePointerZoom() {
219
+ var _this2 = this;
220
+
221
+ if (this.autoplay || this.loopTimeoutId) {
222
+ this.stop();
223
+ this.autoplay = false;
224
+ }
225
+
226
+ if (this.mouseTracked) {
227
+ var zoomSteps = (0, _utils.generateZoomOutSteps)(this.pointerZoom);
228
+ this.container.style.cursor = 'zoom-in';
229
+ zoomSteps.forEach(function (step, index) {
230
+ setTimeout(function () {
231
+ _this2.zoomIntensity = step;
232
+
233
+ _this2.update();
234
+
235
+ var isReachedIntialScale = index === zoomSteps.length - 1;
236
+
237
+ if (isReachedIntialScale) {
238
+ _this2.mouseTracked = false;
239
+
240
+ _this2.update();
241
+ }
242
+
243
+ ;
244
+ }, (_this2.pointerZoom - step) * 200);
245
+ });
246
+ } else {
247
+ if (this.bottomCircle) this.hide360ViewCircleIcon();
248
+
249
+ var _zoomSteps = (0, _utils.generateZoomInSteps)(this.pointerZoom);
250
+
251
+ if (this.hotspotsConfigs) {
252
+ (0, _utils.hideHotspotsIcons)();
253
+ }
254
+
255
+ _zoomSteps.forEach(function (step) {
256
+ setTimeout(function () {
257
+ _this2.zoomIntensity = step;
134
258
 
135
- var isClickedToZoom = this.toStartPointerZoom === _ci2.TO_START_POINTER_ZOOM.CLICK_TO_START && this.clickedToZoom;
136
- var isScrolledToZoom = this.toStartPointerZoom === _ci2.TO_START_POINTER_ZOOM.SCROLL_TO_START;
259
+ _this2.update();
260
+ }, step * 200);
261
+ });
137
262
 
138
- if (isClickedToZoom || isScrolledToZoom) {
139
- this.initMouseScrollZoom(event);
263
+ this.mouseTracked = true;
264
+ this.container.style.cursor = 'zoom-out';
140
265
  }
141
266
  }
142
267
  }, {
143
- key: 'touchStart',
144
- value: function touchStart(event) {
145
- if (!this.imagesLoaded) return;
268
+ key: "onOriginalImageLoad",
269
+ value: function onOriginalImageLoad(orientation, event, image, index) {
270
+ if (orientation === _constants.ORIENTATIONS.Y) {
271
+ this.originalImagesY[index] = image;
272
+ } else {
273
+ this.originalImagesX[index] = image;
274
+ }
146
275
 
147
- var isPinchZoom = !this.disablePinchZoom && (0, _ci.isTwoFingers)(event) && !this.isMagnifyOpen;
276
+ var loadedOriginalXImages = this.originalImagesX.filter(function (image) {
277
+ return image;
278
+ });
279
+ var loadedOriginalYImages = this.originalImagesY.filter(function (image) {
280
+ return image;
281
+ });
282
+ var totalAmount = this.amountX + this.amountY;
283
+ var totalLoadedImages = loadedOriginalXImages.length + loadedOriginalYImages.length;
284
+ var isAllImagesLoaded = loadedOriginalXImages.length + loadedOriginalYImages.length === this.amountX + this.amountY;
285
+ var percentage = Math.round(totalLoadedImages / totalAmount * 100);
286
+ this.updatePercentageInLoader(percentage);
148
287
 
149
- if (isPinchZoom) {
150
- this.initAndSetPinchZoom(event);
151
- };
288
+ if (isAllImagesLoaded) {
289
+ this.removeLoader();
290
+ this.togglePointerZoom(event);
291
+ this.mouseTracked = true;
292
+ this.isAllOriginalImagesLoaded = true;
293
+ }
294
+ }
295
+ }, {
296
+ key: "prepareOriginalImages",
297
+ value: function prepareOriginalImages(event) {
298
+ var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
299
+ this.isStartedLoadOriginalImages = true;
300
+ this.loader = (0, _utils.createLoader)(this.innerBox);
301
+ this.container.style.cursor = 'wait';
302
+ (0, _utils.preloadOriginalImages)(this.srcXConfig, srcX, this.onOriginalImageLoad.bind(this, _constants.ORIENTATIONS.X, event));
152
303
 
304
+ if (this.allowSpinY) {
305
+ var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
306
+ (0, _utils.preloadOriginalImages)(this.srcYConfig, srcY, this.onOriginalImageLoad.bind(this, _constants.ORIENTATIONS.Y, event));
307
+ }
308
+ }
309
+ }, {
310
+ key: "touchStart",
311
+ value: function touchStart(event) {
312
+ if (!this.imagesLoaded) return;
313
+ var isMouseOnHotspotElement = (0, _utils.isMouseOnHotspot)();
153
314
  this.hideInitialIcons();
154
315
 
155
316
  if (this.autoplay || this.loopTimeoutId) {
@@ -157,48 +318,66 @@ var CI360Viewer = function () {
157
318
  this.autoplay = false;
158
319
  }
159
320
 
160
- this.intialPositions = { x: event.touches[0].clientX, y: event.touches[0].clientY };
161
- this.movementStart = { x: event.touches[0].clientX, y: event.touches[0].clientY };
321
+ this.intialPositions = {
322
+ x: event.touches[0].clientX,
323
+ y: event.touches[0].clientY
324
+ };
325
+ this.movementStart = {
326
+ x: event.touches[0].clientX,
327
+ y: event.touches[0].clientY
328
+ };
162
329
  this.isClicked = true;
330
+
331
+ if (isMouseOnHotspotElement) {
332
+ this.isClicked = false;
333
+ }
163
334
  }
164
335
  }, {
165
- key: 'touchEnd',
336
+ key: "touchEnd",
166
337
  value: function touchEnd() {
167
338
  if (!this.imagesLoaded) return;
168
-
169
- if (this.zoomIntensity) this.resetZoom();
170
-
171
- this.movementStart = { x: 0, y: 0 };
339
+ if (this.bottomCircle) this.show360ViewCircleIcon();
340
+ this.movementStart = {
341
+ x: 0,
342
+ y: 0
343
+ };
172
344
  this.isStartSpin = false;
173
345
  this.isClicked = false;
174
-
175
- if (this.bottomCircle) this.show360ViewCircleIcon();
176
346
  }
177
347
  }, {
178
- key: 'touchMove',
348
+ key: "touchMove",
179
349
  value: function touchMove(event) {
180
350
  if (!this.isClicked || !this.imagesLoaded) return;
181
351
 
182
- if (!this.disablePinchZoom && (0, _ci.isTwoFingers)(event)) {
183
- this.fingersPinchZoom(event);
184
- } else {
185
- var nextPositions = { x: event.touches[0].clientX, y: event.touches[0].clientY };
186
-
187
- this.updateMovingDirection(this.intialPositions, nextPositions);
188
- this.onMoveHandler(event);
352
+ if (event.cancelable) {
353
+ event.preventDefault();
189
354
  }
355
+
356
+ var nextPositions = {
357
+ x: event.touches[0].clientX,
358
+ y: event.touches[0].clientY
359
+ };
360
+ this.movingDirection = (0, _utils.getMovingDirection)(this.isStartSpin, this.allowSpinY, this.intialPositions, nextPositions, this.movingDirection);
361
+ this.onMoveHandler(event);
190
362
  }
191
363
  }, {
192
- key: 'keyDownGeneral',
193
- value: function keyDownGeneral() {
364
+ key: "keyDownGeneral",
365
+ value: function keyDownGeneral(event) {
194
366
  if (!this.imagesLoaded) return;
195
367
 
196
368
  if (this.glass) {
197
369
  this.closeMagnifier();
198
370
  }
371
+
372
+ if (event.keyCode === 27) {
373
+ //ESC
374
+ if (this.mouseTracked) {
375
+ this.togglePointerZoom();
376
+ }
377
+ }
199
378
  }
200
379
  }, {
201
- key: 'hideInitialIcons',
380
+ key: "hideInitialIcons",
202
381
  value: function hideInitialIcons() {
203
382
  if (this.glass) {
204
383
  this.closeMagnifier();
@@ -209,17 +388,7 @@ var CI360Viewer = function () {
209
388
  }
210
389
  }
211
390
  }, {
212
- key: 'initMouseScrollZoom',
213
- value: function initMouseScrollZoom(event) {
214
- if (this.bottomCircle) this.hide360ViewCircleIcon();
215
-
216
- this.hideInitialIcons();
217
- this.mouseTracked = true;
218
- this.setCursorPosition(event);
219
- this.mouseScrollZoom(event);
220
- }
221
- }, {
222
- key: 'setCursorPosition',
391
+ key: "setCursorPosition",
223
392
  value: function setCursorPosition(event) {
224
393
  this.mousePositions = {
225
394
  x: event.clientX,
@@ -227,153 +396,54 @@ var CI360Viewer = function () {
227
396
  };
228
397
  }
229
398
  }, {
230
- key: 'getCursorPositionInCanvas',
399
+ key: "getCursorPositionInCanvas",
231
400
  value: function getCursorPositionInCanvas() {
232
401
  var canvasRect = this.canvas.getBoundingClientRect();
233
-
234
402
  this.pointerCurrentPosition = {
235
403
  x: this.mousePositions.x - canvasRect.left,
236
404
  y: this.mousePositions.y - canvasRect.top
237
405
  };
238
-
239
406
  return this.pointerCurrentPosition;
240
407
  }
241
408
  }, {
242
- key: 'mouseScrollZoom',
243
- value: function mouseScrollZoom(event) {
244
- event.preventDefault();
245
-
246
- if (this.autoplay || this.loopTimeoutId) {
247
- this.stop();
248
- this.autoplay = false;
249
- }
250
-
251
- var zoomFactor = (0, _ci.normalizeZoomFactor)(event, this.pointerZoomFactor);
252
- var maxIntensity = (0, _ci.getMaxZoomIntensity)(this.canvas.width, this.maxScale);
253
- this.startPointerZoom = true;
254
- this.zoomIntensity += event.deltaY * zoomFactor;
255
- this.zoomIntensity = Math.min(Math.max(0, this.zoomIntensity), maxIntensity);
256
-
257
- if (this.zoomIntensity) {
258
- if (this.resetZoomIcon) this.showResetZoomIcon();
259
- } else {
260
- if (this.resetZoomIcon) this.hideResetZoomIcon();
261
-
262
- if (this.bottomCircle) this.show360ViewCircleIcon();
409
+ key: "keyDown",
410
+ value: function keyDown(event) {
411
+ if (!this.imagesLoaded) return;
263
412
 
264
- this.startPointerZoom = false;
265
- this.mouseTracked = false;
413
+ if (this.glass) {
414
+ this.closeMagnifier();
266
415
  }
267
416
 
268
- this.update();
269
- }
270
- }, {
271
- key: 'initAndSetPinchZoom',
272
- value: function initAndSetPinchZoom(event) {
273
- if (this.bottomCircle) this.hide360ViewCircleIcon();
274
-
275
- var _getFingersPosition = this.getFingersPosition(event),
276
- _getFingersPosition2 = _slicedToArray(_getFingersPosition, 2),
277
- fingerOnePosition = _getFingersPosition2[0],
278
- fingerTwoPosition = _getFingersPosition2[1];
279
-
280
- this.prevDistanceBetweenFingers = this.getDistanceBetweenFingers(fingerOnePosition, fingerTwoPosition);
281
- }
282
- }, {
283
- key: 'getDistanceBetweenFingers',
284
- value: function getDistanceBetweenFingers(fingerOne, fingerTwo) {
285
- var xPosition = fingerTwo.x - fingerOne.x;
286
- var yPosition = fingerTwo.y - fingerOne.y;
287
-
288
- return Math.sqrt(Math.pow(xPosition, 2) + Math.pow(yPosition, 2));
289
- }
290
- }, {
291
- key: 'updateAveragePositionBetweenFingers',
292
- value: function updateAveragePositionBetweenFingers(fingerOne, fingerTwo) {
293
- var containerRect = this.canvas.getBoundingClientRect();
294
- var offSetX = containerRect.left;
295
- var offSetY = containerRect.top;
296
-
297
- this.pointerCurrentPosition.x = (fingerOne.x + fingerTwo.x) / 2 - offSetX;
298
-
299
- this.pointerCurrentPosition.y = (fingerOne.y + fingerTwo.y) / 2 - offSetY;
300
- }
301
- }, {
302
- key: 'getFingersPosition',
303
- value: function getFingersPosition(event) {
304
- var p1 = event.targetTouches[0];
305
- var p2 = event.targetTouches[1];
306
-
307
- var fingerOnePosition = { x: p1.clientX, y: p1.clientY };
308
- var fingerTwoPosition = { x: p2.clientX, y: p2.clientY };
309
-
310
- return [fingerOnePosition, fingerTwoPosition];
311
- }
312
- }, {
313
- key: 'fingersPinchZoom',
314
- value: function fingersPinchZoom(event) {
315
- var _getFingersPosition3 = this.getFingersPosition(event),
316
- _getFingersPosition4 = _slicedToArray(_getFingersPosition3, 2),
317
- fingerOnePosition = _getFingersPosition4[0],
318
- fingerTwoPosition = _getFingersPosition4[1];
319
-
320
- var currentDistanceBetweenFingers = this.getDistanceBetweenFingers(fingerOnePosition, fingerTwoPosition);
321
- var zoomFactor = this.pinchZoomFactor * 30;
322
-
323
- var zoomSensitivity = 1.5;
324
- var isZoomIn = currentDistanceBetweenFingers > this.prevDistanceBetweenFingers + zoomSensitivity;
325
- var isZoomOut = currentDistanceBetweenFingers + zoomSensitivity < this.prevDistanceBetweenFingers;
326
- var maxIntensity = (0, _ci.getMaxZoomIntensity)(this.canvas.width, this.maxScale);
327
-
328
- this.startPinchZoom = true;
329
-
330
- this.updateAveragePositionBetweenFingers(fingerOnePosition, fingerTwoPosition);
331
-
332
- if (isZoomIn && this.zoomIntensity <= maxIntensity) {
333
- this.zoomIntensity += zoomFactor;
334
- } else if (isZoomOut && this.zoomIntensity >= zoomFactor) {
335
- this.zoomIntensity -= zoomFactor;
417
+ if (event.keyCode === 37) {
418
+ // left
419
+ this.keysReverse ? this.left() : this.right();
420
+ this.onSpin();
336
421
  }
337
422
 
338
- this.update();
339
- this.prevDistanceBetweenFingers = currentDistanceBetweenFingers;
340
- }
341
- }, {
342
- key: 'resetZoom',
343
- value: function resetZoom() {
344
- this.startPointerZoom = false;
345
- this.startPinchZoom = false;
346
- this.mouseTracked = false;
347
- this.clickedToZoom = false;
348
-
349
- if (this.resetZoomIcon) this.hideResetZoomIcon();
350
-
351
- if (this.zoomIntensity) {
352
- this.zoomIntensity = 0;
353
- this.update();
423
+ if (event.keyCode === 39) {
424
+ // right
425
+ this.keysReverse ? this.right() : this.left();
426
+ this.onSpin();
354
427
  }
355
- }
356
- }, {
357
- key: 'keyDown',
358
- value: function keyDown(event) {
359
- if (!this.imagesLoaded) return;
360
428
 
361
- if (this.glass) {
362
- this.closeMagnifier();
363
- }
429
+ if (this.allowSpinY) {
430
+ event.preventDefault();
364
431
 
365
- if ([37, 39].indexOf(event.keyCode) !== -1) {
366
- if (37 === event.keyCode) {
367
- if (this.reversed) this.left();else this.right();
368
- } else if (39 === event.keyCode) {
369
- if (this.reversed) this.right();else this.left();
432
+ if (event.keyCode === 38) {
433
+ // up
434
+ this.keysReverse ? this.top() : this.bottom();
435
+ this.onSpin();
370
436
  }
371
437
 
372
- this.onSpin();
438
+ if (event.keyCode === 40) {
439
+ // down
440
+ this.keysReverse ? this.bottom() : this.top();
441
+ this.onSpin();
442
+ }
373
443
  }
374
444
  }
375
445
  }, {
376
- key: 'onSpin',
446
+ key: "onSpin",
377
447
  value: function onSpin() {
378
448
  if (this.bottomCircle) {
379
449
  this.hide360ViewCircleIcon();
@@ -389,7 +459,7 @@ var CI360Viewer = function () {
389
459
  }
390
460
  }
391
461
  }, {
392
- key: 'keyUp',
462
+ key: "keyUp",
393
463
  value: function keyUp(event) {
394
464
  if (!this.imagesLoaded) return;
395
465
 
@@ -398,87 +468,12 @@ var CI360Viewer = function () {
398
468
  }
399
469
  }
400
470
  }, {
401
- key: 'onFinishSpin',
471
+ key: "onFinishSpin",
402
472
  value: function onFinishSpin() {
403
473
  if (this.bottomCircle) this.show360ViewCircleIcon();
404
474
  }
405
475
  }, {
406
- key: 'onMoveHandler',
407
- value: function onMoveHandler(event) {
408
- var currentPositionX = this.isMobile ? event.touches[0].clientX : event.pageX;
409
- var currentPositionY = this.isMobile ? event.touches[0].clientY : event.pageY;
410
-
411
- var isMoveRight = currentPositionX - this.movementStart.x >= this.speedFactor;
412
- var isMoveLeft = this.movementStart.x - currentPositionX >= this.speedFactor;
413
- var isMoveTop = this.movementStart.y - currentPositionY >= this.speedFactor;
414
- var isMoveBottom = currentPositionY - this.movementStart.y >= this.speedFactor;
415
-
416
- if (this.bottomCircle) this.hide360ViewCircleIcon();
417
-
418
- if (isMoveRight && this.movingDirection === _ci2.ORIENTATIONS.X) {
419
- this.moveRight(currentPositionX);
420
-
421
- this.isStartSpin = true;
422
- } else if (isMoveLeft && this.movingDirection === _ci2.ORIENTATIONS.X) {
423
- this.moveLeft(currentPositionX);
424
-
425
- this.isStartSpin = true;
426
- } else if (isMoveTop && this.movingDirection === _ci2.ORIENTATIONS.Y) {
427
- this.moveTop(currentPositionY);
428
-
429
- this.isStartSpin = true;
430
- } else if (isMoveBottom && this.movingDirection === _ci2.ORIENTATIONS.Y) {
431
- this.moveBottom(currentPositionY);
432
-
433
- this.isStartSpin = true;
434
- }
435
- }
436
- }, {
437
- key: 'moveRight',
438
- value: function moveRight(currentPositionX) {
439
- var itemsSkippedRight = Math.floor((currentPositionX - this.movementStart.x) / this.speedFactor) || 1;
440
-
441
- this.spinReverse ? this.moveActiveIndexDown(itemsSkippedRight) : this.moveActiveIndexUp(itemsSkippedRight);
442
-
443
- this.movementStart.x = currentPositionX;
444
- this.activeImageY = 1;
445
- this.update();
446
- }
447
- }, {
448
- key: 'moveLeft',
449
- value: function moveLeft(currentPositionX) {
450
- var itemsSkippedLeft = Math.floor((this.movementStart.x - currentPositionX) / this.speedFactor) || 1;
451
-
452
- this.spinReverse ? this.moveActiveIndexUp(itemsSkippedLeft) : this.moveActiveIndexDown(itemsSkippedLeft);
453
-
454
- this.activeImageY = 1;
455
- this.movementStart.x = currentPositionX;
456
- this.update();
457
- }
458
- }, {
459
- key: 'moveTop',
460
- value: function moveTop(currentPositionY) {
461
- var itemsSkippedTop = Math.floor((this.movementStart.y - currentPositionY) / this.speedFactor) || 1;
462
-
463
- this.spinReverse ? this.moveActiveYIndexUp(itemsSkippedTop) : this.moveActiveYIndexDown(itemsSkippedTop);
464
-
465
- this.activeImageX = 1;
466
- this.movementStart.y = currentPositionY;
467
- this.update();
468
- }
469
- }, {
470
- key: 'moveBottom',
471
- value: function moveBottom(currentPositionY) {
472
- var itemsSkippedBottom = Math.floor((currentPositionY - this.movementStart.y) / this.speedFactor) || 1;
473
-
474
- this.spinReverse ? this.moveActiveYIndexDown(itemsSkippedBottom) : this.moveActiveYIndexUp(itemsSkippedBottom);
475
-
476
- this.activeImageX = 1;
477
- this.movementStart.y = currentPositionY;
478
- this.update();
479
- }
480
- }, {
481
- key: 'moveActiveIndexUp',
476
+ key: "moveActiveIndexUp",
482
477
  value: function moveActiveIndexUp(itemsSkipped) {
483
478
  var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
484
479
 
@@ -488,24 +483,21 @@ var CI360Viewer = function () {
488
483
  if (isReachedTheEdge) {
489
484
  this.activeImageX = this.amountX;
490
485
 
491
- if (isReverse ? this.prevElem : this.rightElem) {
492
- (0, _ci.addClass)(isReverse ? this.leftElem : this.leftElem, 'not-active');
486
+ if (isReverse ? this.leftElem : this.rightElem) {
487
+ (0, _utils.addClass)(isReverse ? this.leftElem : this.rightElem, 'not-active');
493
488
  }
494
489
  } else {
495
490
  this.activeImageX += itemsSkipped;
496
-
497
- if (this.rightElem) (0, _ci.removeClass)(this.rightElem, 'not-active');
498
-
499
- if (this.leftElem) (0, _ci.removeClass)(this.leftElem, 'not-active');
491
+ if (this.rightElem) (0, _utils.removeClass)(this.rightElem, 'not-active');
492
+ if (this.leftElem) (0, _utils.removeClass)(this.leftElem, 'not-active');
500
493
  }
501
494
  } else {
502
495
  this.activeImageX = (this.activeImageX + itemsSkipped) % this.amountX || this.amountX;
503
-
504
496
  if (this.activeImageX === this.amountX && this.allowSpinY) this.spinY = true;
505
497
  }
506
498
  }
507
499
  }, {
508
- key: 'moveActiveIndexDown',
500
+ key: "moveActiveIndexDown",
509
501
  value: function moveActiveIndexDown(itemsSkipped) {
510
502
  var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
511
503
 
@@ -516,14 +508,12 @@ var CI360Viewer = function () {
516
508
  this.activeImageX = 1;
517
509
 
518
510
  if (isReverse ? this.rightElem : this.leftElem) {
519
- (0, _ci.addClass)(isReverse ? this.rightElem : this.leftElem, 'not-active');
511
+ (0, _utils.addClass)(isReverse ? this.rightElem : this.leftElem, 'not-active');
520
512
  }
521
513
  } else {
522
514
  this.activeImageX -= itemsSkipped;
523
-
524
- if (this.leftElem) (0, _ci.removeClass)(this.leftElem, 'not-active');
525
-
526
- if (this.rightElem) (0, _ci.removeClass)(this.rightElem, 'not-active');
515
+ if (this.leftElem) (0, _utils.removeClass)(this.leftElem, 'not-active');
516
+ if (this.rightElem) (0, _utils.removeClass)(this.rightElem, 'not-active');
527
517
  }
528
518
  } else {
529
519
  if (this.activeImageX - itemsSkipped < 1) {
@@ -535,7 +525,7 @@ var CI360Viewer = function () {
535
525
  }
536
526
  }
537
527
  }, {
538
- key: 'moveActiveYIndexUp',
528
+ key: "moveActiveYIndexUp",
539
529
  value: function moveActiveYIndexUp(itemsSkipped) {
540
530
  var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
541
531
 
@@ -546,23 +536,20 @@ var CI360Viewer = function () {
546
536
  this.activeImageY = this.amountY;
547
537
 
548
538
  if (isReverse ? this.bottomElem : this.topElem) {
549
- (0, _ci.addClass)(isReverse ? this.bottomElem : this.topElem, 'not-active');
539
+ (0, _utils.addClass)(isReverse ? this.bottomElem : this.topElem, 'not-active');
550
540
  }
551
541
  } else {
552
542
  this.activeImageY += itemsSkipped;
553
-
554
- if (this.topElem) (0, _ci.removeClass)(this.topElem, 'not-active');
555
-
556
- if (this.bottomElem) (0, _ci.removeClass)(this.bottomElem, 'not-active');
543
+ if (this.topElem) (0, _utils.removeClass)(this.topElem, 'not-active');
544
+ if (this.bottomElem) (0, _utils.removeClass)(this.bottomElem, 'not-active');
557
545
  }
558
546
  } else {
559
547
  this.activeImageY = (this.activeImageY + itemsSkipped) % this.amountY || this.amountY;
560
-
561
548
  if (this.activeImageY === this.amountY) this.spinY = false;
562
549
  }
563
550
  }
564
551
  }, {
565
- key: 'moveActiveYIndexDown',
552
+ key: "moveActiveYIndexDown",
566
553
  value: function moveActiveYIndexDown(itemsSkipped) {
567
554
  var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
568
555
 
@@ -573,13 +560,12 @@ var CI360Viewer = function () {
573
560
  this.activeImageY = 1;
574
561
 
575
562
  if (isReverse ? this.topElem : this.bottomElem) {
576
- (0, _ci.addClass)(isReverse ? this.topElem : this.bottomElem, 'not-active');
563
+ (0, _utils.addClass)(isReverse ? this.topElem : this.bottomElem, 'not-active');
577
564
  }
578
565
  } else {
579
566
  this.activeImageY -= itemsSkipped;
580
-
581
- if (this.bottomElem) (0, _ci.removeClass)(this.bottomElem, 'not-active');
582
- if (this.topElem) (0, _ci.removeClass)(this.topElem, 'not-active');
567
+ if (this.bottomElem) (0, _utils.removeClass)(this.bottomElem, 'not-active');
568
+ if (this.topElem) (0, _utils.removeClass)(this.topElem, 'not-active');
583
569
  }
584
570
  } else {
585
571
  if (this.activeImageY - itemsSkipped < 1) {
@@ -591,219 +577,242 @@ var CI360Viewer = function () {
591
577
  }
592
578
  }
593
579
  }, {
594
- key: 'loop',
595
- value: function loop(reversed) {
596
- switch (this.autoplayBehavior) {
597
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_Y:
598
- reversed ? this.bottom() : this.top();
599
- break;
600
-
601
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_XY:
602
- if (this.spinY) {
603
- reversed ? this.bottom() : this.top();
604
- } else {
605
- reversed ? this.left() : this.right();
606
- }
607
- break;
608
-
609
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_YX:
610
- if (this.spinY) {
611
- reversed ? this.bottom() : this.top();
612
- } else {
613
- reversed ? this.left() : this.right();
614
- }
615
- break;
580
+ key: "moveRight",
581
+ value: function moveRight(currentPositionX) {
582
+ var itemsSkippedRight = (0, _utils.getItemSkipped)(currentPositionX, this.movementStart.x, this.speedFactor);
583
+ this.spinReverse ? this.moveActiveIndexDown(itemsSkippedRight) : this.moveActiveIndexUp(itemsSkippedRight);
584
+ this.movementStart.x = currentPositionX;
585
+ this.activeImageY = 1;
586
+ this.update();
587
+ }
588
+ }, {
589
+ key: "moveLeft",
590
+ value: function moveLeft(currentPositionX) {
591
+ var itemsSkippedLeft = (0, _utils.getItemSkipped)(this.movementStart.x, currentPositionX, this.speedFactor);
592
+ this.spinReverse ? this.moveActiveIndexUp(itemsSkippedLeft) : this.moveActiveIndexDown(itemsSkippedLeft);
593
+ this.activeImageY = 1;
594
+ this.movementStart.x = currentPositionX;
595
+ this.update();
596
+ }
597
+ }, {
598
+ key: "moveTop",
599
+ value: function moveTop(currentPositionY) {
600
+ var itemsSkippedTop = (0, _utils.getItemSkipped)(this.movementStart.y, currentPositionY, this.speedFactor);
601
+ this.spinReverse ? this.moveActiveYIndexUp(itemsSkippedTop) : this.moveActiveYIndexDown(itemsSkippedTop);
602
+ this.activeImageX = 1;
603
+ this.movementStart.y = currentPositionY;
604
+ this.update();
605
+ }
606
+ }, {
607
+ key: "moveBottom",
608
+ value: function moveBottom(currentPositionY) {
609
+ var itemsSkippedBottom = (0, _utils.getItemSkipped)(currentPositionY, this.movementStart.y, this.speedFactor);
610
+ this.spinReverse ? this.moveActiveYIndexDown(itemsSkippedBottom) : this.moveActiveYIndexUp(itemsSkippedBottom);
611
+ this.activeImageX = 1;
612
+ this.movementStart.y = currentPositionY;
613
+ this.update();
614
+ }
615
+ }, {
616
+ key: "onMoveHandler",
617
+ value: function onMoveHandler(event) {
618
+ var currentPositionX = this.isMobile ? event.touches[0].clientX : event.pageX;
619
+ var currentPositionY = this.isMobile ? event.touches[0].clientY : event.pageY;
620
+ var isMoveRight = currentPositionX - this.movementStart.x >= this.speedFactor;
621
+ var isMoveLeft = this.movementStart.x - currentPositionX >= this.speedFactor;
622
+ var isMoveTop = this.movementStart.y - currentPositionY >= this.speedFactor;
623
+ var isMoveBottom = currentPositionY - this.movementStart.y >= this.speedFactor;
624
+ if (this.bottomCircle) this.hide360ViewCircleIcon();
616
625
 
617
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_X:
618
- default:
619
- reversed ? this.left() : this.right();
626
+ if (isMoveRight && this.movingDirection === _constants.ORIENTATIONS.X) {
627
+ this.moveRight(currentPositionX);
628
+ this.isStartSpin = true;
629
+ } else if (isMoveLeft && this.movingDirection === _constants.ORIENTATIONS.X) {
630
+ this.moveLeft(currentPositionX);
631
+ this.isStartSpin = true;
632
+ } else if (isMoveTop && this.movingDirection === _constants.ORIENTATIONS.Y) {
633
+ this.moveTop(currentPositionY);
634
+ this.isStartSpin = true;
635
+ } else if (isMoveBottom && this.movingDirection === _constants.ORIENTATIONS.Y) {
636
+ this.moveBottom(currentPositionY);
637
+ this.isStartSpin = true;
620
638
  }
621
639
  }
622
640
  }, {
623
- key: 'right',
624
- value: function right() {
625
- this.movingDirection = _ci2.ORIENTATIONS.X;
641
+ key: "left",
642
+ value: function left() {
643
+ this.movingDirection = _constants.ORIENTATIONS.X;
626
644
  this.activeImageY = this.reversed ? this.amountY : 1;
627
-
628
- this.moveActiveIndexUp(1);
645
+ this.moveActiveIndexDown(1);
629
646
  this.update();
630
647
  }
631
648
  }, {
632
- key: 'left',
633
- value: function left() {
634
- this.movingDirection = _ci2.ORIENTATIONS.X;
649
+ key: "right",
650
+ value: function right() {
651
+ this.movingDirection = _constants.ORIENTATIONS.X;
635
652
  this.activeImageY = this.reversed ? this.amountY : 1;
636
-
637
- this.moveActiveIndexDown(1);
653
+ this.moveActiveIndexUp(1);
638
654
  this.update();
639
655
  }
640
656
  }, {
641
- key: 'top',
657
+ key: "top",
642
658
  value: function top() {
643
- this.movingDirection = _ci2.ORIENTATIONS.Y;
659
+ this.movingDirection = _constants.ORIENTATIONS.Y;
644
660
  this.activeImageX = this.reversed ? this.amountX : 1;
645
-
646
661
  this.moveActiveYIndexUp(1);
647
662
  this.update();
648
663
  }
649
664
  }, {
650
- key: 'bottom',
665
+ key: "bottom",
651
666
  value: function bottom() {
652
- this.movingDirection = _ci2.ORIENTATIONS.Y;
667
+ this.movingDirection = _constants.ORIENTATIONS.Y;
653
668
  this.activeImageX = this.reversed ? this.amountX : 1;
654
-
655
669
  this.moveActiveYIndexDown(1);
656
670
  this.update();
657
671
  }
658
672
  }, {
659
- key: 'onLoadResizedImages',
660
- value: function onLoadResizedImages(orientation, event) {
661
- this.incrementLoadedImages(orientation);
662
-
663
- var totalAmount = this.amountX + this.amountY;
664
- var totalLoadedImages = this.loadedImagesX + this.loadedImagesY;
665
-
666
- if (totalLoadedImages === totalAmount) {
667
- this.replaceImages(orientation);
668
- this.update();
669
- }
670
- }
671
- }, {
672
- key: 'replaceImages',
673
- value: function replaceImages(orientation) {
674
- if (orientation === _ci2.ORIENTATIONS.Y) {
675
- this.imagesY = this.resizedImagesY;
676
- } else {
677
- this.imagesX = this.resizedImagesX;
678
- }
673
+ key: "loop",
674
+ value: function loop(reversed) {
675
+ var loopTriggers = {
676
+ left: this.left.bind(this),
677
+ right: this.right.bind(this),
678
+ top: this.top.bind(this),
679
+ bottom: this.bottom.bind(this)
680
+ };
681
+ (0, _utils.loop)(this.autoplayBehavior, this.spinY, reversed, loopTriggers);
679
682
  }
680
683
  }, {
681
- key: 'requestNewImages',
682
- value: function requestNewImages(src, amount, orientation) {
683
- var _this = this;
684
+ key: "updateContainerAndCanvasSize",
685
+ value: function updateContainerAndCanvasSize(image) {
686
+ var imageAspectRatio = (0, _utils.getImageAspectRatio)(image, this.ratio);
684
687
 
685
- if (orientation === _ci2.ORIENTATIONS.Y) {
686
- this.resizedImagesY = [];
687
- this.loadedImagesY = 0;
688
- } else {
689
- this.resizedImagesX = [];
690
- this.loadedImagesX = 0;
688
+ if (this.fullscreenView) {
689
+ this.container.width = window.innerWidth * this.devicePixelRatio;
690
+ this.container.style.width = window.innerWidth + 'px';
691
+ this.container.height = window.innerHeight * this.devicePixelRatio;
692
+ this.container.style.height = window.innerHeight + 'px';
693
+ this.container.style.maxWidth = 'unset';
694
+ this.canvas.width = window.innerWidth * this.devicePixelRatio;
695
+ this.canvas.style.width = window.innerWidth + 'px';
696
+ this.canvas.height = window.innerHeight * this.devicePixelRatio;
697
+ this.canvas.style.height = window.innerHeight + 'px';
698
+ return;
691
699
  }
692
700
 
693
- [].concat(_toConsumableArray(new Array(amount))).map(function (_item, index) {
694
- var nextZeroFilledIndex = (0, _ci.pad)(index + 1, _this.indexZeroBase);
695
- var resultSrc = src.replace('{index}', nextZeroFilledIndex);
696
-
697
- _this.addUpdatedSizeImage(resultSrc, orientation, _this.lazyload, _this.lazySelector, index);
698
- });
701
+ this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
702
+ this.canvas.style.width = this.container.offsetWidth + 'px';
703
+ this.canvas.height = this.container.offsetWidth / imageAspectRatio * this.devicePixelRatio;
704
+ this.canvas.style.height = this.container.offsetWidth / imageAspectRatio + 'px';
699
705
  }
700
706
  }, {
701
- key: 'addUpdatedSizeImage',
702
- value: function addUpdatedSizeImage(resultSrc, orientation, lazyload, lazySelector, index) {
703
- var image = new Image();
704
-
705
- if (lazyload && !this.fullscreenView) {
706
- image.setAttribute('data-src', resultSrc);
707
- image.className = image.className.length ? image.className + (' ' + lazySelector) : lazySelector;
708
-
709
- if (index === 0) {
710
- this.lazyloadInitImage = image;
711
- image.style.position = 'absolute';
712
- image.style.top = '0';
713
- image.style.left = '0';
714
- this.innerBox.appendChild(image);
715
- }
707
+ key: "onResizedImageLoad",
708
+ value: function onResizedImageLoad(orientation, image, index) {
709
+ if (orientation === _constants.ORIENTATIONS.Y) {
710
+ this.resizedImagesY[index] = image;
716
711
  } else {
717
- image.src = resultSrc;
712
+ this.resizedImagesX[index] = image;
718
713
  }
719
714
 
720
- image.onload = this.onLoadResizedImages.bind(this, orientation);
721
- image.onerror = this.onLoadResizedImages.bind(this, orientation);
715
+ var loadedResizedXImages = this.resizedImagesX.filter(function (image) {
716
+ return image;
717
+ });
718
+ var loadedResizedYImages = this.resizedImagesY.filter(function (image) {
719
+ return image;
720
+ });
721
+ var isAllImagesLoaded = loadedResizedXImages.length + loadedResizedYImages.length === this.amountX + this.amountY;
722
722
 
723
- if (orientation === _ci2.ORIENTATIONS.Y) {
724
- this.resizedImagesY.push(image);
725
- } else {
726
- this.resizedImagesX.push(image);
723
+ if (isAllImagesLoaded) {
724
+ this.imagesX = this.resizedImagesX;
725
+ this.imagesY = this.resizedImagesY;
726
+ this.update();
727
727
  }
728
728
  }
729
729
  }, {
730
- key: 'requestResizedImages',
730
+ key: "showImageInfo",
731
+ value: function showImageInfo(ctx) {
732
+ ctx.font = "".concat(this.fullscreenView ? 28 : 14, "px serif");
733
+ ctx.fillStyle = this.info === 'white' ? '#FFF' : '#000';
734
+ var imageDimension = "image-dimension: ".concat(this.container.offsetWidth, "x").concat(this.container.offsetHeight, "px");
735
+ var currentXImage = 'active-index-x: ' + this.activeImageX;
736
+ var currentYImage = 'active-index-y: ' + this.activeImageY;
737
+ var imageIndex = [currentXImage, currentYImage].join(' | ');
738
+ ctx.fillText(imageDimension, 20, this.container.offsetHeight - 35);
739
+ ctx.fillText(imageIndex, 20, this.container.offsetHeight - 10);
740
+ }
741
+ }, {
742
+ key: "requestResizedImages",
731
743
  value: function requestResizedImages() {
732
- var srcX = this.getSrc(this.responsive, this.container, this.folder, this.filenameX, this.ciParams);
733
-
734
- this.requestNewImages(srcX, this.amountX, _ci2.ORIENTATIONS.X);
744
+ if (!this.isReady()) return;
745
+ var responsive = this.ciParams.ciToken;
746
+ var firstImage = this.imagesX[0];
747
+ this.update();
748
+ if (!responsive || this.container.offsetWidth < firstImage.width * 1.5) return;
749
+ this.speedFactor = (0, _utils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
750
+ var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
751
+ (0, _utils.preloadImages)(this.srcXConfig, srcX, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.X));
735
752
 
736
753
  if (this.allowSpinY) {
737
- var srcY = this.getSrc(this.responsive, this.container, this.folder, this.filenameY, this.ciParams);
738
-
739
- this.requestNewImages(srcY, this.amountY, _ci2.ORIENTATIONS.Y);
754
+ var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
755
+ (0, _utils.preloadImages)(this.srcYConfig, srcY, this.onResizedImageLoad.bind(this, _constants.ORIENTATIONS.Y));
740
756
  }
741
757
  }
742
758
  }, {
743
- key: 'update',
759
+ key: "update",
744
760
  value: function update() {
745
761
  var image = this.imagesX[this.activeImageX - 1];
746
762
 
747
- if (this.movingDirection === _ci2.ORIENTATIONS.Y) {
763
+ if (this.movingDirection === _constants.ORIENTATIONS.Y) {
748
764
  image = this.imagesY[this.activeImageY - 1];
749
765
  }
750
766
 
767
+ if (!image) return;
751
768
  var ctx = this.canvas.getContext("2d");
752
-
753
769
  ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
770
+ this.updateContainerAndCanvasSize(image);
754
771
 
755
772
  if (this.fullscreenView) {
756
- this.canvas.width = window.innerWidth * this.devicePixelRatio;
757
- this.canvas.style.width = window.innerWidth + 'px';
758
- this.canvas.height = window.innerHeight * this.devicePixelRatio;
759
- this.canvas.style.height = window.innerHeight + 'px';
760
-
761
- var _contain = (0, _ci.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
762
- offsetX = _contain.offsetX,
763
- offsetY = _contain.offsetY,
773
+ var _contain = (0, _utils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
764
774
  width = _contain.width,
765
- height = _contain.height;
775
+ height = _contain.height,
776
+ offsetX = _contain.offsetX,
777
+ offsetY = _contain.offsetY;
766
778
 
767
779
  ctx.drawImage(image, offsetX, offsetY, width, height);
768
780
  } else {
769
- this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
770
- this.canvas.style.width = this.container.offsetWidth + 'px';
771
- this.canvas.height = this.container.offsetWidth * this.devicePixelRatio / image.width * image.height;
772
- this.canvas.style.height = this.container.offsetWidth / image.width * image.height + 'px';
773
-
774
- if (this.startPointerZoom || this.startPinchZoom) {
781
+ if (this.mouseTracked) {
775
782
  this.updateImageScale(ctx);
776
783
  } else {
784
+ if (this.hotspotsConfigs && !this.autoplay) {
785
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection, this.isClicked);
786
+ }
787
+
777
788
  ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
778
789
  }
779
790
  }
791
+
792
+ if (this.info) {
793
+ this.showImageInfo(ctx);
794
+ }
780
795
  }
781
796
  }, {
782
- key: 'updateImageScale',
797
+ key: "updateImageScale",
783
798
  value: function updateImageScale(ctx) {
784
799
  var image = this.originalImagesX[this.activeImageX - 1];
785
800
 
786
- if (this.movingDirection === _ci2.ORIENTATIONS.Y) {
801
+ if (this.movingDirection === _constants.ORIENTATIONS.Y) {
787
802
  image = this.originalImagesY[this.activeImageY - 1];
788
803
  }
789
804
 
790
- var position = this.pointerCurrentPosition;
791
-
792
- if (this.startPointerZoom) position = this.getCursorPositionInCanvas();
793
-
794
- var imageWidth = this.canvas.width / this.devicePixelRatio;
795
- var imageHeight = this.canvas.height / this.devicePixelRatio;
796
-
797
- var width = this.canvas.width + this.zoomIntensity * (this.canvas.width / this.canvas.height);
798
- var height = this.canvas.height + this.zoomIntensity;
799
-
805
+ var position = this.getCursorPositionInCanvas();
806
+ var imageWidth = this.canvas.width;
807
+ var imageHeight = this.canvas.height;
808
+ var width = this.canvas.width * this.zoomIntensity;
809
+ var height = this.canvas.height * this.zoomIntensity;
800
810
  var pointX = 0 - position.x / imageWidth * (width - this.canvas.width);
801
811
  var pointY = 0 - position.y / imageHeight * (height - this.canvas.height);
802
-
803
812
  ctx.drawImage(image, pointX, pointY, width, height);
804
813
  }
805
814
  }, {
806
- key: 'updatePercentageInLoader',
815
+ key: "updatePercentageInLoader",
807
816
  value: function updatePercentageInLoader(percentage) {
808
817
  if (this.loader) {
809
818
  this.loader.style.width = percentage + '%';
@@ -814,127 +823,40 @@ var CI360Viewer = function () {
814
823
  }
815
824
  }
816
825
  }, {
817
- key: 'onAllImagesLoaded',
818
- value: function onAllImagesLoaded() {
819
- this.imagesLoaded = true;
820
-
821
- this.container.style.cursor = 'grab';
822
- if (this.disableDrag) this.container.style.cursor = 'default';
823
-
824
- this.removeLoader();
825
-
826
- if (!this.fullscreenView) {
827
- this.speedFactor = Math.floor(this.dragSpeed / 150 * 36 / this.amountX * 25 * this.container.offsetWidth / 1500) || 1;
828
- } else {
829
- var containerRatio = this.container.offsetHeight / this.container.offsetWidth;
830
- var imageOffsetWidth = this.container.offsetWidth;
831
-
832
- if (this.ratio > containerRatio) {
833
- imageOffsetWidth = this.container.offsetHeight / this.ratio;
834
- }
835
-
836
- this.speedFactor = Math.floor(this.dragSpeed / 150 * 36 / this.amountX * 25 * imageOffsetWidth / 1500) || 1;
837
- }
838
-
839
- if (this.imageOffset) {
840
- this.activeImageX = this.imageOffset;
841
- };
842
-
843
- if (this.autoplay) {
844
- this.play();
845
- }
846
-
847
- if (this.view360Icon) {
848
- this.view360Icon.innerText = '';
849
- (0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
850
- }
851
-
852
- this.initControls();
853
- }
854
- }, {
855
- key: 'onFirstImageLoaded',
856
- value: function onFirstImageLoaded(event) {
857
- var _this2 = this;
858
-
859
- if (!this.hide360Logo) {
860
- this.add360ViewIcon();
861
- }
826
+ key: "onFirstImageLoaded",
827
+ value: function onFirstImageLoaded(image) {
828
+ this.add360ViewIcon();
829
+ var ctx = this.canvas.getContext("2d");
830
+ ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
831
+ this.updateContainerAndCanvasSize(image);
862
832
 
863
833
  if (this.fullscreenView) {
864
- this.canvas.width = window.innerWidth * this.devicePixelRatio;
865
- this.canvas.style.width = window.innerWidth + 'px';
866
- this.canvas.height = window.innerHeight * this.devicePixelRatio;
867
- this.canvas.style.height = window.innerHeight + 'px';
868
-
869
- var ctx = this.canvas.getContext("2d");
870
-
871
- var _contain2 = (0, _ci.contain)(this.canvas.width, this.canvas.height, event.target.width, event.target.height),
834
+ var _contain2 = (0, _utils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
872
835
  offsetX = _contain2.offsetX,
873
836
  offsetY = _contain2.offsetY,
874
837
  width = _contain2.width,
875
838
  height = _contain2.height;
876
839
 
877
- this.offset = { x: offsetX, y: offsetY };
878
-
879
- ctx.drawImage(event.target, offsetX, offsetY, width, height);
840
+ this.offset = {
841
+ x: offsetX,
842
+ y: offsetY
843
+ };
844
+ this.addCloseFullscreenView();
845
+ ctx.drawImage(image, offsetX, offsetY, width, height);
880
846
  } else {
881
- var _ctx = this.canvas.getContext("2d");
882
- var imagePreview = event.target;
883
-
884
- if (this.imageOffset) {
885
- imagePreview = this.imagesX[this.imageOffset];
886
- }
887
-
888
- if (this.container.offsetWidth === 0) {
889
- var modalRef = this.container.parentElement;
890
-
891
- this.canvas.width = parseInt(modalRef.style.width) * this.devicePixelRatio;
892
- this.canvas.style.width = modalRef.style.width;
893
-
894
- this.canvas.height = parseInt(modalRef.style.height) * this.devicePixelRatio / event.target.width * event.target.height;
895
- this.canvas.style.height = parseInt(modalRef.style.width) / event.target.width * event.target.height + 'px';
896
- }
897
-
898
- if (this.container.offsetWidth > 0) {
899
- this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
900
- this.canvas.style.width = this.container.offsetWidth + 'px';
901
-
902
- this.canvas.height = this.container.offsetWidth * this.devicePixelRatio / event.target.width * event.target.height;
903
- this.canvas.style.height = this.container.offsetWidth / event.target.width * event.target.height + 'px';
904
- }
905
-
906
- _ctx.drawImage(imagePreview, 0, 0, this.canvas.width, this.canvas.height);
907
- }
908
-
909
- if (this.lazyload && !this.fullscreenView) {
910
- this.imagesX.forEach(function (image, index) {
911
- if (index === 0) {
912
- _this2.innerBox.removeChild(_this2.lazyloadInitImage);
913
- return;
914
- }
915
-
916
- var dataSrc = image.getAttribute('data-src');
917
-
918
- if (dataSrc) {
919
- image.src = image.getAttribute('data-src');
920
- }
921
- });
922
- }
923
-
924
- if (this.ratio) {
925
- this.container.style.minHeight = 'auto';
847
+ ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
926
848
  }
927
849
 
928
- if (this.fullscreenView) {
929
- this.addCloseFullscreenView();
850
+ if (this.info) {
851
+ this.showImageInfo(ctx);
930
852
  }
931
853
 
932
- if (this.magnifier && !this.fullscreenView || this.magnifyInFullscreen) {
854
+ if (this.magnifier) {
933
855
  this.addMagnifier();
934
856
  }
935
857
 
936
858
  if (this.boxShadow && !this.fullscreenView) {
937
- this.addBoxShadow();
859
+ this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
938
860
  }
939
861
 
940
862
  if (this.bottomCircle && !this.fullscreenView) {
@@ -944,459 +866,153 @@ var CI360Viewer = function () {
944
866
  if (this.fullscreen && !this.fullscreenView) {
945
867
  this.addFullscreenIcon();
946
868
  }
947
-
948
- if (!this.isMobile && !this.fullscreenView && !this.disablePointerZoom) {
949
- this.addResetZoomIcon();
950
- }
951
869
  }
952
870
  }, {
953
- key: 'incrementLoadedImages',
954
- value: function incrementLoadedImages(orientation) {
955
- if (orientation === _ci2.ORIENTATIONS.Y) {
956
- this.loadedImagesY += 1;
957
- } else {
958
- this.loadedImagesX += 1;
959
- }
960
- }
961
- }, {
962
- key: 'onImageLoad',
963
- value: function onImageLoad(index, orientation, event) {
964
- this.incrementLoadedImages(orientation);
965
-
966
- var totalAmount = this.amountX + this.amountY;
967
- var totalLoadedImages = this.loadedImagesX + this.loadedImagesY;
968
-
969
- var percentage = Math.round(totalLoadedImages / totalAmount * 100);
970
-
971
- this.updatePercentageInLoader(percentage);
972
-
973
- if (index === 0 && orientation !== _ci2.ORIENTATIONS.Y) {
974
- this.onFirstImageLoaded(event);
975
- }
871
+ key: "onAllImagesLoaded",
872
+ value: function onAllImagesLoaded() {
873
+ this.removeLoader();
874
+ this.imagesLoaded = true;
976
875
 
977
- if (totalLoadedImages === totalAmount) {
978
- this.onAllImagesLoaded(event);
876
+ if (this.autoplay && this.pointerZoom) {
877
+ this.container.style.cursor = 'zoom-in';
878
+ } else {
879
+ this.container.style.cursor = 'grab';
979
880
  }
980
- }
981
- }, {
982
- key: 'addCloseFullscreenView',
983
- value: function addCloseFullscreenView(event) {
984
- var closeFullscreenIcon = document.createElement('div');
985
- closeFullscreenIcon.className = 'cloudimage-360-close-fullscreen-icon';
986
- closeFullscreenIcon.onclick = this.setFullscreenEvents.bind(this, event);
987
-
988
- window.onkeyup = this.setFullscreenEvents.bind(this, event);
989
-
990
- this.iconsContainer.appendChild(closeFullscreenIcon);
991
- }
992
- }, {
993
- key: 'add360ViewIcon',
994
- value: function add360ViewIcon() {
995
- var view360Icon = document.createElement('div');
996
-
997
- view360Icon.className = 'cloudimage-360-view-360-icon';
998
- view360Icon.innerText = '0%';
999
-
1000
- this.view360Icon = view360Icon;
1001
- this.innerBox.appendChild(view360Icon);
1002
- }
1003
- }, {
1004
- key: 'addFullscreenIcon',
1005
- value: function addFullscreenIcon() {
1006
- var fullscreenIcon = document.createElement('div');
1007
-
1008
- fullscreenIcon.className = 'cloudimage-360-fullscreen-icon';
1009
- fullscreenIcon.onclick = this.openFullscreenModal.bind(this);
1010
-
1011
- this.fullscreenIcon = fullscreenIcon;
1012
-
1013
- this.iconsContainer.appendChild(fullscreenIcon);
1014
- }
1015
- }, {
1016
- key: 'hideFullscreenIcon',
1017
- value: function hideFullscreenIcon() {
1018
- if (!this.fullscreenIcon) return;
1019
-
1020
- this.fullscreenIcon.style.opacity = '0.4';
1021
- this.fullscreenIcon.style.pointerEvents = 'none';
1022
- }
1023
- }, {
1024
- key: 'showFullscreenIcon',
1025
- value: function showFullscreenIcon() {
1026
- if (!this.fullscreenIcon) return;
1027
-
1028
- this.fullscreenIcon.style.opacity = '1';
1029
- this.fullscreenIcon.style.pointerEvents = 'auto';
1030
- }
1031
- }, {
1032
- key: 'addMagnifier',
1033
- value: function addMagnifier() {
1034
- var magnifyIcon = document.createElement('div');
1035
-
1036
- magnifyIcon.className = 'cloudimage-360-magnifier-icon';
1037
- magnifyIcon.onclick = this.magnify.bind(this);
1038
-
1039
- this.magnifierIcon = magnifyIcon;
1040
-
1041
- this.iconsContainer.appendChild(magnifyIcon);
1042
- }
1043
- }, {
1044
- key: 'disableMagnifierIcon',
1045
- value: function disableMagnifierIcon() {
1046
- if (!this.magnifierIcon) return;
1047
-
1048
- this.magnifierIcon.style.opacity = '0.4';
1049
- this.magnifierIcon.style.pointerEvents = 'none';
1050
- }
1051
- }, {
1052
- key: 'enableMagnifierIcon',
1053
- value: function enableMagnifierIcon() {
1054
- if (!this.magnifierIcon) return;
1055
-
1056
- this.magnifierIcon.style.opacity = '1';
1057
- this.magnifierIcon.style.pointerEvents = 'auto';
1058
- }
1059
- }, {
1060
- key: 'getOriginalSrc',
1061
- value: function getOriginalSrc() {
1062
- var currentImage = this.originalImagesX[this.activeImageX - 1];
1063
-
1064
- if (this.movingDirection === _ci2.ORIENTATIONS.Y) {
1065
- currentImage = this.originalImagesY[this.activeImageY - 1];
1066
- };
1067
-
1068
- return currentImage.src;
1069
- }
1070
- }, {
1071
- key: 'magnify',
1072
- value: function magnify() {
1073
- var _this3 = this;
1074
-
1075
- var image = new Image();
1076
- var src = this.getOriginalSrc();
1077
- this.isMagnifyOpen = true;
1078
-
1079
- image.src = src;
1080
- image.onload = function () {
1081
- if (_this3.glass) {
1082
- _this3.glass.style.cursor = 'none';
1083
- }
1084
- };
1085
-
1086
- this.glass = document.createElement('div');
1087
- this.container.style.overflow = 'hidden';
1088
-
1089
- (0, _ci.magnify)(this.container, this.offset, src, this.glass, this.magnifier || 3);
1090
- }
1091
- }, {
1092
- key: 'closeMagnifier',
1093
- value: function closeMagnifier() {
1094
- if (!this.glass) return;
1095
-
1096
- this.container.style.overflow = 'visible';
1097
- this.container.removeChild(this.glass);
1098
- this.glass = null;
1099
- this.isMagnifyOpen = false;
1100
- }
1101
- }, {
1102
- key: 'openFullscreenModal',
1103
- value: function openFullscreenModal() {
1104
- var fullscreenModal = document.createElement('div');
1105
-
1106
- fullscreenModal.className = 'cloudimage-360-fullscreen-modal';
1107
-
1108
- var fullscreenContainer = this.container.cloneNode();
1109
- var image = this.imagesX[0];
1110
- var ratio = image.height / image.width;
1111
-
1112
- fullscreenContainer.style.height = '100%';
1113
- fullscreenContainer.style.maxHeight = '100%';
1114
-
1115
- fullscreenModal.appendChild(fullscreenContainer);
1116
-
1117
- window.document.body.style.overflow = 'hidden';
1118
- window.document.body.appendChild(fullscreenModal);
1119
881
 
1120
- new CI360Viewer(fullscreenContainer, true, ratio);
1121
- }
1122
- }, {
1123
- key: 'setFullscreenEvents',
1124
- value: function setFullscreenEvents(_, event) {
1125
- if (event.type === 'click') return this.closeFullscreenModal();
1126
- if (event.key === 'Escape') return this.closeFullscreenModalOnEsc();
1127
- }
1128
- }, {
1129
- key: 'closeFullscreenModalOnEsc',
1130
- value: function closeFullscreenModalOnEsc() {
1131
-
1132
- if (this.container.parentNode.parentNode === document.body) {
1133
- this.closeFullscreenModal();
1134
- };
1135
- }
1136
- }, {
1137
- key: 'closeFullscreenModal',
1138
- value: function closeFullscreenModal() {
1139
- document.body.removeChild(this.container.parentNode);
1140
- window.document.body.style.overflow = 'visible';
1141
- }
1142
- }, {
1143
- key: 'add360ViewCircleIcon',
1144
- value: function add360ViewCircleIcon() {
1145
- var view360CircleIcon = new Image();
1146
-
1147
- view360CircleIcon.src = 'https://scaleflex.ultrafast.io/https://scaleflex.api.airstore.io/v1/get/_/2236d56f-914a-5a8b-a3ae-f7bde1c50000/360.svg';
882
+ this.speedFactor = (0, _utils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
1148
883
 
1149
- view360CircleIcon.style.bottom = this.bottomCircleOffset + '%';
1150
- view360CircleIcon.className = 'cloudimage-360-view-360-circle';
1151
-
1152
- this.view360CircleIcon = view360CircleIcon;
1153
- this.innerBox.appendChild(view360CircleIcon);
1154
- }
1155
- }, {
1156
- key: 'hide360ViewCircleIcon',
1157
- value: function hide360ViewCircleIcon() {
1158
- if (!this.view360CircleIcon) return;
1159
-
1160
- this.view360CircleIcon.style.opacity = '0';
1161
- }
1162
- }, {
1163
- key: 'show360ViewCircleIcon',
1164
- value: function show360ViewCircleIcon() {
1165
- if (!this.view360CircleIcon) return;
1166
-
1167
- this.view360CircleIcon.style.opacity = '1';
1168
- }
1169
- }, {
1170
- key: 'remove360ViewCircleIcon',
1171
- value: function remove360ViewCircleIcon() {
1172
- if (!this.view360CircleIcon) return;
1173
-
1174
- this.innerBox.removeChild(this.view360CircleIcon);
1175
- this.view360CircleIcon = null;
1176
- }
1177
- }, {
1178
- key: 'addResetZoomIcon',
1179
- value: function addResetZoomIcon() {
1180
- var resetZoomIcon = document.createElement('div');
1181
-
1182
- resetZoomIcon.className = 'cloudimage-360-reset-zoom-icon';
1183
- this.resetZoomIcon = resetZoomIcon;
884
+ if (this.autoplay) {
885
+ this.play();
886
+ }
1184
887
 
1185
- resetZoomIcon.onmouseenter = this.resetZoom.bind(this);
888
+ if (this.disableDrag) {
889
+ this.container.style.cursor = 'default';
890
+ }
1186
891
 
1187
- this.iconsContainer.appendChild(resetZoomIcon);
1188
- }
1189
- }, {
1190
- key: 'hideResetZoomIcon',
1191
- value: function hideResetZoomIcon() {
1192
- if (!this.resetZoomIcon) return;
1193
- if (this.magnifierIcon) this.enableMagnifierIcon();
1194
- if (this.fullscreenIcon) this.showFullscreenIcon();
892
+ if (this.view360Icon) {
893
+ if (this.hide360Logo) return this.remove360ViewIcon();
894
+ this.view360Icon.innerText = ''; //TODO [deprecated]: remove setView360Icon in the upcoming versions
1195
895
 
1196
- this.resetZoomIcon.style.display = 'none';
1197
- }
1198
- }, {
1199
- key: 'showResetZoomIcon',
1200
- value: function showResetZoomIcon() {
1201
- if (!this.resetZoomIcon) return;
1202
- if (this.magnifierIcon) this.disableMagnifierIcon();
1203
- if (this.fullscreenIcon) this.hideFullscreenIcon();
896
+ if (this.logoSrc) (0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
897
+ }
1204
898
 
1205
- this.resetZoomIcon.style.display = 'block';
899
+ this.initControls();
1206
900
  }
1207
901
  }, {
1208
- key: 'addLoader',
1209
- value: function addLoader() {
1210
- var loader = document.createElement('div');
1211
- loader.className = 'cloudimage-360-loader';
902
+ key: "magnify",
903
+ value: function magnify(event) {
904
+ var _this3 = this;
1212
905
 
1213
- this.loader = loader;
1214
- this.innerBox.appendChild(loader);
1215
- }
1216
- }, {
1217
- key: 'addBoxShadow',
1218
- value: function addBoxShadow() {
1219
- var boxShadow = document.createElement('div');
906
+ event.stopPropagation();
907
+ if (this.mouseTracked) this.togglePointerZoom();
908
+ var currentOriginalImage = (0, _utils.getCurrentOriginalImage)(this.movingDirection, this.imagesX, this.imagesY, this.activeImageX, this.activeImageY);
909
+ this.isMagnifyOpen = true;
1220
910
 
1221
- boxShadow.className = 'cloudimage-360-box-shadow';
1222
- boxShadow.style.boxShadow = this.boxShadow;
911
+ currentOriginalImage.onload = function () {
912
+ if (_this3.glass) {
913
+ _this3.glass.style.cursor = 'none';
914
+ }
915
+ };
1223
916
 
1224
- this.innerBox.appendChild(boxShadow);
917
+ this.glass = document.createElement('div');
918
+ this.container.style.overflow = 'hidden';
919
+ (0, _utils.magnify)(this.container, this.offset, currentOriginalImage, this.glass, this.magnifier || 3);
1225
920
  }
1226
921
  }, {
1227
- key: 'removeLoader',
1228
- value: function removeLoader() {
1229
- if (!this.loader) return;
1230
-
1231
- this.innerBox.removeChild(this.loader);
1232
- this.loader = null;
922
+ key: "closeMagnifier",
923
+ value: function closeMagnifier() {
924
+ if (!this.glass) return;
925
+ this.container.style.overflow = 'visible';
926
+ this.container.removeChild(this.glass);
927
+ this.glass = null;
928
+ this.isMagnifyOpen = false;
1233
929
  }
1234
930
  }, {
1235
- key: 'remove360ViewIcon',
1236
- value: function remove360ViewIcon() {
1237
- if (!this.view360Icon) return;
1238
-
1239
- this.innerBox.removeChild(this.view360Icon);
1240
- this.view360Icon = null;
931
+ key: "openFullscreenModal",
932
+ value: function openFullscreenModal(event) {
933
+ event.stopPropagation();
934
+ if (this.mouseTracked) this.togglePointerZoom();
935
+ var fullscreenContainer = (0, _utils.createFullscreenModal)(this.container);
936
+ new CI360Viewer(fullscreenContainer, true, this.hotspotsConfigs);
1241
937
  }
1242
938
  }, {
1243
- key: 'isCompletedCyle',
1244
- value: function isCompletedCyle() {
1245
- switch (this.autoplayBehavior) {
1246
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_XY:
1247
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_Y:
1248
- {
1249
- var isReachedTheEdge = this.reversed ? this.activeImageY === 1 : this.activeImageY === this.amountY;
1250
-
1251
- if (isReachedTheEdge) return true;
1252
-
1253
- return false;
1254
- }
1255
-
1256
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_X:
1257
- case _ci2.AUTOPLAY_BEHAVIOR.SPIN_YX:
1258
- default:
1259
- {
1260
- var _isReachedTheEdge = this.reversed ? this.activeImageX === 1 : this.activeImageX === this.amountX;
1261
-
1262
- if (_isReachedTheEdge) return true;
939
+ key: "setFullscreenEvents",
940
+ value: function setFullscreenEvents(_, event) {
941
+ if (event.type === 'click') return this.closeFullscreenModal(event);
1263
942
 
1264
- return false;
1265
- }
943
+ if (event.key === 'Escape' && this.container.parentNode.parentNode === document.body) {
944
+ this.closeFullscreenModalOnEsc(event);
1266
945
  }
1267
946
  }
1268
947
  }, {
1269
- key: 'play',
948
+ key: "closeFullscreenModalOnEsc",
949
+ value: function closeFullscreenModalOnEsc(event) {
950
+ this.closeFullscreenModal(event);
951
+ }
952
+ }, {
953
+ key: "play",
1270
954
  value: function play() {
1271
955
  var _this4 = this;
1272
956
 
1273
957
  if (this.bottomCircle) this.hide360ViewCircleIcon();
1274
958
  this.remove360ViewIcon();
1275
-
1276
959
  this.loopTimeoutId = window.setInterval(function () {
1277
960
  _this4.loop(_this4.reversed);
1278
961
 
1279
- var isPlayedOnce = _this4.isCompletedCyle();
962
+ var isPlayedOnce = (0, _utils.isCompletedOneCycle)(_this4.autoplayBehavior, _this4.activeImageX, _this4.activeImageY, _this4.amountX, _this4.amountY, _this4.reversed);
1280
963
 
1281
964
  if (_this4.playOnce && isPlayedOnce) {
1282
965
  window.clearTimeout(_this4.loopTimeoutId);
966
+ _this4.autoplay = false;
967
+
968
+ if (_this4.hotspotsConfigs) {
969
+ (0, _utils.updateHotspots)(_this4.container, _this4.hotspotsConfigs, _this4.activeImageX, _this4.activeImageY, _this4.movingDirection, _this4.isClicked);
970
+ }
1283
971
  }
1284
972
  }, this.autoplaySpeed);
1285
973
  }
1286
974
  }, {
1287
- key: 'stop',
975
+ key: "stop",
1288
976
  value: function stop() {
1289
- if (this.bottomCircle && !this.zoomIntensity) this.show360ViewCircleIcon();
977
+ if (this.bottomCircle) this.show360ViewCircleIcon();
1290
978
  window.clearTimeout(this.loopTimeoutId);
1291
979
  }
1292
980
  }, {
1293
- key: 'getSrc',
1294
- value: function getSrc(responsive, container, folder, filename, _ref) {
1295
- var ciToken = _ref.ciToken,
1296
- ciFilters = _ref.ciFilters,
1297
- ciTransformation = _ref.ciTransformation;
1298
-
1299
- var src = '' + folder + filename;
1300
-
1301
- if (responsive) {
1302
- var imageOffsetWidth = container.offsetWidth;
1303
-
1304
- if (this.fullscreenView) {
1305
- var containerRatio = container.offsetHeight / container.offsetWidth;
1306
-
1307
- if (this.ratio > containerRatio) {
1308
- imageOffsetWidth = container.offsetHeight / this.ratio;
1309
- }
1310
- }
1311
-
1312
- var ciSizeNext = (0, _ci.getSizeAccordingToPixelRatio)((0, _ci.getResponsiveWidthOfContainer)(imageOffsetWidth));
1313
-
1314
- src = 'https://' + ciToken + '.cloudimg.io/v7/' + src + '?' + (ciTransformation ? ciTransformation : 'width=' + ciSizeNext) + (ciFilters ? '&f=' + ciFilters : '');
1315
- }
1316
-
1317
- return src;
1318
- }
1319
- }, {
1320
- key: 'preloadImages',
1321
- value: function preloadImages(amount, src) {
1322
- var orientation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ci2.ORIENTATIONS.X;
1323
- var lazyload = arguments[3];
1324
- var lazySelector = arguments[4];
1325
- var container = arguments[5];
1326
-
981
+ key: "updateView",
982
+ value: function updateView(forceUpdate, viewers) {
1327
983
  var _this5 = this;
1328
984
 
1329
- var responsive = arguments[6];
1330
- var ciParams = arguments[7];
1331
-
1332
- if (this.imageList) {
1333
- try {
1334
- var images = JSON.parse(this.imageList);
1335
-
1336
- this.amountX = images.length;
1337
- images.forEach(function (src, index) {
1338
- var folder = /(http(s?)):\/\//gi.test(src) ? '' : _this5.folder;
1339
- var resultSrc = _this5.getSrc(responsive, container, folder, src, ciParams);
1340
- var lastIndex = resultSrc.lastIndexOf('//');
1341
- var originalSrc = resultSrc.slice(lastIndex);
1342
-
1343
- _this5.addImage(resultSrc, originalSrc, orientation, lazyload, lazySelector, index);
1344
- });
1345
- } catch (error) {
1346
- console.error('Wrong format in image-list attribute: ' + error.message);
1347
- }
1348
- } else {
1349
- [].concat(_toConsumableArray(new Array(amount))).map(function (_item, index) {
1350
- var nextZeroFilledIndex = (0, _ci.pad)(index + 1, _this5.indexZeroBase);
1351
- var resultSrc = src.replace('{index}', nextZeroFilledIndex);
1352
- var originalSrc = resultSrc.replace(_ci2.ORGINAL_SIZE_REGEX, '').replace(_ci2.AND_SYMBOL_REGEX, '?');
985
+ var container = this.container;
986
+ var imageProps = (0, _ci.get360ViewProps)(container);
987
+ var srcPropsChanged = (0, _utils.isPropsChangeRequireReload)(this, imageProps);
988
+ var reInitView = srcPropsChanged || forceUpdate;
1353
989
 
1354
- _this5.addImage(resultSrc, originalSrc, orientation, lazyload, lazySelector, index);
990
+ if (reInitView) {
991
+ var oldElement = this.container;
992
+ var viewIndex = viewers.findIndex(function (view) {
993
+ return view.id === _this5.container.id;
1355
994
  });
1356
- }
1357
- }
1358
- }, {
1359
- key: 'addImage',
1360
- value: function addImage(resultSrc, originalSrc, orientation, lazyload, lazySelector, index) {
1361
- var image = new Image();
1362
- var originalImage = new Image();
1363
-
1364
- if (lazyload && !this.fullscreenView) {
1365
- image.setAttribute('data-src', resultSrc);
1366
- image.className = image.className.length ? image.className + (' ' + lazySelector) : lazySelector;
1367
-
1368
- if (index === 0) {
1369
- this.lazyloadInitImage = image;
1370
- image.style.position = 'absolute';
1371
- image.style.top = '0';
1372
- image.style.left = '0';
1373
- this.innerBox.appendChild(image);
1374
- }
1375
- } else {
1376
- image.src = resultSrc;
1377
- originalImage.src = originalSrc;
995
+ container.removeChild(this.innerBox);
996
+ container = container.cloneNode(true);
997
+ container.className = container.className.replace(' initialized', '');
998
+ oldElement.parentNode.replaceChild(container, oldElement);
999
+ return viewers.splice(viewIndex, 1, new CI360Viewer(container));
1378
1000
  }
1379
1001
 
1380
- image.onload = this.onImageLoad.bind(this, index, orientation);
1381
- image.onerror = this.onImageLoad.bind(this, index, orientation);
1382
-
1383
- if (orientation === _ci2.ORIENTATIONS.Y) {
1384
- this.imagesY.push(image);
1385
- this.originalImagesY.push(originalImage);
1386
- } else {
1387
- this.imagesX.push(image);
1388
- this.originalImagesX.push(originalImage);
1389
- }
1002
+ container.style.position = 'relative';
1003
+ container.style.width = '100%';
1004
+ container.style.cursor = 'default';
1005
+ container.setAttribute('draggable', 'false');
1006
+ this.stop();
1007
+ this.init(container, true);
1390
1008
  }
1391
1009
  }, {
1392
- key: 'destroy',
1010
+ key: "destroy",
1393
1011
  value: function destroy() {
1394
1012
  stop();
1395
-
1396
1013
  var oldElement = this.container;
1397
1014
  var newElement = oldElement.cloneNode(true);
1398
1015
  var innerBox = newElement.querySelector('.cloudimage-360-inner-box');
1399
-
1400
1016
  newElement.className = newElement.className.replace(' initialized', '');
1401
1017
  newElement.style.position = 'relative';
1402
1018
  newElement.style.width = '100%';
@@ -1407,244 +1023,243 @@ var CI360Viewer = function () {
1407
1023
  oldElement.parentNode.replaceChild(newElement, oldElement);
1408
1024
  }
1409
1025
  }, {
1410
- key: 'initControls',
1026
+ key: "addCloseFullscreenView",
1027
+ value: function addCloseFullscreenView(event) {
1028
+ var closeFullscreenIcon = (0, _utils.createCloseFullscreenIcon)();
1029
+ closeFullscreenIcon.onclick = this.setFullscreenEvents.bind(this, event);
1030
+ window.onkeyup = this.setFullscreenEvents.bind(this, event);
1031
+ this.iconsContainer.appendChild(closeFullscreenIcon);
1032
+ }
1033
+ }, {
1034
+ key: "add360ViewIcon",
1035
+ value: function add360ViewIcon() {
1036
+ this.view360Icon = (0, _utils.create360ViewIcon)();
1037
+ this.innerBox.appendChild(this.view360Icon);
1038
+ }
1039
+ }, {
1040
+ key: "addFullscreenIcon",
1041
+ value: function addFullscreenIcon() {
1042
+ this.fullscreenIcon = (0, _utils.createFullscreenIcon)();
1043
+ this.fullscreenIcon.onclick = this.openFullscreenModal.bind(this);
1044
+ this.iconsContainer.appendChild(this.fullscreenIcon);
1045
+ }
1046
+ }, {
1047
+ key: "showFullscreenIcon",
1048
+ value: function showFullscreenIcon() {
1049
+ if (!this.fullscreenIcon) return;
1050
+ this.fullscreenIcon.style.display = 'block';
1051
+ this.fullscreenIcon.style.pointerEvents = 'auto';
1052
+ }
1053
+ }, {
1054
+ key: "hideFullscreenIcon",
1055
+ value: function hideFullscreenIcon() {
1056
+ if (!this.fullscreenIcon) return;
1057
+ this.fullscreenIcon.style.display = 'none';
1058
+ this.fullscreenIcon.style.pointerEvents = 'none';
1059
+ }
1060
+ }, {
1061
+ key: "addMagnifier",
1062
+ value: function addMagnifier() {
1063
+ this.magnifierIcon = (0, _utils.createMagnifierIcon)();
1064
+ this.magnifierIcon.onclick = this.magnify.bind(this);
1065
+ this.iconsContainer.appendChild(this.magnifierIcon);
1066
+ }
1067
+ }, {
1068
+ key: "enableMagnifierIcon",
1069
+ value: function enableMagnifierIcon() {
1070
+ if (!this.magnifierIcon) return;
1071
+ this.magnifierIcon.style.display = 'block';
1072
+ this.magnifierIcon.style.pointerEvents = 'auto';
1073
+ }
1074
+ }, {
1075
+ key: "disableMagnifierIcon",
1076
+ value: function disableMagnifierIcon() {
1077
+ if (!this.magnifierIcon) return;
1078
+ this.magnifierIcon.style.display = 'none';
1079
+ this.magnifierIcon.style.pointerEvents = 'none';
1080
+ }
1081
+ }, {
1082
+ key: "closeFullscreenModal",
1083
+ value: function closeFullscreenModal(event) {
1084
+ event.stopPropagation();
1085
+ document.body.removeChild(this.container.parentNode);
1086
+ window.document.body.style.overflow = 'visible';
1087
+ }
1088
+ }, {
1089
+ key: "add360ViewCircleIcon",
1090
+ value: function add360ViewCircleIcon() {
1091
+ this.view360CircleIcon = (0, _utils.create360ViewCircleIcon)(this.bottomCircleOffset);
1092
+ this.innerBox.appendChild(this.view360CircleIcon);
1093
+ }
1094
+ }, {
1095
+ key: "show360ViewCircleIcon",
1096
+ value: function show360ViewCircleIcon() {
1097
+ if (!this.view360CircleIcon) return;
1098
+ this.view360CircleIcon.style.opacity = '1';
1099
+ }
1100
+ }, {
1101
+ key: "hide360ViewCircleIcon",
1102
+ value: function hide360ViewCircleIcon() {
1103
+ if (!this.view360CircleIcon) return;
1104
+ this.view360CircleIcon.style.opacity = '0';
1105
+ }
1106
+ }, {
1107
+ key: "remove360ViewCircleIcon",
1108
+ value: function remove360ViewCircleIcon() {
1109
+ if (!this.view360CircleIcon) return;
1110
+ this.innerBox.removeChild(this.view360CircleIcon);
1111
+ this.view360CircleIcon = null;
1112
+ }
1113
+ }, {
1114
+ key: "removeLoader",
1115
+ value: function removeLoader() {
1116
+ if (!this.loader) return;
1117
+ this.innerBox.removeChild(this.loader);
1118
+ this.loader = null;
1119
+ }
1120
+ }, {
1121
+ key: "remove360ViewIcon",
1122
+ value: function remove360ViewIcon() {
1123
+ if (!this.view360Icon) return;
1124
+
1125
+ try {
1126
+ this.innerBox.removeChild(this.view360Icon);
1127
+ this.view360Icon = null;
1128
+ } catch (_unused) {}
1129
+ }
1130
+ }, {
1131
+ key: "initControls",
1411
1132
  value: function initControls() {
1412
1133
  var _this6 = this;
1413
1134
 
1414
- var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
1415
- // TODO [deprecated]: remove .cloud-360-left, .cloud-360-right in the upcoming versions
1416
- var left = this.container.querySelector('.cloudimage-360-left') || this.container.querySelector('.cloudimage-360-prev');
1417
- var right = this.container.querySelector('.cloudimage-360-right') || this.container.querySelector('.cloudimage-360-next');
1418
-
1419
- var top = this.container.querySelector('.cloudimage-360-top');
1420
- var bottom = this.container.querySelector('.cloudimage-360-bottom');
1421
-
1422
- if (!left && !right && !top && !bottom) return;
1423
-
1424
1135
  var onLeftStart = function onLeftStart(event) {
1425
1136
  event.stopPropagation();
1137
+
1426
1138
  _this6.onSpin();
1139
+
1427
1140
  _this6.left();
1141
+
1428
1142
  _this6.loopTimeoutId = window.setInterval(_this6.left.bind(_this6), _this6.autoplaySpeed);
1429
1143
  };
1144
+
1430
1145
  var onRightStart = function onRightStart(event) {
1431
1146
  event.stopPropagation();
1147
+
1432
1148
  _this6.onSpin();
1149
+
1433
1150
  _this6.right();
1151
+
1434
1152
  _this6.loopTimeoutId = window.setInterval(_this6.right.bind(_this6), _this6.autoplaySpeed);
1435
1153
  };
1436
1154
 
1437
1155
  var onTopStart = function onTopStart(event) {
1438
1156
  event.stopPropagation();
1157
+
1439
1158
  _this6.onSpin();
1159
+
1440
1160
  _this6.top();
1161
+
1441
1162
  _this6.loopTimeoutId = window.setInterval(_this6.top.bind(_this6), _this6.autoplaySpeed);
1442
1163
  };
1443
1164
 
1444
1165
  var onBottomStart = function onBottomStart(event) {
1445
1166
  event.stopPropagation();
1167
+
1446
1168
  _this6.onSpin();
1169
+
1447
1170
  _this6.bottom();
1171
+
1448
1172
  _this6.loopTimeoutId = window.setInterval(_this6.bottom.bind(_this6), _this6.autoplaySpeed);
1449
1173
  };
1450
1174
 
1451
- var onLeftEnd = function onLeftEnd() {
1175
+ var onEventEnd = function onEventEnd() {
1452
1176
  _this6.onFinishSpin();
1453
- window.clearTimeout(_this6.loopTimeoutId);
1454
- };
1455
1177
 
1456
- var onRightEnd = function onRightEnd() {
1457
- _this6.onFinishSpin();
1458
1178
  window.clearTimeout(_this6.loopTimeoutId);
1459
1179
  };
1460
1180
 
1461
- var onTopEnd = function onTopEnd() {
1462
- _this6.onFinishSpin();
1463
- window.clearTimeout(_this6.loopTimeoutId);
1181
+ var controlsConfig = {
1182
+ container: this.container,
1183
+ controlReverse: this.controlReverse,
1184
+ spinReverse: this.spinReverse,
1185
+ stopAtEdges: this.stopAtEdges
1464
1186
  };
1465
-
1466
- var onBottomEnd = function onBottomEnd() {
1467
- _this6.onFinishSpin();
1468
- window.clearTimeout(_this6.loopTimeoutId);
1187
+ var controlsTriggers = {
1188
+ onLeftStart: onLeftStart,
1189
+ onRightStart: onRightStart,
1190
+ onTopStart: onTopStart,
1191
+ onBottomStart: onBottomStart,
1192
+ onEventEnd: onEventEnd
1469
1193
  };
1470
-
1471
- if (left) {
1472
- left.style.display = 'block';
1473
- left.addEventListener('mousedown', isReverse ? onRightStart : onLeftStart);
1474
- left.addEventListener('touchstart', isReverse ? onRightStart : onLeftStart, { passive: true });
1475
- left.addEventListener('mouseup', isReverse ? onRightEnd : onLeftEnd);
1476
- left.addEventListener('touchend', isReverse ? onRightEnd : onLeftEnd);
1477
-
1478
- this.leftElem = left;
1479
- }
1480
-
1481
- if (right) {
1482
- right.style.display = 'block';
1483
- right.addEventListener('mousedown', isReverse ? onLeftStart : onRightStart);
1484
- right.addEventListener('touchstart', isReverse ? onLeftStart : onRightStart, { passive: true });
1485
- right.addEventListener('mouseup', isReverse ? onLeftEnd : onRightEnd);
1486
- right.addEventListener('touchend', isReverse ? onLeftEnd : onRightEnd);
1487
-
1488
- this.rightElem = right;
1489
- }
1490
-
1491
- if (top) {
1492
- top.style.display = 'block';
1493
- top.addEventListener('mousedown', isReverse ? onBottomStart : onTopStart);
1494
- top.addEventListener('touchstart', isReverse ? onBottomStart : onTopStart);
1495
- top.addEventListener('mouseup', isReverse ? onBottomEnd : onTopEnd);
1496
- top.addEventListener('touchend', isReverse ? onBottomEnd : onTopEnd);
1497
-
1498
- this.topElem = top;
1499
- }
1500
-
1501
- if (bottom) {
1502
- bottom.style.display = 'block';
1503
- bottom.addEventListener('mousedown', isReverse ? onTopStart : onBottomStart);
1504
- bottom.addEventListener('touchstart', isReverse ? onTopStart : onBottomStart);
1505
- bottom.addEventListener('mouseup', isReverse ? onTopEnd : onBottomEnd);
1506
- bottom.addEventListener('touchend', isReverse ? onTopEnd : onBottomEnd);
1507
-
1508
- this.bottomElem = bottom;
1509
- }
1510
-
1511
- if (isReverse ? right : left) {
1512
- if (this.stopAtEdges) {
1513
- (0, _ci.addClass)(isReverse ? right : left, 'not-active');
1514
- }
1515
- }
1516
- }
1517
- }, {
1518
- key: 'addInnerBox',
1519
- value: function addInnerBox() {
1520
- this.innerBox = document.createElement('div');
1521
- this.innerBox.className = 'cloudimage-360-inner-box';
1522
- this.container.appendChild(this.innerBox);
1523
- }
1524
- }, {
1525
- key: 'addIconsContainer',
1526
- value: function addIconsContainer() {
1527
- this.iconsContainer = document.createElement('div');
1528
- this.iconsContainer.className = 'cloudimage-360-icons-container';
1529
-
1530
- this.innerBox.appendChild(this.iconsContainer);
1531
- }
1532
- }, {
1533
- key: 'addCanvas',
1534
- value: function addCanvas() {
1535
- this.canvas = document.createElement('canvas');
1536
- this.canvas.style.width = '100%';
1537
- this.canvas.style.fontSize = '0';
1538
-
1539
- if (this.ratio) {
1540
- this.container.style.minHeight = this.container.offsetWidth * this.ratio + 'px';
1541
- this.canvas.height = parseInt(this.container.style.minHeight);
1542
- }
1543
-
1544
- this.innerBox.appendChild(this.canvas);
1194
+ var controlsElements = (0, _utils.initControls)(controlsConfig, controlsTriggers);
1195
+ this.topElem = controlsElements.top;
1196
+ this.bottomElem = controlsElements.bottom;
1197
+ this.leftElem = controlsElements.left;
1198
+ this.rightElem = controlsElements.right;
1545
1199
  }
1546
1200
  }, {
1547
- key: 'attachEvents',
1201
+ key: "attachEvents",
1548
1202
  value: function attachEvents(draggable, swipeable, keys) {
1549
- var _this7 = this;
1550
-
1551
- window.addEventListener('resize', (0, _ci.debounce)(function () {
1552
- _this7.requestResizedImages();
1553
- }, 300));
1203
+ window.addEventListener('resize', this.requestResizedImages.bind(this));
1554
1204
 
1555
1205
  if (draggable && !this.disableDrag) {
1206
+ this.container.addEventListener('click', this.mouseClick.bind(this));
1556
1207
  this.container.addEventListener('mousedown', this.mouseDown.bind(this));
1557
1208
  this.container.addEventListener('mousemove', this.mouseMove.bind(this));
1209
+ this.container.addEventListener('mouseleave', this.mouseLeave.bind(this));
1558
1210
  document.addEventListener('mouseup', this.mouseUp.bind(this));
1559
1211
  }
1560
1212
 
1561
1213
  if (swipeable && !this.disableDrag) {
1562
- this.container.addEventListener('touchstart', this.touchStart.bind(this), { passive: true });
1214
+ this.container.addEventListener('touchstart', this.touchStart.bind(this), {
1215
+ passive: true
1216
+ });
1563
1217
  this.container.addEventListener('touchend', this.touchEnd.bind(this));
1564
- this.container.addEventListener('touchmove', this.touchMove.bind(this), { passive: true });
1565
- }
1566
-
1567
- if (!this.disablePointerZoom && !this.fullscreenView) {
1568
- this.container.addEventListener('wheel', this.mouseScroll.bind(this));
1218
+ this.container.addEventListener('touchmove', this.touchMove.bind(this));
1569
1219
  }
1570
1220
 
1571
1221
  if (keys) {
1572
1222
  document.addEventListener('keydown', this.keyDown.bind(this));
1573
1223
  document.addEventListener('keyup', this.keyUp.bind(this));
1574
- } else {
1575
- document.addEventListener('keydown', this.keyDownGeneral.bind(this));
1576
1224
  }
1577
- }
1578
- }, {
1579
- key: 'applyStylesToContainer',
1580
- value: function applyStylesToContainer() {
1581
- this.container.style.position = 'relative';
1582
- this.container.style.width = '100%';
1583
- this.container.style.cursor = 'wait';
1584
- this.container.setAttribute('draggable', 'false');
1585
- this.container.className = this.container.className + ' initialized';
1586
- }
1587
- }, {
1588
- key: 'setMouseLeaveActions',
1589
- value: function setMouseLeaveActions(actions) {
1590
- var _this8 = this;
1591
-
1592
- var mouseLeaveActions = actions.split(',');
1593
1225
 
1594
- mouseLeaveActions.forEach(function (action) {
1595
- return _this8.applyMouseLeaveAction(action);
1596
- });
1597
- }
1598
- }, {
1599
- key: 'applyMouseLeaveAction',
1600
- value: function applyMouseLeaveAction(action) {
1601
- switch (action) {
1602
- case _ci2.MOUSE_LEAVE_ACTIONS.RESET_ZOOM:
1603
- this.container.addEventListener('mouseleave', this.resetZoom.bind(this));
1604
- break;
1605
- }
1226
+ document.addEventListener('keydown', this.keyDownGeneral.bind(this));
1606
1227
  }
1607
1228
  }, {
1608
- key: 'init',
1229
+ key: "init",
1609
1230
  value: function init(container) {
1231
+ var _this7 = this;
1232
+
1233
+ var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1234
+
1610
1235
  var _get360ViewProps = (0, _ci.get360ViewProps)(container),
1611
1236
  folder = _get360ViewProps.folder,
1237
+ apiVersion = _get360ViewProps.apiVersion,
1612
1238
  filenameX = _get360ViewProps.filenameX,
1613
1239
  filenameY = _get360ViewProps.filenameY,
1614
- imageList = _get360ViewProps.imageList,
1240
+ imageListX = _get360ViewProps.imageListX,
1241
+ imageListY = _get360ViewProps.imageListY,
1615
1242
  indexZeroBase = _get360ViewProps.indexZeroBase,
1616
1243
  amountX = _get360ViewProps.amountX,
1617
1244
  amountY = _get360ViewProps.amountY,
1618
- imageOffset = _get360ViewProps.imageOffset,
1619
1245
  _get360ViewProps$drag = _get360ViewProps.draggable,
1620
- draggable = _get360ViewProps$drag === undefined ? true : _get360ViewProps$drag,
1246
+ draggable = _get360ViewProps$drag === void 0 ? true : _get360ViewProps$drag,
1621
1247
  _get360ViewProps$swip = _get360ViewProps.swipeable,
1622
- swipeable = _get360ViewProps$swip === undefined ? true : _get360ViewProps$swip,
1248
+ swipeable = _get360ViewProps$swip === void 0 ? true : _get360ViewProps$swip,
1623
1249
  keys = _get360ViewProps.keys,
1250
+ keysReverse = _get360ViewProps.keysReverse,
1624
1251
  bottomCircle = _get360ViewProps.bottomCircle,
1625
1252
  bottomCircleOffset = _get360ViewProps.bottomCircleOffset,
1626
1253
  boxShadow = _get360ViewProps.boxShadow,
1627
1254
  autoplay = _get360ViewProps.autoplay,
1628
1255
  autoplayBehavior = _get360ViewProps.autoplayBehavior,
1629
1256
  playOnce = _get360ViewProps.playOnce,
1630
- pointerZoomFactor = _get360ViewProps.pointerZoomFactor,
1631
- pinchZoomFactor = _get360ViewProps.pinchZoomFactor,
1632
- maxScale = _get360ViewProps.maxScale,
1633
- toStartPointerZoom = _get360ViewProps.toStartPointerZoom,
1634
- onMouseLeave = _get360ViewProps.onMouseLeave,
1635
- _get360ViewProps$disa = _get360ViewProps.disablePointerZoom,
1636
- disablePointerZoom = _get360ViewProps$disa === undefined ? true : _get360ViewProps$disa,
1637
- _get360ViewProps$disa2 = _get360ViewProps.disablePinchZoom,
1638
- disablePinchZoom = _get360ViewProps$disa2 === undefined ? true : _get360ViewProps$disa2,
1639
1257
  speed = _get360ViewProps.speed,
1640
1258
  autoplayReverse = _get360ViewProps.autoplayReverse,
1641
- _get360ViewProps$disa3 = _get360ViewProps.disableDrag,
1642
- disableDrag = _get360ViewProps$disa3 === undefined ? true : _get360ViewProps$disa3,
1259
+ _get360ViewProps$disa = _get360ViewProps.disableDrag,
1260
+ disableDrag = _get360ViewProps$disa === void 0 ? true : _get360ViewProps$disa,
1643
1261
  fullscreen = _get360ViewProps.fullscreen,
1644
1262
  magnifier = _get360ViewProps.magnifier,
1645
- magnifyInFullscreen = _get360ViewProps.magnifyInFullscreen,
1646
- ratio = _get360ViewProps.ratio,
1647
- responsive = _get360ViewProps.responsive,
1648
1263
  ciToken = _get360ViewProps.ciToken,
1649
1264
  ciFilters = _get360ViewProps.ciFilters,
1650
1265
  ciTransformation = _get360ViewProps.ciTransformation,
@@ -1655,76 +1270,176 @@ var CI360Viewer = function () {
1655
1270
  stopAtEdges = _get360ViewProps.stopAtEdges,
1656
1271
  controlReverse = _get360ViewProps.controlReverse,
1657
1272
  hide360Logo = _get360ViewProps.hide360Logo,
1658
- logoSrc = _get360ViewProps.logoSrc;
1659
-
1660
- var ciParams = { ciToken: ciToken, ciFilters: ciFilters, ciTransformation: ciTransformation };
1661
-
1662
- this.addInnerBox();
1663
- this.addIconsContainer();
1664
- this.addLoader();
1273
+ logoSrc = _get360ViewProps.logoSrc,
1274
+ pointerZoom = _get360ViewProps.pointerZoom,
1275
+ ratio = _get360ViewProps.ratio,
1276
+ _get360ViewProps$imag = _get360ViewProps.imageInfo,
1277
+ imageInfo = _get360ViewProps$imag === void 0 ? 'black' : _get360ViewProps$imag;
1665
1278
 
1279
+ var ciParams = {
1280
+ ciToken: ciToken,
1281
+ ciFilters: ciFilters,
1282
+ ciTransformation: ciTransformation
1283
+ };
1666
1284
  this.folder = folder;
1285
+ this.apiVersion = apiVersion;
1667
1286
  this.filenameX = filenameX;
1668
1287
  this.filenameY = filenameY;
1669
- this.imageList = imageList;
1288
+ this.imageListX = imageListX;
1289
+ this.imageListY = imageListY;
1670
1290
  this.indexZeroBase = indexZeroBase;
1671
- this.amountX = amountX;
1672
- this.amountY = amountY;
1673
- this.allowSpinY = !!amountY && !!filenameY;
1674
- this.activeImageX = autoplayReverse ? amountX : 1;
1675
- this.activeImageY = autoplayReverse ? amountY : 1;
1676
- this.spinY = autoplayBehavior === _ci2.AUTOPLAY_BEHAVIOR.SPIN_YX ? true : false;
1677
- this.imageOffset = imageOffset;
1291
+ this.amountX = imageListX ? JSON.parse(imageListX).length : amountX;
1292
+ this.amountY = imageListY ? JSON.parse(imageListY).length : amountY;
1293
+ this.allowSpinY = !!this.amountY;
1294
+ this.activeImageX = autoplayReverse ? this.amountX : 1;
1295
+ this.activeImageY = autoplayReverse ? this.amountY : 1;
1296
+ this.spinY = autoplayBehavior === _constants.AUTOPLAY_BEHAVIOR.SPIN_YX ? true : false;
1678
1297
  this.bottomCircle = bottomCircle;
1679
1298
  this.bottomCircleOffset = bottomCircleOffset;
1680
1299
  this.boxShadow = boxShadow;
1681
1300
  this.autoplay = autoplay;
1682
1301
  this.autoplayBehavior = autoplayBehavior;
1683
1302
  this.playOnce = playOnce;
1684
- this.toStartPointerZoom = toStartPointerZoom, this.disablePointerZoom = disablePointerZoom;
1685
- this.disablePinchZoom = disablePinchZoom;
1686
- this.pointerZoomFactor = pointerZoomFactor;
1687
- this.pinchZoomFactor = pinchZoomFactor;
1688
- this.maxScale = maxScale;
1689
1303
  this.speed = speed;
1690
1304
  this.reversed = autoplayReverse;
1691
1305
  this.disableDrag = disableDrag;
1692
1306
  this.fullscreen = fullscreen;
1693
- this.magnifier = !this.isMobile && magnifier ? magnifier : false;
1694
- this.magnifyInFullscreen = magnifyInFullscreen;
1695
- this.lazyload = lazyload;
1307
+ this.magnifier = !this.isMobile && magnifier > 1 ? Math.min(magnifier, 5) : 0;
1696
1308
  this.lazySelector = lazySelector;
1697
- this.ratio = ratio;
1698
1309
  this.spinReverse = spinReverse;
1699
1310
  this.controlReverse = controlReverse;
1700
- this.dragSpeed = dragSpeed;
1311
+ this.dragSpeed = Math.max(dragSpeed, 50);
1701
1312
  this.autoplaySpeed = this.speed * 36 / this.amountX;
1702
1313
  this.stopAtEdges = stopAtEdges;
1703
1314
  this.hide360Logo = hide360Logo;
1704
1315
  this.logoSrc = logoSrc;
1705
- this.responsive = responsive;
1706
1316
  this.ciParams = ciParams;
1317
+ this.apiVersion = apiVersion;
1318
+ this.pointerZoom = pointerZoom > 1 ? Math.min(pointerZoom, 3) : 0;
1319
+ this.keysReverse = keysReverse;
1320
+ this.info = imageInfo;
1321
+ this.keys = keys;
1322
+ this.ratio = ratio && JSON.parse(ratio);
1323
+
1324
+ if (update) {
1325
+ (0, _utils.removeChildFromParent)(this.innerBox, this.iconsContainer);
1326
+ (0, _utils.removeChildFromParent)(this.innerBox, this.boxShadowEl);
1327
+ (0, _utils.removeChildFromParent)(this.innerBox, this.view360Icon);
1328
+ this.remove360ViewCircleIcon();
1329
+ this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
1330
+
1331
+ if (!this.hide360Logo && !this.lazyload && this.logoSrc) {
1332
+ this.add360ViewIcon();
1333
+ (0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
1334
+ }
1335
+
1336
+ if (this.magnifier) {
1337
+ this.addMagnifier();
1338
+ }
1339
+
1340
+ if (this.bottomCircle && !this.fullscreenView) {
1341
+ this.add360ViewCircleIcon();
1342
+ }
1707
1343
 
1708
- this.applyStylesToContainer();
1344
+ if (this.fullscreen && !this.fullscreenView) {
1345
+ this.addFullscreenIcon();
1346
+ }
1709
1347
 
1710
- this.addCanvas();
1348
+ if (this.boxShadow && !this.fullscreenView) {
1349
+ this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
1350
+ }
1711
1351
 
1712
- var srcX = this.getSrc(responsive, container, folder, filenameX, ciParams);
1713
- var srcY = this.getSrc(responsive, container, folder, filenameY, ciParams);
1352
+ return this.onAllImagesLoaded();
1353
+ }
1714
1354
 
1715
- this.preloadImages(amountX, srcX, _ci2.ORIENTATIONS.X, lazyload, lazySelector, container, responsive, ciParams);
1355
+ this.innerBox = (0, _utils.createInnerBox)(this.container);
1356
+ this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
1357
+ this.canvas = (0, _utils.createCanvas)(this.innerBox);
1358
+ this.loader = (0, _utils.createLoader)(this.innerBox);
1716
1359
 
1717
- if (amountY) {
1718
- this.preloadImages(amountY, srcY, _ci2.ORIENTATIONS.Y, lazyload, lazySelector, container, responsive, ciParams);
1360
+ if (this.hotspotsConfigs && !this.fullscreenView) {
1361
+ (0, _utils.createHotspots)(container, this.hotspotsConfigs);
1719
1362
  }
1720
1363
 
1721
- this.attachEvents(draggable, swipeable, keys);
1364
+ (0, _utils.applyStylesToContainer)(this.container);
1365
+ this.srcXConfig = {
1366
+ folder: folder,
1367
+ filename: filenameX,
1368
+ imageList: imageListX,
1369
+ container: container,
1370
+ innerBox: this.innerBox,
1371
+ apiVersion: apiVersion,
1372
+ ciParams: ciParams,
1373
+ lazySelector: lazySelector,
1374
+ amount: this.amountX,
1375
+ indexZeroBase: indexZeroBase,
1376
+ fullscreen: this.fullscreenView
1377
+ };
1378
+ this.srcYConfig = _objectSpread(_objectSpread({}, this.srcXConfig), {}, {
1379
+ filename: filenameY,
1380
+ orientation: _constants.ORIENTATIONS.Y,
1381
+ imageList: imageListY,
1382
+ amount: this.amountY
1383
+ });
1384
+ var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
1385
+
1386
+ var onImageLoad = function onImageLoad(orientation, image, index) {
1387
+ if (orientation !== _constants.ORIENTATIONS.Y) {
1388
+ _this7.imagesX[index] = image;
1389
+ } else {
1390
+ _this7.imagesY[index] = image;
1391
+ }
1392
+
1393
+ var loadedXImages = _this7.imagesX.filter(function (image) {
1394
+ return image;
1395
+ });
1396
+
1397
+ var loadedYImages = _this7.imagesY.filter(function (image) {
1398
+ return image;
1399
+ });
1400
+
1401
+ var totalAmount = _this7.amountX + _this7.amountY;
1402
+ var totalLoadedImages = loadedXImages.length + loadedYImages.length;
1403
+ var isFirstImageLoaded = !index && orientation !== _constants.ORIENTATIONS.Y;
1404
+ var percentage = Math.round(totalLoadedImages / totalAmount * 100);
1405
+
1406
+ _this7.updatePercentageInLoader(percentage);
1722
1407
 
1723
- if (onMouseLeave) this.setMouseLeaveActions(onMouseLeave);
1408
+ if (isFirstImageLoaded) {
1409
+ _this7.onFirstImageLoaded(image);
1410
+ }
1411
+
1412
+ if (_this7.isReady()) {
1413
+ _this7.onAllImagesLoaded();
1414
+ }
1415
+ };
1416
+
1417
+ var loadImages = function loadImages() {
1418
+ (0, _utils.preloadImages)(_this7.srcXConfig, srcX, onImageLoad.bind(_this7, _constants.ORIENTATIONS.X));
1419
+
1420
+ if (_this7.allowSpinY) {
1421
+ var srcY = (0, _utils.generateImagesPath)(_this7.srcYConfig);
1422
+ (0, _utils.preloadImages)(_this7.srcYConfig, srcY, onImageLoad.bind(_this7, _constants.ORIENTATIONS.Y));
1423
+ }
1424
+ };
1425
+
1426
+ if (lazyload) {
1427
+ var onFirstImageLoad = function onFirstImageLoad(image) {
1428
+ _this7.innerBox.removeChild(image);
1429
+
1430
+ loadImages();
1431
+ };
1432
+
1433
+ (0, _utils.initLazyload)(srcX, this.srcXConfig, onFirstImageLoad);
1434
+ } else {
1435
+ loadImages();
1436
+ }
1437
+
1438
+ this.attachEvents(draggable, swipeable, keys);
1724
1439
  }
1725
1440
  }]);
1726
-
1727
1441
  return CI360Viewer;
1728
1442
  }();
1729
1443
 
1730
- exports.default = CI360Viewer;
1444
+ var _default = CI360Viewer;
1445
+ exports.default = _default;