js-cloudimage-360-view 2.7.2-beta.3 → 2.7.2-beta.7
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 +734 -1229
- package/dist/ci360.utils.js +17 -198
- package/dist/index.js +7 -11
- package/package.json +10 -8
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,116 +526,135 @@ 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
|
-
return this.containerWidth;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
return parentEl.offsetWidth;
|
|
708
|
-
}
|
|
709
|
-
}, {
|
|
710
|
-
key: 'getContainerResponsiveHeight',
|
|
711
|
-
value: function getContainerResponsiveHeight(width) {
|
|
712
|
-
if (this.containerHeight) {
|
|
713
|
-
if (width < this.containerHeight) {
|
|
714
|
-
return width;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
return this.containerHeight;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
return this.container.offsetWidth;
|
|
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);
|
|
721
631
|
}
|
|
722
632
|
}, {
|
|
723
|
-
key:
|
|
633
|
+
key: "updateContainerSize",
|
|
724
634
|
value: function updateContainerSize(image) {
|
|
635
|
+
var parentEl = this.container.parentNode || {};
|
|
725
636
|
var imageAspectRatio = image.width / image.height;
|
|
726
637
|
var isProvidedHeightLessThanWidth = this.containerHeight < this.containerWidth;
|
|
727
|
-
var containerWidth =
|
|
728
|
-
var containerHeight =
|
|
638
|
+
var containerWidth = (0, _jsCloudimage360ViewUtils.getContainerResponsiveWidth)(parentEl, this.containerWidth);
|
|
639
|
+
var containerHeight = (0, _jsCloudimage360ViewUtils.getContainerResponsiveHeight)(this.container, containerWidth, this.containerHeight);
|
|
640
|
+
|
|
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
|
+
}
|
|
729
649
|
|
|
730
650
|
if (this.containerWidth && this.containerHeight) {
|
|
731
651
|
this.container.style.width = containerWidth + 'px';
|
|
732
652
|
this.container.style.height = containerHeight / imageAspectRatio + 'px';
|
|
733
|
-
|
|
734
653
|
return;
|
|
735
654
|
}
|
|
736
655
|
|
|
737
656
|
if (!this.containerWidth && !this.containerHeight) {
|
|
738
657
|
this.container.style.height = containerHeight / imageAspectRatio + 'px';
|
|
739
|
-
|
|
740
658
|
return;
|
|
741
659
|
}
|
|
742
660
|
|
|
@@ -749,95 +667,47 @@ var CI360Viewer = function () {
|
|
|
749
667
|
}
|
|
750
668
|
}
|
|
751
669
|
}, {
|
|
752
|
-
key:
|
|
753
|
-
value: function
|
|
754
|
-
this.incrementLoadedImages(orientation);
|
|
755
|
-
|
|
756
|
-
var totalAmount = this.amountX + this.amountY;
|
|
757
|
-
var totalLoadedImages = this.loadedImagesX + this.loadedImagesY;
|
|
758
|
-
|
|
759
|
-
if (this.loadedImagesX === 1 && orientation !== _ci2.ORIENTATIONS.Y) {
|
|
760
|
-
this.updateContainerSize(event.target);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
if (totalLoadedImages === totalAmount) {
|
|
764
|
-
this.replaceImages(orientation);
|
|
765
|
-
this.update();
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}, {
|
|
769
|
-
key: 'replaceImages',
|
|
770
|
-
value: function replaceImages(orientation) {
|
|
670
|
+
key: "onResizedImageLoad",
|
|
671
|
+
value: function onResizedImageLoad(orientation, image, index) {
|
|
771
672
|
if (orientation === _ci2.ORIENTATIONS.Y) {
|
|
772
|
-
this.
|
|
673
|
+
this.resizedImagesY[index] = image;
|
|
773
674
|
} else {
|
|
774
|
-
this.
|
|
675
|
+
this.resizedImagesX[index] = image;
|
|
775
676
|
}
|
|
776
|
-
}
|
|
777
|
-
}, {
|
|
778
|
-
key: 'requestNewImages',
|
|
779
|
-
value: function requestNewImages(src, amount, orientation) {
|
|
780
|
-
var _this = this;
|
|
781
|
-
|
|
782
|
-
if (orientation === _ci2.ORIENTATIONS.Y) {
|
|
783
|
-
this.resizedImagesY = [];
|
|
784
|
-
this.loadedImagesY = 0;
|
|
785
|
-
} else {
|
|
786
|
-
this.resizedImagesX = [];
|
|
787
|
-
this.loadedImagesX = 0;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
[].concat(_toConsumableArray(new Array(amount))).map(function (_item, index) {
|
|
791
|
-
var nextZeroFilledIndex = (0, _ci.pad)(index + 1, _this.indexZeroBase);
|
|
792
|
-
var resultSrc = src.replace('{index}', nextZeroFilledIndex);
|
|
793
677
|
|
|
794
|
-
|
|
678
|
+
var loadedResizedXImages = this.resizedImagesX.filter(function (image) {
|
|
679
|
+
return !!image;
|
|
795
680
|
});
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
var image = new Image();
|
|
801
|
-
|
|
802
|
-
if (lazyload && !this.fullscreenView) {
|
|
803
|
-
image.setAttribute('data-src', resultSrc);
|
|
804
|
-
image.className = image.className.length ? image.className + (' ' + lazySelector) : lazySelector;
|
|
805
|
-
|
|
806
|
-
if (index === 0) {
|
|
807
|
-
this.lazyloadInitImage = image;
|
|
808
|
-
image.style.position = 'absolute';
|
|
809
|
-
image.style.top = '0';
|
|
810
|
-
image.style.left = '0';
|
|
811
|
-
this.innerBox.appendChild(image);
|
|
812
|
-
}
|
|
813
|
-
} else {
|
|
814
|
-
image.src = resultSrc;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
image.onload = this.onLoadResizedImages.bind(this, orientation);
|
|
818
|
-
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;
|
|
819
685
|
|
|
820
|
-
if (
|
|
821
|
-
this.
|
|
822
|
-
|
|
823
|
-
this.
|
|
686
|
+
if (isAllImagesLoaded) {
|
|
687
|
+
this.imagesX = this.resizedImagesX;
|
|
688
|
+
this.imagesY = this.resizedImagesY;
|
|
689
|
+
this.update();
|
|
824
690
|
}
|
|
825
691
|
}
|
|
826
692
|
}, {
|
|
827
|
-
key:
|
|
693
|
+
key: "requestResizedImages",
|
|
828
694
|
value: function requestResizedImages() {
|
|
829
|
-
var
|
|
830
|
-
|
|
831
|
-
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);
|
|
832
703
|
|
|
833
704
|
if (this.allowSpinY) {
|
|
834
|
-
var srcY =
|
|
835
|
-
|
|
836
|
-
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);
|
|
837
707
|
}
|
|
838
708
|
}
|
|
839
709
|
}, {
|
|
840
|
-
key:
|
|
710
|
+
key: "update",
|
|
841
711
|
value: function update() {
|
|
842
712
|
var image = this.imagesX[this.activeImageX - 1];
|
|
843
713
|
|
|
@@ -846,30 +716,22 @@ var CI360Viewer = function () {
|
|
|
846
716
|
}
|
|
847
717
|
|
|
848
718
|
var ctx = this.canvas.getContext("2d");
|
|
849
|
-
|
|
850
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';
|
|
851
724
|
|
|
852
725
|
if (this.fullscreenView) {
|
|
853
|
-
this.canvas.width
|
|
854
|
-
this.canvas.style.width = window.innerWidth + 'px';
|
|
855
|
-
this.canvas.height = window.innerHeight * this.devicePixelRatio;
|
|
856
|
-
this.canvas.style.height = window.innerHeight + 'px';
|
|
857
|
-
|
|
858
|
-
var _contain = (0, _ci.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
|
|
859
|
-
offsetX = _contain.offsetX,
|
|
860
|
-
offsetY = _contain.offsetY,
|
|
726
|
+
var _contain = (0, _jsCloudimage360ViewUtils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
|
|
861
727
|
width = _contain.width,
|
|
862
|
-
height = _contain.height
|
|
728
|
+
height = _contain.height,
|
|
729
|
+
offsetX = _contain.offsetX,
|
|
730
|
+
offsetY = _contain.offsetY;
|
|
863
731
|
|
|
864
732
|
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
865
733
|
} else {
|
|
866
|
-
|
|
867
|
-
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
868
|
-
|
|
869
|
-
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
870
|
-
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
871
|
-
|
|
872
|
-
if (this.startPointerZoom || this.startPinchZoom) {
|
|
734
|
+
if (this.mouseTracked) {
|
|
873
735
|
this.updateImageScale(ctx);
|
|
874
736
|
} else {
|
|
875
737
|
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
@@ -877,7 +739,7 @@ var CI360Viewer = function () {
|
|
|
877
739
|
}
|
|
878
740
|
}
|
|
879
741
|
}, {
|
|
880
|
-
key:
|
|
742
|
+
key: "updateImageScale",
|
|
881
743
|
value: function updateImageScale(ctx) {
|
|
882
744
|
var image = this.originalImagesX[this.activeImageX - 1];
|
|
883
745
|
|
|
@@ -885,23 +747,17 @@ var CI360Viewer = function () {
|
|
|
885
747
|
image = this.originalImagesY[this.activeImageY - 1];
|
|
886
748
|
}
|
|
887
749
|
|
|
888
|
-
var position = this.
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
var
|
|
893
|
-
var imageHeight = this.canvas.height / this.devicePixelRatio;
|
|
894
|
-
|
|
895
|
-
var width = this.canvas.width + this.zoomIntensity * (this.canvas.width / this.canvas.height);
|
|
896
|
-
var height = this.canvas.height + this.zoomIntensity;
|
|
897
|
-
|
|
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;
|
|
898
755
|
var pointX = 0 - position.x / imageWidth * (width - this.canvas.width);
|
|
899
756
|
var pointY = 0 - position.y / imageHeight * (height - this.canvas.height);
|
|
900
|
-
|
|
901
757
|
ctx.drawImage(image, pointX, pointY, width, height);
|
|
902
758
|
}
|
|
903
759
|
}, {
|
|
904
|
-
key:
|
|
760
|
+
key: "updatePercentageInLoader",
|
|
905
761
|
value: function updatePercentageInLoader(percentage) {
|
|
906
762
|
if (this.loader) {
|
|
907
763
|
this.loader.style.width = percentage + '%';
|
|
@@ -912,53 +768,10 @@ var CI360Viewer = function () {
|
|
|
912
768
|
}
|
|
913
769
|
}
|
|
914
770
|
}, {
|
|
915
|
-
key:
|
|
916
|
-
value: function
|
|
917
|
-
this.
|
|
918
|
-
|
|
919
|
-
this.container.style.cursor = 'grab';
|
|
920
|
-
if (this.disableDrag) this.container.style.cursor = 'default';
|
|
921
|
-
|
|
922
|
-
this.removeLoader();
|
|
923
|
-
|
|
924
|
-
if (!this.fullscreenView) {
|
|
925
|
-
this.speedFactor = Math.floor(this.dragSpeed / 150 * 36 / this.amountX * 25 * this.container.offsetWidth / 1500) || 1;
|
|
926
|
-
} else {
|
|
927
|
-
var containerRatio = this.container.offsetHeight / this.container.offsetWidth;
|
|
928
|
-
var imageOffsetWidth = this.container.offsetWidth;
|
|
929
|
-
|
|
930
|
-
if (this.ratio > containerRatio) {
|
|
931
|
-
imageOffsetWidth = this.container.offsetHeight / this.ratio;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
this.speedFactor = Math.floor(this.dragSpeed / 150 * 36 / this.amountX * 25 * imageOffsetWidth / 1500) || 1;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
if (this.imageOffset) {
|
|
938
|
-
this.activeImageX = this.imageOffset;
|
|
939
|
-
};
|
|
940
|
-
|
|
941
|
-
if (this.autoplay) {
|
|
942
|
-
this.play();
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
if (this.view360Icon) {
|
|
946
|
-
this.view360Icon.innerText = '';
|
|
947
|
-
(0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
this.initControls();
|
|
951
|
-
}
|
|
952
|
-
}, {
|
|
953
|
-
key: 'onFirstImageLoaded',
|
|
954
|
-
value: function onFirstImageLoaded(event) {
|
|
955
|
-
var _this2 = this;
|
|
956
|
-
|
|
957
|
-
this.updateContainerSize(event.target);
|
|
958
|
-
|
|
959
|
-
if (!this.hide360Logo) {
|
|
960
|
-
this.add360ViewIcon();
|
|
961
|
-
}
|
|
771
|
+
key: "onFirstImageLoaded",
|
|
772
|
+
value: function onFirstImageLoaded(image) {
|
|
773
|
+
if (!this.hide360Logo && !this.lazyload) this.add360ViewIcon();
|
|
774
|
+
var ctx = this.canvas.getContext("2d");
|
|
962
775
|
|
|
963
776
|
if (this.fullscreenView) {
|
|
964
777
|
this.canvas.width = window.innerWidth * this.devicePixelRatio;
|
|
@@ -966,71 +779,35 @@ var CI360Viewer = function () {
|
|
|
966
779
|
this.canvas.height = window.innerHeight * this.devicePixelRatio;
|
|
967
780
|
this.canvas.style.height = window.innerHeight + 'px';
|
|
968
781
|
|
|
969
|
-
var
|
|
970
|
-
|
|
971
|
-
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),
|
|
972
783
|
offsetX = _contain2.offsetX,
|
|
973
784
|
offsetY = _contain2.offsetY,
|
|
974
785
|
width = _contain2.width,
|
|
975
786
|
height = _contain2.height;
|
|
976
787
|
|
|
977
|
-
this.offset = {
|
|
978
|
-
|
|
979
|
-
|
|
788
|
+
this.offset = {
|
|
789
|
+
x: offsetX,
|
|
790
|
+
y: offsetY
|
|
791
|
+
};
|
|
792
|
+
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
980
793
|
} else {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
if (this.container.offsetWidth === 0) {
|
|
989
|
-
var modalRef = this.container.parentNode || {};
|
|
990
|
-
|
|
991
|
-
this.canvas.width = parseInt(modalRef.style.width) * this.devicePixelRatio;
|
|
992
|
-
this.canvas.style.width = modalRef.style.width;
|
|
993
|
-
|
|
994
|
-
this.canvas.height = parseInt(modalRef.style.height) * this.devicePixelRatio / event.target.width * event.target.height;
|
|
995
|
-
this.canvas.style.height = parseInt(modalRef.style.width) / event.target.width * event.target.height + 'px';
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
if (this.container.offsetWidth > 0) {
|
|
999
|
-
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
1000
|
-
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
1001
|
-
|
|
1002
|
-
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
1003
|
-
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
_ctx.drawImage(imagePreview, 0, 0, this.canvas.width, this.canvas.height);
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
if (this.lazyload && !this.fullscreenView) {
|
|
1010
|
-
this.imagesX.forEach(function (image, index) {
|
|
1011
|
-
if (index === 0) {
|
|
1012
|
-
_this2.innerBox.removeChild(_this2.lazyloadInitImage);
|
|
1013
|
-
return;
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
var dataSrc = image.getAttribute('data-src');
|
|
1017
|
-
|
|
1018
|
-
if (dataSrc) {
|
|
1019
|
-
image.src = image.getAttribute('data-src');
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
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);
|
|
1022
799
|
}
|
|
1023
800
|
|
|
1024
801
|
if (this.fullscreenView) {
|
|
1025
802
|
this.addCloseFullscreenView();
|
|
1026
803
|
}
|
|
1027
804
|
|
|
1028
|
-
if (this.magnifier
|
|
805
|
+
if (this.magnifier) {
|
|
1029
806
|
this.addMagnifier();
|
|
1030
807
|
}
|
|
1031
808
|
|
|
1032
809
|
if (this.boxShadow && !this.fullscreenView) {
|
|
1033
|
-
this.
|
|
810
|
+
(0, _jsCloudimage360ViewUtils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
1034
811
|
}
|
|
1035
812
|
|
|
1036
813
|
if (this.bottomCircle && !this.fullscreenView) {
|
|
@@ -1040,339 +817,98 @@ var CI360Viewer = function () {
|
|
|
1040
817
|
if (this.fullscreen && !this.fullscreenView) {
|
|
1041
818
|
this.addFullscreenIcon();
|
|
1042
819
|
}
|
|
1043
|
-
|
|
1044
|
-
if (!this.isMobile && !this.fullscreenView && !this.disablePointerZoom) {
|
|
1045
|
-
this.addResetZoomIcon();
|
|
1046
|
-
}
|
|
1047
820
|
}
|
|
1048
821
|
}, {
|
|
1049
|
-
key:
|
|
1050
|
-
value: function
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
} else {
|
|
1054
|
-
this.loadedImagesX += 1;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
}, {
|
|
1058
|
-
key: 'onImageLoad',
|
|
1059
|
-
value: function onImageLoad(index, orientation, event) {
|
|
1060
|
-
this.incrementLoadedImages(orientation);
|
|
1061
|
-
|
|
1062
|
-
var totalAmount = this.amountX + this.amountY;
|
|
1063
|
-
var totalLoadedImages = this.loadedImagesX + this.loadedImagesY;
|
|
1064
|
-
|
|
1065
|
-
var percentage = Math.round(totalLoadedImages / totalAmount * 100);
|
|
1066
|
-
|
|
1067
|
-
this.updatePercentageInLoader(percentage);
|
|
1068
|
-
|
|
1069
|
-
if (index === 0 && orientation !== _ci2.ORIENTATIONS.Y) {
|
|
1070
|
-
this.onFirstImageLoaded(event);
|
|
1071
|
-
}
|
|
822
|
+
key: "onAllImagesLoaded",
|
|
823
|
+
value: function onAllImagesLoaded() {
|
|
824
|
+
this.removeLoader();
|
|
825
|
+
this.imagesLoaded = true;
|
|
1072
826
|
|
|
1073
|
-
if (
|
|
1074
|
-
this.
|
|
827
|
+
if (this.autoplay && this.pointerZoom) {
|
|
828
|
+
this.container.style.cursor = 'zoom-in';
|
|
829
|
+
} else {
|
|
830
|
+
this.container.style.cursor = 'grab';
|
|
1075
831
|
}
|
|
1076
|
-
}
|
|
1077
|
-
}, {
|
|
1078
|
-
key: 'addCloseFullscreenView',
|
|
1079
|
-
value: function addCloseFullscreenView(event) {
|
|
1080
|
-
var closeFullscreenIcon = document.createElement('div');
|
|
1081
|
-
closeFullscreenIcon.className = 'cloudimage-360-close-fullscreen-icon';
|
|
1082
|
-
closeFullscreenIcon.onclick = this.setFullscreenEvents.bind(this, event);
|
|
1083
|
-
|
|
1084
|
-
window.onkeyup = this.setFullscreenEvents.bind(this, event);
|
|
1085
|
-
|
|
1086
|
-
this.iconsContainer.appendChild(closeFullscreenIcon);
|
|
1087
|
-
}
|
|
1088
|
-
}, {
|
|
1089
|
-
key: 'add360ViewIcon',
|
|
1090
|
-
value: function add360ViewIcon() {
|
|
1091
|
-
var view360Icon = document.createElement('div');
|
|
1092
|
-
|
|
1093
|
-
view360Icon.className = 'cloudimage-360-view-360-icon';
|
|
1094
|
-
view360Icon.innerText = '0%';
|
|
1095
|
-
|
|
1096
|
-
this.view360Icon = view360Icon;
|
|
1097
|
-
this.innerBox.appendChild(view360Icon);
|
|
1098
|
-
}
|
|
1099
|
-
}, {
|
|
1100
|
-
key: 'addFullscreenIcon',
|
|
1101
|
-
value: function addFullscreenIcon() {
|
|
1102
|
-
var fullscreenIcon = document.createElement('div');
|
|
1103
|
-
|
|
1104
|
-
fullscreenIcon.className = 'cloudimage-360-fullscreen-icon';
|
|
1105
|
-
fullscreenIcon.onclick = this.openFullscreenModal.bind(this);
|
|
1106
|
-
|
|
1107
|
-
this.fullscreenIcon = fullscreenIcon;
|
|
1108
|
-
|
|
1109
|
-
this.iconsContainer.appendChild(fullscreenIcon);
|
|
1110
|
-
}
|
|
1111
|
-
}, {
|
|
1112
|
-
key: 'hideFullscreenIcon',
|
|
1113
|
-
value: function hideFullscreenIcon() {
|
|
1114
|
-
if (!this.fullscreenIcon) return;
|
|
1115
|
-
|
|
1116
|
-
this.fullscreenIcon.style.display = 'none';
|
|
1117
|
-
this.fullscreenIcon.style.pointerEvents = 'none';
|
|
1118
|
-
}
|
|
1119
|
-
}, {
|
|
1120
|
-
key: 'showFullscreenIcon',
|
|
1121
|
-
value: function showFullscreenIcon() {
|
|
1122
|
-
if (!this.fullscreenIcon) return;
|
|
1123
|
-
|
|
1124
|
-
this.fullscreenIcon.style.display = 'block';
|
|
1125
|
-
this.fullscreenIcon.style.pointerEvents = 'auto';
|
|
1126
|
-
}
|
|
1127
|
-
}, {
|
|
1128
|
-
key: 'addMagnifier',
|
|
1129
|
-
value: function addMagnifier() {
|
|
1130
|
-
var magnifyIcon = document.createElement('div');
|
|
1131
|
-
|
|
1132
|
-
magnifyIcon.className = 'cloudimage-360-magnifier-icon';
|
|
1133
|
-
magnifyIcon.onclick = this.magnify.bind(this);
|
|
1134
|
-
|
|
1135
|
-
this.magnifierIcon = magnifyIcon;
|
|
1136
|
-
|
|
1137
|
-
this.iconsContainer.appendChild(magnifyIcon);
|
|
1138
|
-
}
|
|
1139
|
-
}, {
|
|
1140
|
-
key: 'disableMagnifierIcon',
|
|
1141
|
-
value: function disableMagnifierIcon() {
|
|
1142
|
-
if (!this.magnifierIcon) return;
|
|
1143
|
-
|
|
1144
|
-
this.magnifierIcon.style.display = 'none';
|
|
1145
|
-
this.magnifierIcon.style.pointerEvents = 'none';
|
|
1146
|
-
}
|
|
1147
|
-
}, {
|
|
1148
|
-
key: 'enableMagnifierIcon',
|
|
1149
|
-
value: function enableMagnifierIcon() {
|
|
1150
|
-
if (!this.magnifierIcon) return;
|
|
1151
|
-
|
|
1152
|
-
this.magnifierIcon.style.display = 'block';
|
|
1153
|
-
this.magnifierIcon.style.pointerEvents = 'auto';
|
|
1154
|
-
}
|
|
1155
|
-
}, {
|
|
1156
|
-
key: 'getOriginalSrc',
|
|
1157
|
-
value: function getOriginalSrc() {
|
|
1158
|
-
var currentImage = this.originalImagesX[this.activeImageX - 1];
|
|
1159
|
-
|
|
1160
|
-
if (this.movingDirection === _ci2.ORIENTATIONS.Y) {
|
|
1161
|
-
currentImage = this.originalImagesY[this.activeImageY - 1];
|
|
1162
|
-
};
|
|
1163
|
-
|
|
1164
|
-
return currentImage.src;
|
|
1165
|
-
}
|
|
1166
|
-
}, {
|
|
1167
|
-
key: 'magnify',
|
|
1168
|
-
value: function magnify() {
|
|
1169
|
-
var _this3 = this;
|
|
1170
|
-
|
|
1171
|
-
var image = new Image();
|
|
1172
|
-
var src = this.getOriginalSrc();
|
|
1173
|
-
this.isMagnifyOpen = true;
|
|
1174
|
-
|
|
1175
|
-
image.src = src;
|
|
1176
|
-
image.onload = function () {
|
|
1177
|
-
if (_this3.glass) {
|
|
1178
|
-
_this3.glass.style.cursor = 'none';
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
|
-
this.glass = document.createElement('div');
|
|
1183
|
-
this.container.style.overflow = 'hidden';
|
|
1184
|
-
|
|
1185
|
-
(0, _ci.magnify)(this.container, this.offset, src, this.glass, this.magnifier || 3);
|
|
1186
|
-
}
|
|
1187
|
-
}, {
|
|
1188
|
-
key: 'closeMagnifier',
|
|
1189
|
-
value: function closeMagnifier() {
|
|
1190
|
-
if (!this.glass) return;
|
|
1191
|
-
|
|
1192
|
-
this.container.style.overflow = 'visible';
|
|
1193
|
-
this.container.removeChild(this.glass);
|
|
1194
|
-
this.glass = null;
|
|
1195
|
-
this.isMagnifyOpen = false;
|
|
1196
|
-
}
|
|
1197
|
-
}, {
|
|
1198
|
-
key: 'openFullscreenModal',
|
|
1199
|
-
value: function openFullscreenModal() {
|
|
1200
|
-
var fullscreenModal = document.createElement('div');
|
|
1201
|
-
|
|
1202
|
-
fullscreenModal.className = 'cloudimage-360-fullscreen-modal';
|
|
1203
|
-
|
|
1204
|
-
var fullscreenContainer = this.container.cloneNode();
|
|
1205
|
-
var image = this.imagesX[0];
|
|
1206
|
-
var ratio = image.height / image.width;
|
|
1207
832
|
|
|
1208
|
-
|
|
1209
|
-
fullscreenContainer.style.maxHeight = '100%';
|
|
833
|
+
this.speedFactor = (0, _jsCloudimage360ViewUtils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
|
|
1210
834
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
window.document.body.appendChild(fullscreenModal);
|
|
1215
|
-
|
|
1216
|
-
new CI360Viewer(fullscreenContainer, true, ratio);
|
|
1217
|
-
}
|
|
1218
|
-
}, {
|
|
1219
|
-
key: 'setFullscreenEvents',
|
|
1220
|
-
value: function setFullscreenEvents(_, event) {
|
|
1221
|
-
if (event.type === 'click') return this.closeFullscreenModal();
|
|
1222
|
-
if (event.key === 'Escape') return this.closeFullscreenModalOnEsc();
|
|
1223
|
-
}
|
|
1224
|
-
}, {
|
|
1225
|
-
key: 'closeFullscreenModalOnEsc',
|
|
1226
|
-
value: function closeFullscreenModalOnEsc() {
|
|
1227
|
-
|
|
1228
|
-
if (this.container.parentNode.parentNode === document.body) {
|
|
1229
|
-
this.closeFullscreenModal();
|
|
1230
|
-
};
|
|
1231
|
-
}
|
|
1232
|
-
}, {
|
|
1233
|
-
key: 'closeFullscreenModal',
|
|
1234
|
-
value: function closeFullscreenModal() {
|
|
1235
|
-
document.body.removeChild(this.container.parentNode);
|
|
1236
|
-
window.document.body.style.overflow = 'visible';
|
|
1237
|
-
}
|
|
1238
|
-
}, {
|
|
1239
|
-
key: 'add360ViewCircleIcon',
|
|
1240
|
-
value: function add360ViewCircleIcon() {
|
|
1241
|
-
var view360CircleIcon = new Image();
|
|
1242
|
-
|
|
1243
|
-
view360CircleIcon.src = 'https://scaleflex.ultrafast.io/https://scaleflex.api.airstore.io/v1/get/_/2236d56f-914a-5a8b-a3ae-f7bde1c50000/360.svg';
|
|
1244
|
-
|
|
1245
|
-
view360CircleIcon.style.bottom = this.bottomCircleOffset + '%';
|
|
1246
|
-
view360CircleIcon.className = 'cloudimage-360-view-360-circle';
|
|
1247
|
-
|
|
1248
|
-
this.view360CircleIcon = view360CircleIcon;
|
|
1249
|
-
this.innerBox.appendChild(view360CircleIcon);
|
|
1250
|
-
}
|
|
1251
|
-
}, {
|
|
1252
|
-
key: 'hide360ViewCircleIcon',
|
|
1253
|
-
value: function hide360ViewCircleIcon() {
|
|
1254
|
-
if (!this.view360CircleIcon) return;
|
|
1255
|
-
|
|
1256
|
-
this.view360CircleIcon.style.opacity = '0';
|
|
1257
|
-
}
|
|
1258
|
-
}, {
|
|
1259
|
-
key: 'show360ViewCircleIcon',
|
|
1260
|
-
value: function show360ViewCircleIcon() {
|
|
1261
|
-
if (!this.view360CircleIcon) return;
|
|
1262
|
-
|
|
1263
|
-
this.view360CircleIcon.style.opacity = '1';
|
|
1264
|
-
}
|
|
1265
|
-
}, {
|
|
1266
|
-
key: 'remove360ViewCircleIcon',
|
|
1267
|
-
value: function remove360ViewCircleIcon() {
|
|
1268
|
-
if (!this.view360CircleIcon) return;
|
|
1269
|
-
|
|
1270
|
-
this.innerBox.removeChild(this.view360CircleIcon);
|
|
1271
|
-
this.view360CircleIcon = null;
|
|
1272
|
-
}
|
|
1273
|
-
}, {
|
|
1274
|
-
key: 'addResetZoomIcon',
|
|
1275
|
-
value: function addResetZoomIcon() {
|
|
1276
|
-
var resetZoomIcon = document.createElement('div');
|
|
835
|
+
if (this.autoplay) {
|
|
836
|
+
this.play();
|
|
837
|
+
}
|
|
1277
838
|
|
|
1278
|
-
|
|
1279
|
-
|
|
839
|
+
if (this.disableDrag) {
|
|
840
|
+
this.container.style.cursor = 'default';
|
|
841
|
+
}
|
|
1280
842
|
|
|
1281
|
-
|
|
843
|
+
if (this.view360Icon) {
|
|
844
|
+
this.view360Icon.innerText = '';
|
|
845
|
+
(0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
|
|
846
|
+
}
|
|
1282
847
|
|
|
1283
|
-
this.
|
|
848
|
+
this.initControls();
|
|
1284
849
|
}
|
|
1285
850
|
}, {
|
|
1286
|
-
key:
|
|
1287
|
-
value: function
|
|
1288
|
-
|
|
1289
|
-
if (this.magnifierIcon) this.enableMagnifierIcon();
|
|
1290
|
-
if (this.fullscreenIcon) this.showFullscreenIcon();
|
|
851
|
+
key: "magnify",
|
|
852
|
+
value: function magnify(event) {
|
|
853
|
+
var _this3 = this;
|
|
1291
854
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
value: function showResetZoomIcon() {
|
|
1297
|
-
if (!this.resetZoomIcon) return;
|
|
1298
|
-
if (this.magnifierIcon) this.disableMagnifierIcon();
|
|
1299
|
-
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;
|
|
1300
859
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
var loader = document.createElement('div');
|
|
1307
|
-
loader.className = 'cloudimage-360-loader';
|
|
860
|
+
currentOriginalImage.onload = function () {
|
|
861
|
+
if (_this3.glass) {
|
|
862
|
+
_this3.glass.style.cursor = 'none';
|
|
863
|
+
}
|
|
864
|
+
};
|
|
1308
865
|
|
|
1309
|
-
this.
|
|
1310
|
-
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);
|
|
1311
869
|
}
|
|
1312
870
|
}, {
|
|
1313
|
-
key:
|
|
1314
|
-
value: function
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
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;
|
|
1321
878
|
}
|
|
1322
879
|
}, {
|
|
1323
|
-
key:
|
|
1324
|
-
value: function
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
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);
|
|
1329
886
|
}
|
|
1330
887
|
}, {
|
|
1331
|
-
key:
|
|
1332
|
-
value: function
|
|
1333
|
-
if (
|
|
888
|
+
key: "setFullscreenEvents",
|
|
889
|
+
value: function setFullscreenEvents(_, event) {
|
|
890
|
+
if (event.type === 'click') return this.closeFullscreenModal(event);
|
|
1334
891
|
|
|
1335
|
-
this.
|
|
1336
|
-
|
|
892
|
+
if (event.key === 'Escape' && this.container.parentNode.parentNode === document.body) {
|
|
893
|
+
this.closeFullscreenModalOnEsc(event);
|
|
894
|
+
}
|
|
1337
895
|
}
|
|
1338
896
|
}, {
|
|
1339
|
-
key:
|
|
1340
|
-
value: function
|
|
1341
|
-
|
|
1342
|
-
case _ci2.AUTOPLAY_BEHAVIOR.SPIN_XY:
|
|
1343
|
-
case _ci2.AUTOPLAY_BEHAVIOR.SPIN_Y:
|
|
1344
|
-
{
|
|
1345
|
-
var isReachedTheEdge = this.reversed ? this.activeImageY === 1 : this.activeImageY === this.amountY;
|
|
1346
|
-
|
|
1347
|
-
if (isReachedTheEdge) return true;
|
|
1348
|
-
|
|
1349
|
-
return false;
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
case _ci2.AUTOPLAY_BEHAVIOR.SPIN_X:
|
|
1353
|
-
case _ci2.AUTOPLAY_BEHAVIOR.SPIN_YX:
|
|
1354
|
-
default:
|
|
1355
|
-
{
|
|
1356
|
-
var _isReachedTheEdge = this.reversed ? this.activeImageX === 1 : this.activeImageX === this.amountX;
|
|
1357
|
-
|
|
1358
|
-
if (_isReachedTheEdge) return true;
|
|
1359
|
-
|
|
1360
|
-
return false;
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
897
|
+
key: "closeFullscreenModalOnEsc",
|
|
898
|
+
value: function closeFullscreenModalOnEsc(event) {
|
|
899
|
+
this.closeFullscreenModal(event);
|
|
1363
900
|
}
|
|
1364
901
|
}, {
|
|
1365
|
-
key:
|
|
902
|
+
key: "play",
|
|
1366
903
|
value: function play() {
|
|
1367
904
|
var _this4 = this;
|
|
1368
905
|
|
|
1369
906
|
if (this.bottomCircle) this.hide360ViewCircleIcon();
|
|
1370
907
|
this.remove360ViewIcon();
|
|
1371
|
-
|
|
1372
908
|
this.loopTimeoutId = window.setInterval(function () {
|
|
1373
909
|
_this4.loop(_this4.reversed);
|
|
1374
910
|
|
|
1375
|
-
var isPlayedOnce = _this4.
|
|
911
|
+
var isPlayedOnce = (0, _jsCloudimage360ViewUtils.isCompletedOneCycle)(_this4.autoplayBehavior, _this4.activeImageX, _this4.activeImageY, _this4.amountX, _this4.amountY, _this4.reversed);
|
|
1376
912
|
|
|
1377
913
|
if (_this4.playOnce && isPlayedOnce) {
|
|
1378
914
|
window.clearTimeout(_this4.loopTimeoutId);
|
|
@@ -1385,124 +921,18 @@ var CI360Viewer = function () {
|
|
|
1385
921
|
}, this.autoplaySpeed);
|
|
1386
922
|
}
|
|
1387
923
|
}, {
|
|
1388
|
-
key:
|
|
924
|
+
key: "stop",
|
|
1389
925
|
value: function stop() {
|
|
1390
|
-
if (this.bottomCircle
|
|
926
|
+
if (this.bottomCircle) this.show360ViewCircleIcon();
|
|
1391
927
|
window.clearTimeout(this.loopTimeoutId);
|
|
1392
928
|
}
|
|
1393
929
|
}, {
|
|
1394
|
-
key:
|
|
1395
|
-
value: function getSrc(container, folder, apiVersion, filename) {
|
|
1396
|
-
var ciParams = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
1397
|
-
var ciToken = ciParams.ciToken,
|
|
1398
|
-
ciFilters = ciParams.ciFilters,
|
|
1399
|
-
ciTransformation = ciParams.ciTransformation;
|
|
1400
|
-
|
|
1401
|
-
var src = '' + folder + filename;
|
|
1402
|
-
|
|
1403
|
-
if (ciToken) {
|
|
1404
|
-
var imageOffsetWidth = container.offsetWidth;
|
|
1405
|
-
|
|
1406
|
-
var vesrion = _ci2.falsyValues.indexOf(apiVersion) !== -1 ? null : apiVersion;
|
|
1407
|
-
var finalApiVersion = vesrion ? vesrion + '/' : '';
|
|
1408
|
-
|
|
1409
|
-
if (this.fullscreenView) {
|
|
1410
|
-
var containerRatio = container.offsetHeight / container.offsetWidth;
|
|
1411
|
-
|
|
1412
|
-
if (this.ratio > containerRatio) {
|
|
1413
|
-
imageOffsetWidth = container.offsetHeight / this.ratio;
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
var ciSizeNext = (0, _ci.getSizeAccordingToPixelRatio)((0, _ci.getResponsiveWidthOfContainer)(imageOffsetWidth));
|
|
1418
|
-
|
|
1419
|
-
src = 'https://' + ciToken + '.cloudimg.io/' + finalApiVersion + src + '?' + (ciTransformation ? ciTransformation : 'width=' + ciSizeNext) + (ciFilters ? '&f=' + ciFilters : '');
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
return src;
|
|
1423
|
-
}
|
|
1424
|
-
}, {
|
|
1425
|
-
key: 'preloadImages',
|
|
1426
|
-
value: function preloadImages(amount, src) {
|
|
1427
|
-
var orientation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ci2.ORIENTATIONS.X;
|
|
1428
|
-
var lazyload = arguments[3];
|
|
1429
|
-
var lazySelector = arguments[4];
|
|
1430
|
-
var container = arguments[5];
|
|
1431
|
-
var ciParams = arguments[6];
|
|
1432
|
-
|
|
1433
|
-
var _this5 = this;
|
|
1434
|
-
|
|
1435
|
-
var apiVersion = arguments[7];
|
|
1436
|
-
var filename = arguments[8];
|
|
1437
|
-
|
|
1438
|
-
if (this.imageList) {
|
|
1439
|
-
try {
|
|
1440
|
-
var images = JSON.parse(this.imageList);
|
|
1441
|
-
|
|
1442
|
-
this.amountX = images.length;
|
|
1443
|
-
images.forEach(function (src, index) {
|
|
1444
|
-
var folder = /(http(s?)):\/\//gi.test(src) ? '' : _this5.folder;
|
|
1445
|
-
var resultSrc = _this5.getSrc(container, folder, apiVersion, filename, ciParams);
|
|
1446
|
-
var lastIndex = resultSrc.lastIndexOf('//');
|
|
1447
|
-
var originalSrc = resultSrc.slice(lastIndex);
|
|
1448
|
-
|
|
1449
|
-
_this5.addImage(resultSrc, originalSrc, orientation, lazyload, lazySelector, index);
|
|
1450
|
-
});
|
|
1451
|
-
} catch (error) {
|
|
1452
|
-
console.error('Wrong format in image-list attribute: ' + error.message);
|
|
1453
|
-
}
|
|
1454
|
-
} else {
|
|
1455
|
-
[].concat(_toConsumableArray(new Array(amount))).map(function (_item, index) {
|
|
1456
|
-
var nextZeroFilledIndex = (0, _ci.pad)(index + 1, _this5.indexZeroBase);
|
|
1457
|
-
var resultSrc = src.replace('{index}', nextZeroFilledIndex);
|
|
1458
|
-
var originalSrc = resultSrc.replace(_ci2.ORGINAL_SIZE_REGEX, '').replace(_ci2.AND_SYMBOL_REGEX, '?');
|
|
1459
|
-
|
|
1460
|
-
_this5.addImage(resultSrc, originalSrc, orientation, lazyload, lazySelector, index);
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
}, {
|
|
1465
|
-
key: 'addImage',
|
|
1466
|
-
value: function addImage(resultSrc, originalSrc, orientation, lazyload, lazySelector, index) {
|
|
1467
|
-
var image = new Image();
|
|
1468
|
-
var originalImage = new Image();
|
|
1469
|
-
|
|
1470
|
-
if (lazyload && !this.fullscreenView) {
|
|
1471
|
-
image.setAttribute('data-src', resultSrc);
|
|
1472
|
-
image.className = image.className.length ? image.className + (' ' + lazySelector) : lazySelector;
|
|
1473
|
-
|
|
1474
|
-
if (index === 0) {
|
|
1475
|
-
this.lazyloadInitImage = image;
|
|
1476
|
-
image.style.position = 'absolute';
|
|
1477
|
-
image.style.top = '0';
|
|
1478
|
-
image.style.left = '0';
|
|
1479
|
-
this.innerBox.appendChild(image);
|
|
1480
|
-
}
|
|
1481
|
-
} else {
|
|
1482
|
-
image.src = resultSrc;
|
|
1483
|
-
originalImage.src = originalSrc;
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
image.onload = this.onImageLoad.bind(this, index, orientation);
|
|
1487
|
-
image.onerror = this.onImageLoad.bind(this, index, orientation);
|
|
1488
|
-
|
|
1489
|
-
if (orientation === _ci2.ORIENTATIONS.Y) {
|
|
1490
|
-
this.imagesY.push(image);
|
|
1491
|
-
this.originalImagesY.push(originalImage);
|
|
1492
|
-
} else {
|
|
1493
|
-
this.imagesX.push(image);
|
|
1494
|
-
this.originalImagesX.push(originalImage);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
}, {
|
|
1498
|
-
key: 'destroy',
|
|
930
|
+
key: "destroy",
|
|
1499
931
|
value: function destroy() {
|
|
1500
932
|
stop();
|
|
1501
|
-
|
|
1502
933
|
var oldElement = this.container;
|
|
1503
934
|
var newElement = oldElement.cloneNode(true);
|
|
1504
935
|
var innerBox = newElement.querySelector('.cloudimage-360-inner-box');
|
|
1505
|
-
|
|
1506
936
|
newElement.className = newElement.className.replace(' initialized', '');
|
|
1507
937
|
newElement.style.position = 'relative';
|
|
1508
938
|
newElement.style.width = '100%';
|
|
@@ -1513,240 +943,241 @@ var CI360Viewer = function () {
|
|
|
1513
943
|
oldElement.parentNode.replaceChild(newElement, oldElement);
|
|
1514
944
|
}
|
|
1515
945
|
}, {
|
|
1516
|
-
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",
|
|
1517
1049
|
value: function initControls() {
|
|
1518
|
-
var
|
|
1519
|
-
|
|
1520
|
-
var isReverse = this.controlReverse ? !this.spinReverse : this.spinReverse;
|
|
1521
|
-
// TODO [deprecated]: remove .cloud-360-left, .cloud-360-right in the upcoming versions
|
|
1522
|
-
var left = this.container.querySelector('.cloudimage-360-left') || this.container.querySelector('.cloudimage-360-prev');
|
|
1523
|
-
var right = this.container.querySelector('.cloudimage-360-right') || this.container.querySelector('.cloudimage-360-next');
|
|
1524
|
-
|
|
1525
|
-
var top = this.container.querySelector('.cloudimage-360-top');
|
|
1526
|
-
var bottom = this.container.querySelector('.cloudimage-360-bottom');
|
|
1527
|
-
|
|
1528
|
-
if (!left && !right && !top && !bottom) return;
|
|
1050
|
+
var _this5 = this;
|
|
1529
1051
|
|
|
1530
1052
|
var onLeftStart = function onLeftStart(event) {
|
|
1531
1053
|
event.stopPropagation();
|
|
1532
|
-
_this6.onSpin();
|
|
1533
|
-
_this6.left();
|
|
1534
|
-
_this6.loopTimeoutId = window.setInterval(_this6.left.bind(_this6), _this6.autoplaySpeed);
|
|
1535
|
-
};
|
|
1536
|
-
var onRightStart = function onRightStart(event) {
|
|
1537
|
-
event.stopPropagation();
|
|
1538
|
-
_this6.onSpin();
|
|
1539
|
-
_this6.right();
|
|
1540
|
-
_this6.loopTimeoutId = window.setInterval(_this6.right.bind(_this6), _this6.autoplaySpeed);
|
|
1541
|
-
};
|
|
1542
1054
|
|
|
1543
|
-
|
|
1544
|
-
event.stopPropagation();
|
|
1545
|
-
_this6.onSpin();
|
|
1546
|
-
_this6.top();
|
|
1547
|
-
_this6.loopTimeoutId = window.setInterval(_this6.top.bind(_this6), _this6.autoplaySpeed);
|
|
1548
|
-
};
|
|
1055
|
+
_this5.onSpin();
|
|
1549
1056
|
|
|
1550
|
-
|
|
1551
|
-
event.stopPropagation();
|
|
1552
|
-
_this6.onSpin();
|
|
1553
|
-
_this6.bottom();
|
|
1554
|
-
_this6.loopTimeoutId = window.setInterval(_this6.bottom.bind(_this6), _this6.autoplaySpeed);
|
|
1555
|
-
};
|
|
1057
|
+
_this5.left();
|
|
1556
1058
|
|
|
1557
|
-
|
|
1558
|
-
_this6.onFinishSpin();
|
|
1559
|
-
window.clearTimeout(_this6.loopTimeoutId);
|
|
1059
|
+
_this5.loopTimeoutId = window.setInterval(_this5.left.bind(_this5), _this5.autoplaySpeed);
|
|
1560
1060
|
};
|
|
1561
1061
|
|
|
1562
|
-
var
|
|
1563
|
-
|
|
1564
|
-
window.clearTimeout(_this6.loopTimeoutId);
|
|
1565
|
-
};
|
|
1062
|
+
var onRightStart = function onRightStart(event) {
|
|
1063
|
+
event.stopPropagation();
|
|
1566
1064
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
};
|
|
1065
|
+
_this5.onSpin();
|
|
1066
|
+
|
|
1067
|
+
_this5.right();
|
|
1571
1068
|
|
|
1572
|
-
|
|
1573
|
-
_this6.onFinishSpin();
|
|
1574
|
-
window.clearTimeout(_this6.loopTimeoutId);
|
|
1069
|
+
_this5.loopTimeoutId = window.setInterval(_this5.right.bind(_this5), _this5.autoplaySpeed);
|
|
1575
1070
|
};
|
|
1576
1071
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
left.addEventListener('mousedown', isReverse ? onRightStart : onLeftStart);
|
|
1580
|
-
left.addEventListener('touchstart', isReverse ? onRightStart : onLeftStart, { passive: true });
|
|
1581
|
-
left.addEventListener('mouseup', isReverse ? onRightEnd : onLeftEnd);
|
|
1582
|
-
left.addEventListener('touchend', isReverse ? onRightEnd : onLeftEnd);
|
|
1072
|
+
var onTopStart = function onTopStart(event) {
|
|
1073
|
+
event.stopPropagation();
|
|
1583
1074
|
|
|
1584
|
-
|
|
1585
|
-
}
|
|
1075
|
+
_this5.onSpin();
|
|
1586
1076
|
|
|
1587
|
-
|
|
1588
|
-
right.style.display = 'block';
|
|
1589
|
-
right.addEventListener('mousedown', isReverse ? onLeftStart : onRightStart);
|
|
1590
|
-
right.addEventListener('touchstart', isReverse ? onLeftStart : onRightStart, { passive: true });
|
|
1591
|
-
right.addEventListener('mouseup', isReverse ? onLeftEnd : onRightEnd);
|
|
1592
|
-
right.addEventListener('touchend', isReverse ? onLeftEnd : onRightEnd);
|
|
1077
|
+
_this5.top();
|
|
1593
1078
|
|
|
1594
|
-
|
|
1595
|
-
}
|
|
1079
|
+
_this5.loopTimeoutId = window.setInterval(_this5.top.bind(_this5), _this5.autoplaySpeed);
|
|
1080
|
+
};
|
|
1596
1081
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
top.addEventListener('mousedown', isReverse ? onBottomStart : onTopStart);
|
|
1600
|
-
top.addEventListener('touchstart', isReverse ? onBottomStart : onTopStart);
|
|
1601
|
-
top.addEventListener('mouseup', isReverse ? onBottomEnd : onTopEnd);
|
|
1602
|
-
top.addEventListener('touchend', isReverse ? onBottomEnd : onTopEnd);
|
|
1082
|
+
var onBottomStart = function onBottomStart(event) {
|
|
1083
|
+
event.stopPropagation();
|
|
1603
1084
|
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1085
|
+
_this5.onSpin();
|
|
1606
1086
|
|
|
1607
|
-
|
|
1608
|
-
bottom.style.display = 'block';
|
|
1609
|
-
bottom.addEventListener('mousedown', isReverse ? onTopStart : onBottomStart);
|
|
1610
|
-
bottom.addEventListener('touchstart', isReverse ? onTopStart : onBottomStart);
|
|
1611
|
-
bottom.addEventListener('mouseup', isReverse ? onTopEnd : onBottomEnd);
|
|
1612
|
-
bottom.addEventListener('touchend', isReverse ? onTopEnd : onBottomEnd);
|
|
1087
|
+
_this5.bottom();
|
|
1613
1088
|
|
|
1614
|
-
|
|
1615
|
-
}
|
|
1089
|
+
_this5.loopTimeoutId = window.setInterval(_this5.bottom.bind(_this5), _this5.autoplaySpeed);
|
|
1090
|
+
};
|
|
1616
1091
|
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
(0, _ci.addClass)(isReverse ? right : left, 'not-active');
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
}, {
|
|
1624
|
-
key: 'addInnerBox',
|
|
1625
|
-
value: function addInnerBox() {
|
|
1626
|
-
this.innerBox = document.createElement('div');
|
|
1627
|
-
this.innerBox.className = 'cloudimage-360-inner-box';
|
|
1628
|
-
this.container.appendChild(this.innerBox);
|
|
1629
|
-
}
|
|
1630
|
-
}, {
|
|
1631
|
-
key: 'addIconsContainer',
|
|
1632
|
-
value: function addIconsContainer() {
|
|
1633
|
-
this.iconsContainer = document.createElement('div');
|
|
1634
|
-
this.iconsContainer.className = 'cloudimage-360-icons-container';
|
|
1092
|
+
var onEventEnd = function onEventEnd() {
|
|
1093
|
+
_this5.onFinishSpin();
|
|
1635
1094
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
}, {
|
|
1639
|
-
key: 'addCanvas',
|
|
1640
|
-
value: function addCanvas() {
|
|
1641
|
-
this.canvas = document.createElement('canvas');
|
|
1642
|
-
this.canvas.style.width = '100%';
|
|
1643
|
-
this.canvas.style.fontSize = '0';
|
|
1095
|
+
window.clearTimeout(_this5.loopTimeoutId);
|
|
1096
|
+
};
|
|
1644
1097
|
|
|
1645
|
-
|
|
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 || {};
|
|
1646
1116
|
}
|
|
1647
1117
|
}, {
|
|
1648
|
-
key:
|
|
1118
|
+
key: "attachEvents",
|
|
1649
1119
|
value: function attachEvents(draggable, swipeable, keys) {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
window.addEventListener('resize', (0, _ci.debounce)(function () {
|
|
1653
|
-
_this7.requestResizedImages();
|
|
1654
|
-
}, 80));
|
|
1120
|
+
window.addEventListener('resize', this.requestResizedImages.bind(this));
|
|
1655
1121
|
|
|
1656
1122
|
if (draggable && !this.disableDrag) {
|
|
1123
|
+
this.container.addEventListener('click', this.mouseClick.bind(this));
|
|
1657
1124
|
this.container.addEventListener('mousedown', this.mouseDown.bind(this));
|
|
1658
1125
|
this.container.addEventListener('mousemove', this.mouseMove.bind(this));
|
|
1126
|
+
this.container.addEventListener('mouseleave', this.mouseLeave.bind(this));
|
|
1659
1127
|
document.addEventListener('mouseup', this.mouseUp.bind(this));
|
|
1660
1128
|
}
|
|
1661
1129
|
|
|
1662
1130
|
if (swipeable && !this.disableDrag) {
|
|
1663
|
-
this.container.addEventListener('touchstart', this.touchStart.bind(this), {
|
|
1131
|
+
this.container.addEventListener('touchstart', this.touchStart.bind(this), {
|
|
1132
|
+
passive: true
|
|
1133
|
+
});
|
|
1664
1134
|
this.container.addEventListener('touchend', this.touchEnd.bind(this));
|
|
1665
|
-
this.container.addEventListener('touchmove', this.touchMove.bind(this), {
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
if (!this.disablePointerZoom && !this.fullscreenView) {
|
|
1669
|
-
this.container.addEventListener('click', this.mouseClick.bind(this));
|
|
1670
|
-
this.container.addEventListener('wheel', this.mouseScroll.bind(this));
|
|
1135
|
+
this.container.addEventListener('touchmove', this.touchMove.bind(this), {
|
|
1136
|
+
passive: true
|
|
1137
|
+
});
|
|
1671
1138
|
}
|
|
1672
1139
|
|
|
1673
1140
|
if (keys) {
|
|
1674
1141
|
document.addEventListener('keydown', this.keyDown.bind(this));
|
|
1675
1142
|
document.addEventListener('keyup', this.keyUp.bind(this));
|
|
1676
|
-
} else {
|
|
1677
|
-
document.addEventListener('keydown', this.keyDownGeneral.bind(this));
|
|
1678
1143
|
}
|
|
1679
|
-
}
|
|
1680
|
-
}, {
|
|
1681
|
-
key: 'applyStylesToContainer',
|
|
1682
|
-
value: function applyStylesToContainer() {
|
|
1683
|
-
this.container.style.position = 'relative';
|
|
1684
|
-
this.container.style.width = '100%';
|
|
1685
|
-
this.container.style.cursor = 'wait';
|
|
1686
|
-
this.container.setAttribute('draggable', 'false');
|
|
1687
|
-
this.container.className = this.container.className + ' initialized';
|
|
1688
|
-
}
|
|
1689
|
-
}, {
|
|
1690
|
-
key: 'setMouseLeaveActions',
|
|
1691
|
-
value: function setMouseLeaveActions(actions) {
|
|
1692
|
-
var _this8 = this;
|
|
1693
1144
|
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
mouseLeaveActions.forEach(function (action) {
|
|
1697
|
-
return _this8.applyMouseLeaveAction(action);
|
|
1698
|
-
});
|
|
1145
|
+
document.addEventListener('keydown', this.keyDownGeneral.bind(this));
|
|
1699
1146
|
}
|
|
1700
1147
|
}, {
|
|
1701
|
-
key:
|
|
1702
|
-
value: function applyMouseLeaveAction(action) {
|
|
1703
|
-
switch (action) {
|
|
1704
|
-
case _ci2.MOUSE_LEAVE_ACTIONS.RESET_ZOOM:
|
|
1705
|
-
this.container.addEventListener('mouseleave', this.resetZoom.bind(this));
|
|
1706
|
-
break;
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
}, {
|
|
1710
|
-
key: 'init',
|
|
1148
|
+
key: "init",
|
|
1711
1149
|
value: function init(container) {
|
|
1150
|
+
var _this6 = this;
|
|
1151
|
+
|
|
1712
1152
|
var _get360ViewProps = (0, _ci.get360ViewProps)(container),
|
|
1713
1153
|
folder = _get360ViewProps.folder,
|
|
1714
1154
|
apiVersion = _get360ViewProps.apiVersion,
|
|
1715
1155
|
filenameX = _get360ViewProps.filenameX,
|
|
1716
1156
|
filenameY = _get360ViewProps.filenameY,
|
|
1717
|
-
|
|
1157
|
+
imageListX = _get360ViewProps.imageListX,
|
|
1158
|
+
imageListY = _get360ViewProps.imageListY,
|
|
1718
1159
|
indexZeroBase = _get360ViewProps.indexZeroBase,
|
|
1719
1160
|
amountX = _get360ViewProps.amountX,
|
|
1720
1161
|
amountY = _get360ViewProps.amountY,
|
|
1721
1162
|
imageOffset = _get360ViewProps.imageOffset,
|
|
1722
1163
|
_get360ViewProps$drag = _get360ViewProps.draggable,
|
|
1723
|
-
draggable = _get360ViewProps$drag ===
|
|
1164
|
+
draggable = _get360ViewProps$drag === void 0 ? true : _get360ViewProps$drag,
|
|
1724
1165
|
_get360ViewProps$swip = _get360ViewProps.swipeable,
|
|
1725
|
-
swipeable = _get360ViewProps$swip ===
|
|
1166
|
+
swipeable = _get360ViewProps$swip === void 0 ? true : _get360ViewProps$swip,
|
|
1726
1167
|
keys = _get360ViewProps.keys,
|
|
1168
|
+
keysReverse = _get360ViewProps.keysReverse,
|
|
1727
1169
|
bottomCircle = _get360ViewProps.bottomCircle,
|
|
1728
1170
|
bottomCircleOffset = _get360ViewProps.bottomCircleOffset,
|
|
1729
1171
|
boxShadow = _get360ViewProps.boxShadow,
|
|
1730
1172
|
autoplay = _get360ViewProps.autoplay,
|
|
1731
1173
|
autoplayBehavior = _get360ViewProps.autoplayBehavior,
|
|
1732
1174
|
playOnce = _get360ViewProps.playOnce,
|
|
1733
|
-
pointerZoomFactor = _get360ViewProps.pointerZoomFactor,
|
|
1734
|
-
pinchZoomFactor = _get360ViewProps.pinchZoomFactor,
|
|
1735
|
-
maxScale = _get360ViewProps.maxScale,
|
|
1736
|
-
toStartPointerZoom = _get360ViewProps.toStartPointerZoom,
|
|
1737
|
-
onMouseLeave = _get360ViewProps.onMouseLeave,
|
|
1738
|
-
_get360ViewProps$disa = _get360ViewProps.disablePointerZoom,
|
|
1739
|
-
disablePointerZoom = _get360ViewProps$disa === undefined ? true : _get360ViewProps$disa,
|
|
1740
|
-
_get360ViewProps$disa2 = _get360ViewProps.disablePinchZoom,
|
|
1741
|
-
disablePinchZoom = _get360ViewProps$disa2 === undefined ? true : _get360ViewProps$disa2,
|
|
1742
1175
|
speed = _get360ViewProps.speed,
|
|
1743
1176
|
autoplayReverse = _get360ViewProps.autoplayReverse,
|
|
1744
|
-
_get360ViewProps$
|
|
1745
|
-
disableDrag = _get360ViewProps$
|
|
1177
|
+
_get360ViewProps$disa = _get360ViewProps.disableDrag,
|
|
1178
|
+
disableDrag = _get360ViewProps$disa === void 0 ? true : _get360ViewProps$disa,
|
|
1746
1179
|
fullscreen = _get360ViewProps.fullscreen,
|
|
1747
1180
|
magnifier = _get360ViewProps.magnifier,
|
|
1748
|
-
magnifyInFullscreen = _get360ViewProps.magnifyInFullscreen,
|
|
1749
|
-
ratio = _get360ViewProps.ratio,
|
|
1750
1181
|
ciToken = _get360ViewProps.ciToken,
|
|
1751
1182
|
ciFilters = _get360ViewProps.ciFilters,
|
|
1752
1183
|
ciTransformation = _get360ViewProps.ciTransformation,
|
|
@@ -1759,25 +1190,26 @@ var CI360Viewer = function () {
|
|
|
1759
1190
|
hide360Logo = _get360ViewProps.hide360Logo,
|
|
1760
1191
|
logoSrc = _get360ViewProps.logoSrc,
|
|
1761
1192
|
containerWidth = _get360ViewProps.containerWidth,
|
|
1762
|
-
containerHeight = _get360ViewProps.containerHeight
|
|
1763
|
-
|
|
1764
|
-
var ciParams = { ciToken: ciToken, ciFilters: ciFilters, ciTransformation: ciTransformation };
|
|
1765
|
-
|
|
1766
|
-
this.addInnerBox();
|
|
1767
|
-
this.addIconsContainer();
|
|
1768
|
-
this.addLoader();
|
|
1193
|
+
containerHeight = _get360ViewProps.containerHeight,
|
|
1194
|
+
pointerZoom = _get360ViewProps.pointerZoom;
|
|
1769
1195
|
|
|
1196
|
+
var ciParams = {
|
|
1197
|
+
ciToken: ciToken,
|
|
1198
|
+
ciFilters: ciFilters,
|
|
1199
|
+
ciTransformation: ciTransformation
|
|
1200
|
+
};
|
|
1770
1201
|
this.folder = folder;
|
|
1771
1202
|
this.apiVersion = apiVersion;
|
|
1772
1203
|
this.filenameX = filenameX;
|
|
1773
1204
|
this.filenameY = filenameY;
|
|
1774
|
-
this.
|
|
1205
|
+
this.imageListX = imageListX;
|
|
1206
|
+
this.imageListY = imageListY;
|
|
1775
1207
|
this.indexZeroBase = indexZeroBase;
|
|
1776
|
-
this.amountX = amountX;
|
|
1777
|
-
this.amountY = amountY;
|
|
1778
|
-
this.allowSpinY = !!amountY
|
|
1779
|
-
this.activeImageX = autoplayReverse ? amountX : 1;
|
|
1780
|
-
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;
|
|
1781
1213
|
this.spinY = autoplayBehavior === _ci2.AUTOPLAY_BEHAVIOR.SPIN_YX ? true : false;
|
|
1782
1214
|
this.imageOffset = imageOffset;
|
|
1783
1215
|
this.bottomCircle = bottomCircle;
|
|
@@ -1786,20 +1218,14 @@ var CI360Viewer = function () {
|
|
|
1786
1218
|
this.autoplay = autoplay;
|
|
1787
1219
|
this.autoplayBehavior = autoplayBehavior;
|
|
1788
1220
|
this.playOnce = playOnce;
|
|
1789
|
-
this.toStartPointerZoom = toStartPointerZoom, this.disablePointerZoom = disablePointerZoom;
|
|
1790
|
-
this.disablePinchZoom = disablePinchZoom;
|
|
1791
|
-
this.pointerZoomFactor = pointerZoomFactor;
|
|
1792
|
-
this.pinchZoomFactor = pinchZoomFactor;
|
|
1793
|
-
this.maxScale = maxScale;
|
|
1794
1221
|
this.speed = speed;
|
|
1795
1222
|
this.reversed = autoplayReverse;
|
|
1796
1223
|
this.disableDrag = disableDrag;
|
|
1797
1224
|
this.fullscreen = fullscreen;
|
|
1798
1225
|
this.magnifier = !this.isMobile && magnifier ? magnifier : false;
|
|
1799
|
-
this.
|
|
1800
|
-
this.
|
|
1226
|
+
this.lazyloadX = lazyload;
|
|
1227
|
+
this.lazyloadY = lazyload;
|
|
1801
1228
|
this.lazySelector = lazySelector;
|
|
1802
|
-
this.ratio = ratio;
|
|
1803
1229
|
this.spinReverse = spinReverse;
|
|
1804
1230
|
this.controlReverse = controlReverse;
|
|
1805
1231
|
this.dragSpeed = dragSpeed;
|
|
@@ -1811,27 +1237,106 @@ var CI360Viewer = function () {
|
|
|
1811
1237
|
this.apiVersion = apiVersion;
|
|
1812
1238
|
this.containerWidth = containerWidth;
|
|
1813
1239
|
this.containerHeight = containerHeight;
|
|
1240
|
+
this.pointerZoom = Math.min(Math.max(pointerZoom, 1), 3);
|
|
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);
|
|
1814
1313
|
|
|
1815
|
-
|
|
1314
|
+
if (isFirstImageLoaded) {
|
|
1315
|
+
_this6.updateContainerSize(image);
|
|
1816
1316
|
|
|
1817
|
-
|
|
1317
|
+
_this6.onFirstImageLoaded(image);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
if (isAllImagesLoaded) {
|
|
1321
|
+
_this6.onAllImagesLoaded();
|
|
1818
1322
|
|
|
1819
|
-
|
|
1820
|
-
|
|
1323
|
+
if (lazyload) {
|
|
1324
|
+
_this6.innerBox.removeChild(_this6.lazyloadInitImageX);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1821
1328
|
|
|
1822
|
-
|
|
1329
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(this.srcXConfig, srcX, onImageLoad.bind(this, _ci2.ORIENTATIONS.X));
|
|
1823
1330
|
|
|
1824
|
-
if (
|
|
1825
|
-
|
|
1331
|
+
if (this.allowSpinY) {
|
|
1332
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(this.srcYConfig, srcY, onImageLoad.bind(this, _ci2.ORIENTATIONS.Y));
|
|
1826
1333
|
}
|
|
1827
1334
|
|
|
1828
1335
|
this.attachEvents(draggable, swipeable, keys);
|
|
1829
|
-
|
|
1830
|
-
if (onMouseLeave) this.setMouseLeaveActions(onMouseLeave);
|
|
1831
1336
|
}
|
|
1832
1337
|
}]);
|
|
1833
|
-
|
|
1834
1338
|
return CI360Viewer;
|
|
1835
1339
|
}();
|
|
1836
1340
|
|
|
1837
|
-
|
|
1341
|
+
var _default = CI360Viewer;
|
|
1342
|
+
exports.default = _default;
|