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