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