js-cloudimage-360-view 3.0.0-beta.0 → 3.0.1

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