js-cloudimage-360-view 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +547 -0
- package/dist/ci360.constants.js +31 -0
- package/dist/ci360.service.js +1637 -0
- package/dist/ci360.utils.js +250 -0
- package/dist/index.js +57 -0
- package/dist/static/css/style.css +121 -0
- package/package.json +59 -0
|
@@ -0,0 +1,1637 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
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"); } }; }();
|
|
8
|
+
|
|
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; }; }();
|
|
10
|
+
|
|
11
|
+
var _ci = require('./ci360.utils');
|
|
12
|
+
|
|
13
|
+
var _ci2 = require('./ci360.constants');
|
|
14
|
+
|
|
15
|
+
require('./static/css/style.css');
|
|
16
|
+
|
|
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); } }
|
|
18
|
+
|
|
19
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
+
|
|
21
|
+
var CI360Viewer = function () {
|
|
22
|
+
function CI360Viewer(container, fullscreen, ratio) {
|
|
23
|
+
_classCallCheck(this, CI360Viewer);
|
|
24
|
+
|
|
25
|
+
this.container = container;
|
|
26
|
+
this.movementStart = { x: 0, y: 0 };
|
|
27
|
+
this.isStartSpin = false;
|
|
28
|
+
this.movingDirection = _ci2.ORIENTATIONS.CENTER;
|
|
29
|
+
this.isClicked = false;
|
|
30
|
+
this.loadedImagesX = 0;
|
|
31
|
+
this.loadedImagesY = 0;
|
|
32
|
+
this.imagesLoaded = false;
|
|
33
|
+
this.reversed = false;
|
|
34
|
+
this.fullscreenView = !!fullscreen;
|
|
35
|
+
this.ratio = ratio;
|
|
36
|
+
this.imagesX = [];
|
|
37
|
+
this.imagesY = [];
|
|
38
|
+
this.originalImagesX = [];
|
|
39
|
+
this.originalImagesY = [];
|
|
40
|
+
this.devicePixelRatio = Math.round(window.devicePixelRatio || 1);
|
|
41
|
+
this.isMobile = !!('ontouchstart' in window || navigator.msMaxTouchPoints);
|
|
42
|
+
this.id = container.id;
|
|
43
|
+
this.init(container);
|
|
44
|
+
this.clickedToZoom = false;
|
|
45
|
+
this.isMagnifyOpen = false;
|
|
46
|
+
this.startPointerZoom = false;
|
|
47
|
+
this.zoomIntensity = 0;
|
|
48
|
+
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;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_createClass(CI360Viewer, [{
|
|
56
|
+
key: 'mouseDown',
|
|
57
|
+
value: function mouseDown(event) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
|
|
60
|
+
var pageX = event.pageX,
|
|
61
|
+
pageY = event.pageY;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if (!this.imagesLoaded) return;
|
|
65
|
+
|
|
66
|
+
this.hideInitialIcons();
|
|
67
|
+
|
|
68
|
+
if (this.autoplay || this.loopTimeoutId) {
|
|
69
|
+
this.stop();
|
|
70
|
+
this.autoplay = false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this.intialPositions = { x: pageX, y: pageY };
|
|
74
|
+
this.movementStart = { x: pageX, y: pageY };
|
|
75
|
+
this.isClicked = true;
|
|
76
|
+
this.clickedToZoom = true;
|
|
77
|
+
this.container.style.cursor = 'grabbing';
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: 'mouseUp',
|
|
81
|
+
value: function mouseUp() {
|
|
82
|
+
if (!this.imagesLoaded || !this.isClicked) return;
|
|
83
|
+
|
|
84
|
+
this.movementStart = { x: 0, y: 0 };
|
|
85
|
+
this.isStartSpin = false;
|
|
86
|
+
this.isClicked = false;
|
|
87
|
+
this.container.style.cursor = 'grab';
|
|
88
|
+
|
|
89
|
+
if (this.bottomCircle && !this.zoomIntensity) {
|
|
90
|
+
this.show360ViewCircleIcon();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: 'mouseMove',
|
|
95
|
+
value: function mouseMove(event) {
|
|
96
|
+
if (!this.imagesLoaded) return;
|
|
97
|
+
|
|
98
|
+
var pageX = event.pageX,
|
|
99
|
+
pageY = event.pageY;
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if (this.mouseTracked) {
|
|
103
|
+
this.setCursorPosition(event);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (this.isClicked) {
|
|
107
|
+
var nextPositions = { x: pageX, y: pageY };
|
|
108
|
+
|
|
109
|
+
this.updateMovingDirection(this.intialPositions, nextPositions);
|
|
110
|
+
this.onMoveHandler(event);
|
|
111
|
+
} else if (this.zoomIntensity) {
|
|
112
|
+
this.update();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
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;
|
|
123
|
+
|
|
124
|
+
if (differenceInPositionX > sensitivity) this.movingDirection = _ci2.ORIENTATIONS.X;
|
|
125
|
+
|
|
126
|
+
if (differenceInPositionY > sensitivity && this.allowSpinY) this.movingDirection = _ci2.ORIENTATIONS.Y;
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: 'mouseScroll',
|
|
130
|
+
value: function mouseScroll(event) {
|
|
131
|
+
if (this.disablePointerZoom || this.isMagnifyOpen) return;
|
|
132
|
+
|
|
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;
|
|
135
|
+
|
|
136
|
+
if (isClickedToZoom || isScrolledToZoom) {
|
|
137
|
+
this.initMouseScrollZoom(event);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: 'touchStart',
|
|
142
|
+
value: function touchStart(event) {
|
|
143
|
+
if (!this.imagesLoaded) return;
|
|
144
|
+
|
|
145
|
+
var isPinchZoom = !this.disablePinchZoom && (0, _ci.isTwoFingers)(event) && !this.isMagnifyOpen;
|
|
146
|
+
|
|
147
|
+
if (isPinchZoom) {
|
|
148
|
+
this.initAndSetPinchZoom(event);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
this.hideInitialIcons();
|
|
152
|
+
|
|
153
|
+
if (this.autoplay || this.loopTimeoutId) {
|
|
154
|
+
this.stop();
|
|
155
|
+
this.autoplay = false;
|
|
156
|
+
}
|
|
157
|
+
|
|
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 };
|
|
160
|
+
this.isClicked = true;
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: 'touchEnd',
|
|
164
|
+
value: function touchEnd() {
|
|
165
|
+
if (!this.imagesLoaded) return;
|
|
166
|
+
|
|
167
|
+
if (this.zoomIntensity) this.resetZoom();
|
|
168
|
+
|
|
169
|
+
this.movementStart = { x: 0, y: 0 };
|
|
170
|
+
this.isStartSpin = false;
|
|
171
|
+
this.isClicked = false;
|
|
172
|
+
|
|
173
|
+
if (this.bottomCircle) this.show360ViewCircleIcon();
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: 'touchMove',
|
|
177
|
+
value: function touchMove(event) {
|
|
178
|
+
if (!this.isClicked || !this.imagesLoaded) return;
|
|
179
|
+
|
|
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);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
key: 'keyDownGeneral',
|
|
191
|
+
value: function keyDownGeneral() {
|
|
192
|
+
if (!this.imagesLoaded) return;
|
|
193
|
+
|
|
194
|
+
if (this.glass) {
|
|
195
|
+
this.closeMagnifier();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: 'hideInitialIcons',
|
|
200
|
+
value: function hideInitialIcons() {
|
|
201
|
+
if (this.glass) {
|
|
202
|
+
this.closeMagnifier();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (this.view360Icon) {
|
|
206
|
+
this.remove360ViewIcon();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
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',
|
|
221
|
+
value: function setCursorPosition(event) {
|
|
222
|
+
this.mousePositions = {
|
|
223
|
+
x: event.clientX,
|
|
224
|
+
y: event.clientY
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
key: 'getCursorPositionInCanvas',
|
|
229
|
+
value: function getCursorPositionInCanvas() {
|
|
230
|
+
var canvasRect = this.canvas.getBoundingClientRect();
|
|
231
|
+
|
|
232
|
+
this.pointerCurrentPosition = {
|
|
233
|
+
x: this.mousePositions.x - canvasRect.left,
|
|
234
|
+
y: this.mousePositions.y - canvasRect.top
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
return this.pointerCurrentPosition;
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
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();
|
|
261
|
+
|
|
262
|
+
this.startPointerZoom = false;
|
|
263
|
+
this.mouseTracked = false;
|
|
264
|
+
}
|
|
265
|
+
|
|
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;
|
|
334
|
+
}
|
|
335
|
+
|
|
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();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}, {
|
|
355
|
+
key: 'keyDown',
|
|
356
|
+
value: function keyDown(event) {
|
|
357
|
+
if (!this.imagesLoaded) return;
|
|
358
|
+
|
|
359
|
+
if (this.glass) {
|
|
360
|
+
this.closeMagnifier();
|
|
361
|
+
}
|
|
362
|
+
|
|
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();
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
this.onSpin();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: 'onSpin',
|
|
375
|
+
value: function onSpin() {
|
|
376
|
+
if (this.bottomCircle) {
|
|
377
|
+
this.hide360ViewCircleIcon();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (this.view360Icon) {
|
|
381
|
+
this.remove360ViewIcon();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (this.autoplay || this.loopTimeoutId) {
|
|
385
|
+
this.stop();
|
|
386
|
+
this.autoplay = false;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}, {
|
|
390
|
+
key: 'keyUp',
|
|
391
|
+
value: function keyUp(event) {
|
|
392
|
+
if (!this.imagesLoaded) return;
|
|
393
|
+
|
|
394
|
+
if ([37, 39].indexOf(event.keyCode) !== -1) {
|
|
395
|
+
this.onFinishSpin();
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: 'onFinishSpin',
|
|
400
|
+
value: function onFinishSpin() {
|
|
401
|
+
if (this.bottomCircle) this.show360ViewCircleIcon();
|
|
402
|
+
}
|
|
403
|
+
}, {
|
|
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',
|
|
480
|
+
value: function moveActiveIndexUp(itemsSkipped) {
|
|
481
|
+
var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
|
|
482
|
+
|
|
483
|
+
if (this.stopAtEdges) {
|
|
484
|
+
var isReachedTheEdge = this.activeImageX + itemsSkipped >= this.amountX;
|
|
485
|
+
|
|
486
|
+
if (isReachedTheEdge) {
|
|
487
|
+
this.activeImageX = this.amountX;
|
|
488
|
+
|
|
489
|
+
if (isReverse ? this.prevElem : this.rightElem) {
|
|
490
|
+
(0, _ci.addClass)(isReverse ? this.leftElem : this.leftElem, 'not-active');
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
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');
|
|
498
|
+
}
|
|
499
|
+
} else {
|
|
500
|
+
this.activeImageX = (this.activeImageX + itemsSkipped) % this.amountX || this.amountX;
|
|
501
|
+
|
|
502
|
+
if (this.activeImageX === this.amountX && this.allowSpinY) this.spinY = true;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}, {
|
|
506
|
+
key: 'moveActiveIndexDown',
|
|
507
|
+
value: function moveActiveIndexDown(itemsSkipped) {
|
|
508
|
+
var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
|
|
509
|
+
|
|
510
|
+
if (this.stopAtEdges) {
|
|
511
|
+
var isReachedTheEdge = this.activeImageX - itemsSkipped <= 1;
|
|
512
|
+
|
|
513
|
+
if (isReachedTheEdge) {
|
|
514
|
+
this.activeImageX = 1;
|
|
515
|
+
|
|
516
|
+
if (isReverse ? this.rightElem : this.leftElem) {
|
|
517
|
+
(0, _ci.addClass)(isReverse ? this.rightElem : this.leftElem, 'not-active');
|
|
518
|
+
}
|
|
519
|
+
} else {
|
|
520
|
+
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');
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
if (this.activeImageX - itemsSkipped < 1) {
|
|
528
|
+
this.activeImageX = this.amountX + (this.activeImageX - itemsSkipped);
|
|
529
|
+
this.spinY = true;
|
|
530
|
+
} else {
|
|
531
|
+
this.activeImageX -= itemsSkipped;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}, {
|
|
536
|
+
key: 'moveActiveYIndexUp',
|
|
537
|
+
value: function moveActiveYIndexUp(itemsSkipped) {
|
|
538
|
+
var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
|
|
539
|
+
|
|
540
|
+
if (this.stopAtEdges) {
|
|
541
|
+
var isReachedTheEdge = this.activeImageY + itemsSkipped >= this.amountY;
|
|
542
|
+
|
|
543
|
+
if (isReachedTheEdge) {
|
|
544
|
+
this.activeImageY = this.amountY;
|
|
545
|
+
|
|
546
|
+
if (isReverse ? this.bottomElem : this.topElem) {
|
|
547
|
+
(0, _ci.addClass)(isReverse ? this.bottomElem : this.topElem, 'not-active');
|
|
548
|
+
}
|
|
549
|
+
} else {
|
|
550
|
+
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');
|
|
555
|
+
}
|
|
556
|
+
} else {
|
|
557
|
+
this.activeImageY = (this.activeImageY + itemsSkipped) % this.amountY || this.amountY;
|
|
558
|
+
|
|
559
|
+
if (this.activeImageY === this.amountY) this.spinY = false;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}, {
|
|
563
|
+
key: 'moveActiveYIndexDown',
|
|
564
|
+
value: function moveActiveYIndexDown(itemsSkipped) {
|
|
565
|
+
var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
|
|
566
|
+
|
|
567
|
+
if (this.stopAtEdges) {
|
|
568
|
+
var isReachedTheEdge = this.activeImageY - itemsSkipped <= 1;
|
|
569
|
+
|
|
570
|
+
if (isReachedTheEdge) {
|
|
571
|
+
this.activeImageY = 1;
|
|
572
|
+
|
|
573
|
+
if (isReverse ? this.topElem : this.bottomElem) {
|
|
574
|
+
(0, _ci.addClass)(isReverse ? this.topElem : this.bottomElem, 'not-active');
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
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');
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
if (this.activeImageY - itemsSkipped < 1) {
|
|
584
|
+
this.activeImageY = this.amountY + (this.activeImageY - itemsSkipped);
|
|
585
|
+
this.spinY = false;
|
|
586
|
+
} else {
|
|
587
|
+
this.activeImageY -= itemsSkipped;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}, {
|
|
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);
|
|
627
|
+
this.update();
|
|
628
|
+
}
|
|
629
|
+
}, {
|
|
630
|
+
key: 'left',
|
|
631
|
+
value: function left() {
|
|
632
|
+
this.movingDirection = _ci2.ORIENTATIONS.X;
|
|
633
|
+
this.activeImageY = this.reversed ? this.amountY : 1;
|
|
634
|
+
|
|
635
|
+
this.moveActiveIndexDown(1);
|
|
636
|
+
this.update();
|
|
637
|
+
}
|
|
638
|
+
}, {
|
|
639
|
+
key: 'top',
|
|
640
|
+
value: function top() {
|
|
641
|
+
this.movingDirection = _ci2.ORIENTATIONS.Y;
|
|
642
|
+
this.activeImageX = this.reversed ? this.amountX : 1;
|
|
643
|
+
|
|
644
|
+
this.moveActiveYIndexUp(1);
|
|
645
|
+
this.update();
|
|
646
|
+
}
|
|
647
|
+
}, {
|
|
648
|
+
key: 'bottom',
|
|
649
|
+
value: function bottom() {
|
|
650
|
+
this.movingDirection = _ci2.ORIENTATIONS.Y;
|
|
651
|
+
this.activeImageX = this.reversed ? this.amountX : 1;
|
|
652
|
+
|
|
653
|
+
this.moveActiveYIndexDown(1);
|
|
654
|
+
this.update();
|
|
655
|
+
}
|
|
656
|
+
}, {
|
|
657
|
+
key: 'update',
|
|
658
|
+
value: function update() {
|
|
659
|
+
var image = this.imagesX[this.activeImageX - 1];
|
|
660
|
+
|
|
661
|
+
if (this.movingDirection === _ci2.ORIENTATIONS.Y) {
|
|
662
|
+
image = this.imagesY[this.activeImageY - 1];
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
var ctx = this.canvas.getContext("2d");
|
|
666
|
+
|
|
667
|
+
ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
|
|
668
|
+
|
|
669
|
+
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,
|
|
678
|
+
width = _contain.width,
|
|
679
|
+
height = _contain.height;
|
|
680
|
+
|
|
681
|
+
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
682
|
+
} 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) {
|
|
689
|
+
this.updateImageScale(ctx);
|
|
690
|
+
} else {
|
|
691
|
+
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}, {
|
|
696
|
+
key: 'updateImageScale',
|
|
697
|
+
value: function updateImageScale(ctx) {
|
|
698
|
+
var image = this.originalImagesX[this.activeImageX - 1];
|
|
699
|
+
|
|
700
|
+
if (this.movingDirection === _ci2.ORIENTATIONS.Y) {
|
|
701
|
+
image = this.originalImagesY[this.activeImageY - 1];
|
|
702
|
+
}
|
|
703
|
+
|
|
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
|
+
|
|
714
|
+
var pointX = 0 - position.x / imageWidth * (width - this.canvas.width);
|
|
715
|
+
var pointY = 0 - position.y / imageHeight * (height - this.canvas.height);
|
|
716
|
+
|
|
717
|
+
ctx.drawImage(image, pointX, pointY, width, height);
|
|
718
|
+
}
|
|
719
|
+
}, {
|
|
720
|
+
key: 'updatePercentageInLoader',
|
|
721
|
+
value: function updatePercentageInLoader(percentage) {
|
|
722
|
+
if (this.loader) {
|
|
723
|
+
this.loader.style.width = percentage + '%';
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (this.view360Icon) {
|
|
727
|
+
this.view360Icon.innerText = percentage + '%';
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}, {
|
|
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
|
+
}
|
|
776
|
+
|
|
777
|
+
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),
|
|
786
|
+
offsetX = _contain2.offsetX,
|
|
787
|
+
offsetY = _contain2.offsetY,
|
|
788
|
+
width = _contain2.width,
|
|
789
|
+
height = _contain2.height;
|
|
790
|
+
|
|
791
|
+
this.offset = { x: offsetX, y: offsetY };
|
|
792
|
+
|
|
793
|
+
ctx.drawImage(event.target, offsetX, offsetY, width, height);
|
|
794
|
+
} 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);
|
|
821
|
+
}
|
|
822
|
+
|
|
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
|
+
});
|
|
836
|
+
}
|
|
837
|
+
|
|
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) {
|
|
847
|
+
this.addMagnifier();
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
if (this.boxShadow && !this.fullscreenView) {
|
|
851
|
+
this.addBoxShadow();
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
if (this.bottomCircle && !this.fullscreenView) {
|
|
855
|
+
this.add360ViewCircleIcon();
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (this.fullscreen && !this.fullscreenView) {
|
|
859
|
+
this.addFullscreenIcon();
|
|
860
|
+
}
|
|
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
|
+
}
|
|
875
|
+
}, {
|
|
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
|
+
}
|
|
890
|
+
|
|
891
|
+
if (totalLoadedImages === totalAmount) {
|
|
892
|
+
this.onAllImagesLoaded(event);
|
|
893
|
+
}
|
|
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
|
+
|
|
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');
|
|
1097
|
+
|
|
1098
|
+
resetZoomIcon.className = 'cloudimage-360-reset-zoom-icon';
|
|
1099
|
+
this.resetZoomIcon = resetZoomIcon;
|
|
1100
|
+
|
|
1101
|
+
resetZoomIcon.onmouseenter = this.resetZoom.bind(this);
|
|
1102
|
+
|
|
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();
|
|
1111
|
+
|
|
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();
|
|
1120
|
+
|
|
1121
|
+
this.resetZoomIcon.style.display = 'block';
|
|
1122
|
+
}
|
|
1123
|
+
}, {
|
|
1124
|
+
key: 'addLoader',
|
|
1125
|
+
value: function addLoader() {
|
|
1126
|
+
var loader = document.createElement('div');
|
|
1127
|
+
loader.className = 'cloudimage-360-loader';
|
|
1128
|
+
|
|
1129
|
+
this.loader = loader;
|
|
1130
|
+
this.innerBox.appendChild(loader);
|
|
1131
|
+
}
|
|
1132
|
+
}, {
|
|
1133
|
+
key: 'addBoxShadow',
|
|
1134
|
+
value: function addBoxShadow() {
|
|
1135
|
+
var boxShadow = document.createElement('div');
|
|
1136
|
+
|
|
1137
|
+
boxShadow.className = 'cloudimage-360-box-shadow';
|
|
1138
|
+
boxShadow.style.boxShadow = this.boxShadow;
|
|
1139
|
+
|
|
1140
|
+
this.innerBox.appendChild(boxShadow);
|
|
1141
|
+
}
|
|
1142
|
+
}, {
|
|
1143
|
+
key: 'removeLoader',
|
|
1144
|
+
value: function removeLoader() {
|
|
1145
|
+
if (!this.loader) return;
|
|
1146
|
+
|
|
1147
|
+
this.innerBox.removeChild(this.loader);
|
|
1148
|
+
this.loader = null;
|
|
1149
|
+
}
|
|
1150
|
+
}, {
|
|
1151
|
+
key: 'remove360ViewIcon',
|
|
1152
|
+
value: function remove360ViewIcon() {
|
|
1153
|
+
if (!this.view360Icon) return;
|
|
1154
|
+
|
|
1155
|
+
this.innerBox.removeChild(this.view360Icon);
|
|
1156
|
+
this.view360Icon = null;
|
|
1157
|
+
}
|
|
1158
|
+
}, {
|
|
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;
|
|
1179
|
+
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}, {
|
|
1185
|
+
key: 'play',
|
|
1186
|
+
value: function play() {
|
|
1187
|
+
var _this3 = this;
|
|
1188
|
+
|
|
1189
|
+
if (this.bottomCircle) this.hide360ViewCircleIcon();
|
|
1190
|
+
this.remove360ViewIcon();
|
|
1191
|
+
|
|
1192
|
+
this.loopTimeoutId = window.setInterval(function () {
|
|
1193
|
+
_this3.loop(_this3.reversed);
|
|
1194
|
+
|
|
1195
|
+
var isPlayedOnce = _this3.isCompletedCyle();
|
|
1196
|
+
|
|
1197
|
+
if (_this3.playOnce && isPlayedOnce) {
|
|
1198
|
+
window.clearTimeout(_this3.loopTimeoutId);
|
|
1199
|
+
}
|
|
1200
|
+
}, this.autoplaySpeed);
|
|
1201
|
+
}
|
|
1202
|
+
}, {
|
|
1203
|
+
key: 'stop',
|
|
1204
|
+
value: function stop() {
|
|
1205
|
+
if (this.bottomCircle && !this.zoomIntensity) this.show360ViewCircleIcon();
|
|
1206
|
+
window.clearTimeout(this.loopTimeoutId);
|
|
1207
|
+
}
|
|
1208
|
+
}, {
|
|
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);
|
|
1258
|
+
|
|
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);
|
|
1270
|
+
|
|
1271
|
+
_this4.addImage(resultSrc, originalSrc, orientation, lazyload, lazySelector, index);
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
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
|
+
|
|
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
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}, {
|
|
1309
|
+
key: 'destroy',
|
|
1310
|
+
value: function destroy() {
|
|
1311
|
+
stop();
|
|
1312
|
+
|
|
1313
|
+
var oldElement = this.container;
|
|
1314
|
+
var newElement = oldElement.cloneNode(true);
|
|
1315
|
+
var innerBox = newElement.querySelector('.cloudimage-360-inner-box');
|
|
1316
|
+
|
|
1317
|
+
newElement.className = newElement.className.replace(' initialized', '');
|
|
1318
|
+
newElement.style.position = 'relative';
|
|
1319
|
+
newElement.style.width = '100%';
|
|
1320
|
+
newElement.style.cursor = 'default';
|
|
1321
|
+
newElement.setAttribute('draggable', 'false');
|
|
1322
|
+
newElement.style.minHeight = 'auto';
|
|
1323
|
+
newElement.removeChild(innerBox);
|
|
1324
|
+
oldElement.parentNode.replaceChild(newElement, oldElement);
|
|
1325
|
+
}
|
|
1326
|
+
}, {
|
|
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');
|
|
1338
|
+
|
|
1339
|
+
if (!left && !right && !top && !bottom) return;
|
|
1340
|
+
|
|
1341
|
+
var onLeftStart = function onLeftStart(event) {
|
|
1342
|
+
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
|
+
|
|
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
|
+
};
|
|
1360
|
+
|
|
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
|
+
};
|
|
1367
|
+
|
|
1368
|
+
var onLeftEnd = function onLeftEnd() {
|
|
1369
|
+
_this5.onFinishSpin();
|
|
1370
|
+
window.clearTimeout(_this5.loopTimeoutId);
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
var onRightEnd = function onRightEnd() {
|
|
1374
|
+
_this5.onFinishSpin();
|
|
1375
|
+
window.clearTimeout(_this5.loopTimeoutId);
|
|
1376
|
+
};
|
|
1377
|
+
|
|
1378
|
+
var onTopEnd = function onTopEnd() {
|
|
1379
|
+
_this5.onFinishSpin();
|
|
1380
|
+
window.clearTimeout(_this5.loopTimeoutId);
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
var onBottomEnd = function onBottomEnd() {
|
|
1384
|
+
_this5.onFinishSpin();
|
|
1385
|
+
window.clearTimeout(_this5.loopTimeoutId);
|
|
1386
|
+
};
|
|
1387
|
+
|
|
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);
|
|
1394
|
+
|
|
1395
|
+
this.leftElem = left;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
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);
|
|
1404
|
+
|
|
1405
|
+
this.rightElem = right;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
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);
|
|
1414
|
+
|
|
1415
|
+
this.topElem = top;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
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);
|
|
1424
|
+
|
|
1425
|
+
this.bottomElem = bottom;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
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';
|
|
1446
|
+
|
|
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';
|
|
1455
|
+
|
|
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
|
+
}
|
|
1460
|
+
|
|
1461
|
+
this.innerBox.appendChild(this.canvas);
|
|
1462
|
+
}
|
|
1463
|
+
}, {
|
|
1464
|
+
key: 'attachEvents',
|
|
1465
|
+
value: function attachEvents(draggable, swipeable, keys) {
|
|
1466
|
+
if (draggable && !this.disableDrag) {
|
|
1467
|
+
this.container.addEventListener('mousedown', this.mouseDown.bind(this));
|
|
1468
|
+
this.container.addEventListener('mousemove', this.mouseMove.bind(this));
|
|
1469
|
+
document.addEventListener('mouseup', this.mouseUp.bind(this));
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
if (swipeable && !this.disableDrag) {
|
|
1473
|
+
this.container.addEventListener('touchstart', this.touchStart.bind(this), { passive: true });
|
|
1474
|
+
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));
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
if (keys) {
|
|
1483
|
+
document.addEventListener('keydown', this.keyDown.bind(this));
|
|
1484
|
+
document.addEventListener('keyup', this.keyUp.bind(this));
|
|
1485
|
+
} else {
|
|
1486
|
+
document.addEventListener('keydown', this.keyDownGeneral.bind(this));
|
|
1487
|
+
}
|
|
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
|
+
|
|
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
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
}, {
|
|
1519
|
+
key: 'init',
|
|
1520
|
+
value: function init(container) {
|
|
1521
|
+
var _get360ViewProps = (0, _ci.get360ViewProps)(container),
|
|
1522
|
+
folder = _get360ViewProps.folder,
|
|
1523
|
+
filenameX = _get360ViewProps.filenameX,
|
|
1524
|
+
filenameY = _get360ViewProps.filenameY,
|
|
1525
|
+
imageList = _get360ViewProps.imageList,
|
|
1526
|
+
indexZeroBase = _get360ViewProps.indexZeroBase,
|
|
1527
|
+
amountX = _get360ViewProps.amountX,
|
|
1528
|
+
amountY = _get360ViewProps.amountY,
|
|
1529
|
+
imageOffset = _get360ViewProps.imageOffset,
|
|
1530
|
+
_get360ViewProps$drag = _get360ViewProps.draggable,
|
|
1531
|
+
draggable = _get360ViewProps$drag === undefined ? true : _get360ViewProps$drag,
|
|
1532
|
+
_get360ViewProps$swip = _get360ViewProps.swipeable,
|
|
1533
|
+
swipeable = _get360ViewProps$swip === undefined ? true : _get360ViewProps$swip,
|
|
1534
|
+
keys = _get360ViewProps.keys,
|
|
1535
|
+
bottomCircle = _get360ViewProps.bottomCircle,
|
|
1536
|
+
bottomCircleOffset = _get360ViewProps.bottomCircleOffset,
|
|
1537
|
+
boxShadow = _get360ViewProps.boxShadow,
|
|
1538
|
+
autoplay = _get360ViewProps.autoplay,
|
|
1539
|
+
autoplayBehavior = _get360ViewProps.autoplayBehavior,
|
|
1540
|
+
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
|
+
speed = _get360ViewProps.speed,
|
|
1551
|
+
autoplayReverse = _get360ViewProps.autoplayReverse,
|
|
1552
|
+
_get360ViewProps$disa3 = _get360ViewProps.disableDrag,
|
|
1553
|
+
disableDrag = _get360ViewProps$disa3 === undefined ? true : _get360ViewProps$disa3,
|
|
1554
|
+
fullscreen = _get360ViewProps.fullscreen,
|
|
1555
|
+
magnifier = _get360ViewProps.magnifier,
|
|
1556
|
+
magnifyInFullscreen = _get360ViewProps.magnifyInFullscreen,
|
|
1557
|
+
ratio = _get360ViewProps.ratio,
|
|
1558
|
+
responsive = _get360ViewProps.responsive,
|
|
1559
|
+
ciToken = _get360ViewProps.ciToken,
|
|
1560
|
+
ciFilters = _get360ViewProps.ciFilters,
|
|
1561
|
+
ciTransformation = _get360ViewProps.ciTransformation,
|
|
1562
|
+
lazyload = _get360ViewProps.lazyload,
|
|
1563
|
+
lazySelector = _get360ViewProps.lazySelector,
|
|
1564
|
+
spinReverse = _get360ViewProps.spinReverse,
|
|
1565
|
+
dragSpeed = _get360ViewProps.dragSpeed,
|
|
1566
|
+
stopAtEdges = _get360ViewProps.stopAtEdges,
|
|
1567
|
+
controlReverse = _get360ViewProps.controlReverse,
|
|
1568
|
+
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();
|
|
1576
|
+
|
|
1577
|
+
this.folder = folder;
|
|
1578
|
+
this.filenameX = filenameX;
|
|
1579
|
+
this.imageList = imageList;
|
|
1580
|
+
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;
|
|
1588
|
+
this.bottomCircle = bottomCircle;
|
|
1589
|
+
this.bottomCircleOffset = bottomCircleOffset;
|
|
1590
|
+
this.boxShadow = boxShadow;
|
|
1591
|
+
this.autoplay = autoplay;
|
|
1592
|
+
this.autoplayBehavior = autoplayBehavior;
|
|
1593
|
+
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
|
+
this.speed = speed;
|
|
1600
|
+
this.reversed = autoplayReverse;
|
|
1601
|
+
this.disableDrag = disableDrag;
|
|
1602
|
+
this.fullscreen = fullscreen;
|
|
1603
|
+
this.magnifier = !this.isMobile && magnifier ? magnifier : false;
|
|
1604
|
+
this.magnifyInFullscreen = magnifyInFullscreen;
|
|
1605
|
+
this.lazyload = lazyload;
|
|
1606
|
+
this.ratio = ratio;
|
|
1607
|
+
this.spinReverse = spinReverse;
|
|
1608
|
+
this.controlReverse = controlReverse;
|
|
1609
|
+
this.dragSpeed = dragSpeed;
|
|
1610
|
+
this.autoplaySpeed = this.speed * 36 / this.amountX;
|
|
1611
|
+
this.stopAtEdges = stopAtEdges;
|
|
1612
|
+
this.hide360Logo = hide360Logo;
|
|
1613
|
+
this.logoSrc = logoSrc;
|
|
1614
|
+
|
|
1615
|
+
this.applyStylesToContainer();
|
|
1616
|
+
|
|
1617
|
+
this.addCanvas();
|
|
1618
|
+
|
|
1619
|
+
var srcX = this.getSrc(responsive, container, folder, filenameX, ciParams);
|
|
1620
|
+
var srcY = this.getSrc(responsive, container, folder, filenameY, ciParams);
|
|
1621
|
+
|
|
1622
|
+
this.preloadImages(amountX, srcX, _ci2.ORIENTATIONS.X, lazyload, lazySelector, container, responsive, ciParams);
|
|
1623
|
+
|
|
1624
|
+
if (amountY) {
|
|
1625
|
+
this.preloadImages(amountY, srcY, _ci2.ORIENTATIONS.Y, lazyload, lazySelector, container, responsive, ciParams);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
this.attachEvents(draggable, swipeable, keys);
|
|
1629
|
+
|
|
1630
|
+
if (onMouseLeave) this.setMouseLeaveActions(onMouseLeave);
|
|
1631
|
+
}
|
|
1632
|
+
}]);
|
|
1633
|
+
|
|
1634
|
+
return CI360Viewer;
|
|
1635
|
+
}();
|
|
1636
|
+
|
|
1637
|
+
exports.default = CI360Viewer;
|