js-cloudimage-360-view 2.7.2-beta.3 → 2.7.2-beta.4
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/dist/ci360.constants.js +8 -13
- package/dist/ci360.service.js +733 -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,134 @@ 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
|
+
return;
|
|
647
|
+
}
|
|
729
648
|
|
|
730
649
|
if (this.containerWidth && this.containerHeight) {
|
|
731
650
|
this.container.style.width = containerWidth + 'px';
|
|
732
651
|
this.container.style.height = containerHeight / imageAspectRatio + 'px';
|
|
733
|
-
|
|
734
652
|
return;
|
|
735
653
|
}
|
|
736
654
|
|
|
737
655
|
if (!this.containerWidth && !this.containerHeight) {
|
|
738
656
|
this.container.style.height = containerHeight / imageAspectRatio + 'px';
|
|
739
|
-
|
|
740
657
|
return;
|
|
741
658
|
}
|
|
742
659
|
|
|
@@ -749,95 +666,47 @@ var CI360Viewer = function () {
|
|
|
749
666
|
}
|
|
750
667
|
}
|
|
751
668
|
}, {
|
|
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) {
|
|
669
|
+
key: "onResizedImageLoad",
|
|
670
|
+
value: function onResizedImageLoad(orientation, image, index) {
|
|
771
671
|
if (orientation === _ci2.ORIENTATIONS.Y) {
|
|
772
|
-
this.
|
|
672
|
+
this.resizedImagesY[index] = image;
|
|
773
673
|
} else {
|
|
774
|
-
this.
|
|
674
|
+
this.resizedImagesX[index] = image;
|
|
775
675
|
}
|
|
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
676
|
|
|
794
|
-
|
|
677
|
+
var loadedResizedXImages = this.resizedImagesX.filter(function (image) {
|
|
678
|
+
return !!image;
|
|
795
679
|
});
|
|
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);
|
|
680
|
+
var loadedResizedYImages = this.resizedImagesY.filter(function (image) {
|
|
681
|
+
return !!image;
|
|
682
|
+
});
|
|
683
|
+
var isAllImagesLoaded = loadedResizedXImages.length + loadedResizedYImages.length === this.amountX + this.amountY;
|
|
819
684
|
|
|
820
|
-
if (
|
|
821
|
-
this.
|
|
822
|
-
|
|
823
|
-
this.
|
|
685
|
+
if (isAllImagesLoaded) {
|
|
686
|
+
this.imagesX = this.resizedImagesX;
|
|
687
|
+
this.imagesY = this.resizedImagesY;
|
|
688
|
+
this.update();
|
|
824
689
|
}
|
|
825
690
|
}
|
|
826
691
|
}, {
|
|
827
|
-
key:
|
|
692
|
+
key: "requestResizedImages",
|
|
828
693
|
value: function requestResizedImages() {
|
|
829
|
-
var
|
|
830
|
-
|
|
831
|
-
this.
|
|
694
|
+
var responsive = this.ciParams.ciToken;
|
|
695
|
+
var firstImage = this.imagesX[0];
|
|
696
|
+
this.updateContainerSize(firstImage);
|
|
697
|
+
this.update();
|
|
698
|
+
this.speedFactor = (0, _jsCloudimage360ViewUtils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
|
|
699
|
+
var srcX = (0, _jsCloudimage360ViewUtils.generateImagesPath)(this.srcXConfig);
|
|
700
|
+
if (!responsive || this.container.offsetWidth < firstImage.width * 1.5) return;
|
|
701
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(this.srcXConfig, srcX, this.onResizedImageLoad.bind(this, _ci2.ORIENTATIONS.X), true);
|
|
832
702
|
|
|
833
703
|
if (this.allowSpinY) {
|
|
834
|
-
var srcY =
|
|
835
|
-
|
|
836
|
-
this.requestNewImages(srcY, this.amountY, _ci2.ORIENTATIONS.Y);
|
|
704
|
+
var srcY = (0, _jsCloudimage360ViewUtils.generateImagesPath)(this.srcYConfig);
|
|
705
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(this.srcYConfig, srcY, this.onResizedImageLoad.bind(this, _ci2.ORIENTATIONS.Y), true);
|
|
837
706
|
}
|
|
838
707
|
}
|
|
839
708
|
}, {
|
|
840
|
-
key:
|
|
709
|
+
key: "update",
|
|
841
710
|
value: function update() {
|
|
842
711
|
var image = this.imagesX[this.activeImageX - 1];
|
|
843
712
|
|
|
@@ -846,30 +715,22 @@ var CI360Viewer = function () {
|
|
|
846
715
|
}
|
|
847
716
|
|
|
848
717
|
var ctx = this.canvas.getContext("2d");
|
|
849
|
-
|
|
850
718
|
ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
|
|
719
|
+
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
720
|
+
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
721
|
+
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
722
|
+
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
851
723
|
|
|
852
724
|
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,
|
|
725
|
+
var _contain = (0, _jsCloudimage360ViewUtils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
|
|
861
726
|
width = _contain.width,
|
|
862
|
-
height = _contain.height
|
|
727
|
+
height = _contain.height,
|
|
728
|
+
offsetX = _contain.offsetX,
|
|
729
|
+
offsetY = _contain.offsetY;
|
|
863
730
|
|
|
864
731
|
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
865
732
|
} 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) {
|
|
733
|
+
if (this.mouseTracked) {
|
|
873
734
|
this.updateImageScale(ctx);
|
|
874
735
|
} else {
|
|
875
736
|
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
@@ -877,7 +738,7 @@ var CI360Viewer = function () {
|
|
|
877
738
|
}
|
|
878
739
|
}
|
|
879
740
|
}, {
|
|
880
|
-
key:
|
|
741
|
+
key: "updateImageScale",
|
|
881
742
|
value: function updateImageScale(ctx) {
|
|
882
743
|
var image = this.originalImagesX[this.activeImageX - 1];
|
|
883
744
|
|
|
@@ -885,23 +746,17 @@ var CI360Viewer = function () {
|
|
|
885
746
|
image = this.originalImagesY[this.activeImageY - 1];
|
|
886
747
|
}
|
|
887
748
|
|
|
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
|
-
|
|
749
|
+
var position = this.getCursorPositionInCanvas();
|
|
750
|
+
var imageWidth = this.canvas.width;
|
|
751
|
+
var imageHeight = this.canvas.height;
|
|
752
|
+
var width = this.canvas.width * this.zoomIntensity;
|
|
753
|
+
var height = this.canvas.height * this.zoomIntensity;
|
|
898
754
|
var pointX = 0 - position.x / imageWidth * (width - this.canvas.width);
|
|
899
755
|
var pointY = 0 - position.y / imageHeight * (height - this.canvas.height);
|
|
900
|
-
|
|
901
756
|
ctx.drawImage(image, pointX, pointY, width, height);
|
|
902
757
|
}
|
|
903
758
|
}, {
|
|
904
|
-
key:
|
|
759
|
+
key: "updatePercentageInLoader",
|
|
905
760
|
value: function updatePercentageInLoader(percentage) {
|
|
906
761
|
if (this.loader) {
|
|
907
762
|
this.loader.style.width = percentage + '%';
|
|
@@ -912,53 +767,10 @@ var CI360Viewer = function () {
|
|
|
912
767
|
}
|
|
913
768
|
}
|
|
914
769
|
}, {
|
|
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
|
-
}
|
|
770
|
+
key: "onFirstImageLoaded",
|
|
771
|
+
value: function onFirstImageLoaded(image) {
|
|
772
|
+
if (!this.hide360Logo && !this.lazyload) this.add360ViewIcon();
|
|
773
|
+
var ctx = this.canvas.getContext("2d");
|
|
962
774
|
|
|
963
775
|
if (this.fullscreenView) {
|
|
964
776
|
this.canvas.width = window.innerWidth * this.devicePixelRatio;
|
|
@@ -966,71 +778,35 @@ var CI360Viewer = function () {
|
|
|
966
778
|
this.canvas.height = window.innerHeight * this.devicePixelRatio;
|
|
967
779
|
this.canvas.style.height = window.innerHeight + 'px';
|
|
968
780
|
|
|
969
|
-
var
|
|
970
|
-
|
|
971
|
-
var _contain2 = (0, _ci.contain)(this.canvas.width, this.canvas.height, event.target.width, event.target.height),
|
|
781
|
+
var _contain2 = (0, _jsCloudimage360ViewUtils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
|
|
972
782
|
offsetX = _contain2.offsetX,
|
|
973
783
|
offsetY = _contain2.offsetY,
|
|
974
784
|
width = _contain2.width,
|
|
975
785
|
height = _contain2.height;
|
|
976
786
|
|
|
977
|
-
this.offset = {
|
|
978
|
-
|
|
979
|
-
|
|
787
|
+
this.offset = {
|
|
788
|
+
x: offsetX,
|
|
789
|
+
y: offsetY
|
|
790
|
+
};
|
|
791
|
+
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
980
792
|
} 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
|
-
});
|
|
793
|
+
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
794
|
+
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
795
|
+
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
796
|
+
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
797
|
+
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
1022
798
|
}
|
|
1023
799
|
|
|
1024
800
|
if (this.fullscreenView) {
|
|
1025
801
|
this.addCloseFullscreenView();
|
|
1026
802
|
}
|
|
1027
803
|
|
|
1028
|
-
if (this.magnifier
|
|
804
|
+
if (this.magnifier) {
|
|
1029
805
|
this.addMagnifier();
|
|
1030
806
|
}
|
|
1031
807
|
|
|
1032
808
|
if (this.boxShadow && !this.fullscreenView) {
|
|
1033
|
-
this.
|
|
809
|
+
(0, _jsCloudimage360ViewUtils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
1034
810
|
}
|
|
1035
811
|
|
|
1036
812
|
if (this.bottomCircle && !this.fullscreenView) {
|
|
@@ -1040,339 +816,98 @@ var CI360Viewer = function () {
|
|
|
1040
816
|
if (this.fullscreen && !this.fullscreenView) {
|
|
1041
817
|
this.addFullscreenIcon();
|
|
1042
818
|
}
|
|
1043
|
-
|
|
1044
|
-
if (!this.isMobile && !this.fullscreenView && !this.disablePointerZoom) {
|
|
1045
|
-
this.addResetZoomIcon();
|
|
1046
|
-
}
|
|
1047
819
|
}
|
|
1048
820
|
}, {
|
|
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
|
-
}
|
|
821
|
+
key: "onAllImagesLoaded",
|
|
822
|
+
value: function onAllImagesLoaded() {
|
|
823
|
+
this.removeLoader();
|
|
824
|
+
this.imagesLoaded = true;
|
|
1072
825
|
|
|
1073
|
-
if (
|
|
1074
|
-
this.
|
|
826
|
+
if (this.autoplay && this.pointerZoom) {
|
|
827
|
+
this.container.style.cursor = 'zoom-in';
|
|
828
|
+
} else {
|
|
829
|
+
this.container.style.cursor = 'grab';
|
|
1075
830
|
}
|
|
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
831
|
|
|
1208
|
-
|
|
1209
|
-
fullscreenContainer.style.maxHeight = '100%';
|
|
832
|
+
this.speedFactor = (0, _jsCloudimage360ViewUtils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
|
|
1210
833
|
|
|
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');
|
|
834
|
+
if (this.autoplay) {
|
|
835
|
+
this.play();
|
|
836
|
+
}
|
|
1277
837
|
|
|
1278
|
-
|
|
1279
|
-
|
|
838
|
+
if (this.disableDrag) {
|
|
839
|
+
this.container.style.cursor = 'default';
|
|
840
|
+
}
|
|
1280
841
|
|
|
1281
|
-
|
|
842
|
+
if (this.view360Icon) {
|
|
843
|
+
this.view360Icon.innerText = '';
|
|
844
|
+
(0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
|
|
845
|
+
}
|
|
1282
846
|
|
|
1283
|
-
this.
|
|
847
|
+
this.initControls();
|
|
1284
848
|
}
|
|
1285
849
|
}, {
|
|
1286
|
-
key:
|
|
1287
|
-
value: function
|
|
1288
|
-
|
|
1289
|
-
if (this.magnifierIcon) this.enableMagnifierIcon();
|
|
1290
|
-
if (this.fullscreenIcon) this.showFullscreenIcon();
|
|
850
|
+
key: "magnify",
|
|
851
|
+
value: function magnify(event) {
|
|
852
|
+
var _this3 = this;
|
|
1291
853
|
|
|
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();
|
|
854
|
+
event.stopPropagation();
|
|
855
|
+
if (this.mouseTracked) this.togglePointerZoom();
|
|
856
|
+
var currentOriginalImage = (0, _jsCloudimage360ViewUtils.getCurrentOriginalImage)(this.movingDirection, this.imagesX, this.imagesY, this.activeImageX, this.activeImageY);
|
|
857
|
+
this.isMagnifyOpen = true;
|
|
1300
858
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
var loader = document.createElement('div');
|
|
1307
|
-
loader.className = 'cloudimage-360-loader';
|
|
859
|
+
currentOriginalImage.onload = function () {
|
|
860
|
+
if (_this3.glass) {
|
|
861
|
+
_this3.glass.style.cursor = 'none';
|
|
862
|
+
}
|
|
863
|
+
};
|
|
1308
864
|
|
|
1309
|
-
this.
|
|
1310
|
-
this.
|
|
865
|
+
this.glass = document.createElement('div');
|
|
866
|
+
this.container.style.overflow = 'hidden';
|
|
867
|
+
(0, _jsCloudimage360ViewUtils.magnify)(this.container, this.offset, currentOriginalImage, this.glass, this.magnifier || 3);
|
|
1311
868
|
}
|
|
1312
869
|
}, {
|
|
1313
|
-
key:
|
|
1314
|
-
value: function
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
this.innerBox.appendChild(boxShadow);
|
|
870
|
+
key: "closeMagnifier",
|
|
871
|
+
value: function closeMagnifier() {
|
|
872
|
+
if (!this.glass) return;
|
|
873
|
+
this.container.style.overflow = 'visible';
|
|
874
|
+
this.container.removeChild(this.glass);
|
|
875
|
+
this.glass = null;
|
|
876
|
+
this.isMagnifyOpen = false;
|
|
1321
877
|
}
|
|
1322
878
|
}, {
|
|
1323
|
-
key:
|
|
1324
|
-
value: function
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
879
|
+
key: "openFullscreenModal",
|
|
880
|
+
value: function openFullscreenModal(event) {
|
|
881
|
+
event.stopPropagation();
|
|
882
|
+
if (this.mouseTracked) this.togglePointerZoom();
|
|
883
|
+
var fullscreenContainer = (0, _jsCloudimage360ViewUtils.createFullscreenModal)(this.container);
|
|
884
|
+
new CI360Viewer(fullscreenContainer, true);
|
|
1329
885
|
}
|
|
1330
886
|
}, {
|
|
1331
|
-
key:
|
|
1332
|
-
value: function
|
|
1333
|
-
if (
|
|
887
|
+
key: "setFullscreenEvents",
|
|
888
|
+
value: function setFullscreenEvents(_, event) {
|
|
889
|
+
if (event.type === 'click') return this.closeFullscreenModal(event);
|
|
1334
890
|
|
|
1335
|
-
this.
|
|
1336
|
-
|
|
891
|
+
if (event.key === 'Escape' && this.container.parentNode.parentNode === document.body) {
|
|
892
|
+
this.closeFullscreenModalOnEsc(event);
|
|
893
|
+
}
|
|
1337
894
|
}
|
|
1338
895
|
}, {
|
|
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
|
-
}
|
|
896
|
+
key: "closeFullscreenModalOnEsc",
|
|
897
|
+
value: function closeFullscreenModalOnEsc(event) {
|
|
898
|
+
this.closeFullscreenModal(event);
|
|
1363
899
|
}
|
|
1364
900
|
}, {
|
|
1365
|
-
key:
|
|
901
|
+
key: "play",
|
|
1366
902
|
value: function play() {
|
|
1367
903
|
var _this4 = this;
|
|
1368
904
|
|
|
1369
905
|
if (this.bottomCircle) this.hide360ViewCircleIcon();
|
|
1370
906
|
this.remove360ViewIcon();
|
|
1371
|
-
|
|
1372
907
|
this.loopTimeoutId = window.setInterval(function () {
|
|
1373
908
|
_this4.loop(_this4.reversed);
|
|
1374
909
|
|
|
1375
|
-
var isPlayedOnce = _this4.
|
|
910
|
+
var isPlayedOnce = (0, _jsCloudimage360ViewUtils.isCompletedOneCycle)(_this4.autoplayBehavior, _this4.activeImageX, _this4.activeImageY, _this4.amountX, _this4.amountY, _this4.reversed);
|
|
1376
911
|
|
|
1377
912
|
if (_this4.playOnce && isPlayedOnce) {
|
|
1378
913
|
window.clearTimeout(_this4.loopTimeoutId);
|
|
@@ -1385,124 +920,18 @@ var CI360Viewer = function () {
|
|
|
1385
920
|
}, this.autoplaySpeed);
|
|
1386
921
|
}
|
|
1387
922
|
}, {
|
|
1388
|
-
key:
|
|
923
|
+
key: "stop",
|
|
1389
924
|
value: function stop() {
|
|
1390
|
-
if (this.bottomCircle
|
|
925
|
+
if (this.bottomCircle) this.show360ViewCircleIcon();
|
|
1391
926
|
window.clearTimeout(this.loopTimeoutId);
|
|
1392
927
|
}
|
|
1393
928
|
}, {
|
|
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',
|
|
929
|
+
key: "destroy",
|
|
1499
930
|
value: function destroy() {
|
|
1500
931
|
stop();
|
|
1501
|
-
|
|
1502
932
|
var oldElement = this.container;
|
|
1503
933
|
var newElement = oldElement.cloneNode(true);
|
|
1504
934
|
var innerBox = newElement.querySelector('.cloudimage-360-inner-box');
|
|
1505
|
-
|
|
1506
935
|
newElement.className = newElement.className.replace(' initialized', '');
|
|
1507
936
|
newElement.style.position = 'relative';
|
|
1508
937
|
newElement.style.width = '100%';
|
|
@@ -1513,240 +942,241 @@ var CI360Viewer = function () {
|
|
|
1513
942
|
oldElement.parentNode.replaceChild(newElement, oldElement);
|
|
1514
943
|
}
|
|
1515
944
|
}, {
|
|
1516
|
-
key:
|
|
945
|
+
key: "addCloseFullscreenView",
|
|
946
|
+
value: function addCloseFullscreenView(event) {
|
|
947
|
+
var closeFullscreenIcon = (0, _jsCloudimage360ViewUtils.createCloseFullscreenIcon)();
|
|
948
|
+
closeFullscreenIcon.onclick = this.setFullscreenEvents.bind(this, event);
|
|
949
|
+
window.onkeyup = this.setFullscreenEvents.bind(this, event);
|
|
950
|
+
this.iconsContainer.appendChild(closeFullscreenIcon);
|
|
951
|
+
}
|
|
952
|
+
}, {
|
|
953
|
+
key: "add360ViewIcon",
|
|
954
|
+
value: function add360ViewIcon() {
|
|
955
|
+
this.view360Icon = (0, _jsCloudimage360ViewUtils.create360ViewIcon)();
|
|
956
|
+
this.innerBox.appendChild(this.view360Icon);
|
|
957
|
+
}
|
|
958
|
+
}, {
|
|
959
|
+
key: "addFullscreenIcon",
|
|
960
|
+
value: function addFullscreenIcon() {
|
|
961
|
+
this.fullscreenIcon = (0, _jsCloudimage360ViewUtils.createFullscreenIcon)();
|
|
962
|
+
this.fullscreenIcon.onclick = this.openFullscreenModal.bind(this);
|
|
963
|
+
this.iconsContainer.appendChild(this.fullscreenIcon);
|
|
964
|
+
}
|
|
965
|
+
}, {
|
|
966
|
+
key: "showFullscreenIcon",
|
|
967
|
+
value: function showFullscreenIcon() {
|
|
968
|
+
if (!this.fullscreenIcon) return;
|
|
969
|
+
this.fullscreenIcon.style.display = 'block';
|
|
970
|
+
this.fullscreenIcon.style.pointerEvents = 'auto';
|
|
971
|
+
}
|
|
972
|
+
}, {
|
|
973
|
+
key: "hideFullscreenIcon",
|
|
974
|
+
value: function hideFullscreenIcon() {
|
|
975
|
+
if (!this.fullscreenIcon) return;
|
|
976
|
+
this.fullscreenIcon.style.display = 'none';
|
|
977
|
+
this.fullscreenIcon.style.pointerEvents = 'none';
|
|
978
|
+
}
|
|
979
|
+
}, {
|
|
980
|
+
key: "addMagnifier",
|
|
981
|
+
value: function addMagnifier() {
|
|
982
|
+
this.magnifierIcon = (0, _jsCloudimage360ViewUtils.createMagnifierIcon)();
|
|
983
|
+
this.magnifierIcon.onclick = this.magnify.bind(this);
|
|
984
|
+
this.iconsContainer.appendChild(this.magnifierIcon);
|
|
985
|
+
}
|
|
986
|
+
}, {
|
|
987
|
+
key: "enableMagnifierIcon",
|
|
988
|
+
value: function enableMagnifierIcon() {
|
|
989
|
+
if (!this.magnifierIcon) return;
|
|
990
|
+
this.magnifierIcon.style.display = 'block';
|
|
991
|
+
this.magnifierIcon.style.pointerEvents = 'auto';
|
|
992
|
+
}
|
|
993
|
+
}, {
|
|
994
|
+
key: "disableMagnifierIcon",
|
|
995
|
+
value: function disableMagnifierIcon() {
|
|
996
|
+
if (!this.magnifierIcon) return;
|
|
997
|
+
this.magnifierIcon.style.display = 'none';
|
|
998
|
+
this.magnifierIcon.style.pointerEvents = 'none';
|
|
999
|
+
}
|
|
1000
|
+
}, {
|
|
1001
|
+
key: "closeFullscreenModal",
|
|
1002
|
+
value: function closeFullscreenModal(event) {
|
|
1003
|
+
event.stopPropagation();
|
|
1004
|
+
document.body.removeChild(this.container.parentNode);
|
|
1005
|
+
window.document.body.style.overflow = 'visible';
|
|
1006
|
+
}
|
|
1007
|
+
}, {
|
|
1008
|
+
key: "add360ViewCircleIcon",
|
|
1009
|
+
value: function add360ViewCircleIcon() {
|
|
1010
|
+
this.view360CircleIcon = (0, _jsCloudimage360ViewUtils.create360ViewCircleIcon)(this.bottomCircleOffset);
|
|
1011
|
+
this.innerBox.appendChild(this.view360CircleIcon);
|
|
1012
|
+
}
|
|
1013
|
+
}, {
|
|
1014
|
+
key: "show360ViewCircleIcon",
|
|
1015
|
+
value: function show360ViewCircleIcon() {
|
|
1016
|
+
if (!this.view360CircleIcon) return;
|
|
1017
|
+
this.view360CircleIcon.style.opacity = '1';
|
|
1018
|
+
}
|
|
1019
|
+
}, {
|
|
1020
|
+
key: "hide360ViewCircleIcon",
|
|
1021
|
+
value: function hide360ViewCircleIcon() {
|
|
1022
|
+
if (!this.view360CircleIcon) return;
|
|
1023
|
+
this.view360CircleIcon.style.opacity = '0';
|
|
1024
|
+
}
|
|
1025
|
+
}, {
|
|
1026
|
+
key: "remove360ViewCircleIcon",
|
|
1027
|
+
value: function remove360ViewCircleIcon() {
|
|
1028
|
+
if (!this.view360CircleIcon) return;
|
|
1029
|
+
this.innerBox.removeChild(this.view360CircleIcon);
|
|
1030
|
+
this.view360CircleIcon = null;
|
|
1031
|
+
}
|
|
1032
|
+
}, {
|
|
1033
|
+
key: "removeLoader",
|
|
1034
|
+
value: function removeLoader() {
|
|
1035
|
+
if (!this.loader) return;
|
|
1036
|
+
this.innerBox.removeChild(this.loader);
|
|
1037
|
+
this.loader = null;
|
|
1038
|
+
}
|
|
1039
|
+
}, {
|
|
1040
|
+
key: "remove360ViewIcon",
|
|
1041
|
+
value: function remove360ViewIcon() {
|
|
1042
|
+
if (!this.view360Icon) return;
|
|
1043
|
+
this.innerBox.removeChild(this.view360Icon);
|
|
1044
|
+
this.view360Icon = null;
|
|
1045
|
+
}
|
|
1046
|
+
}, {
|
|
1047
|
+
key: "initControls",
|
|
1517
1048
|
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;
|
|
1049
|
+
var _this5 = this;
|
|
1529
1050
|
|
|
1530
1051
|
var onLeftStart = function onLeftStart(event) {
|
|
1531
1052
|
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
1053
|
|
|
1543
|
-
|
|
1544
|
-
event.stopPropagation();
|
|
1545
|
-
_this6.onSpin();
|
|
1546
|
-
_this6.top();
|
|
1547
|
-
_this6.loopTimeoutId = window.setInterval(_this6.top.bind(_this6), _this6.autoplaySpeed);
|
|
1548
|
-
};
|
|
1054
|
+
_this5.onSpin();
|
|
1549
1055
|
|
|
1550
|
-
|
|
1551
|
-
event.stopPropagation();
|
|
1552
|
-
_this6.onSpin();
|
|
1553
|
-
_this6.bottom();
|
|
1554
|
-
_this6.loopTimeoutId = window.setInterval(_this6.bottom.bind(_this6), _this6.autoplaySpeed);
|
|
1555
|
-
};
|
|
1056
|
+
_this5.left();
|
|
1556
1057
|
|
|
1557
|
-
|
|
1558
|
-
_this6.onFinishSpin();
|
|
1559
|
-
window.clearTimeout(_this6.loopTimeoutId);
|
|
1058
|
+
_this5.loopTimeoutId = window.setInterval(_this5.left.bind(_this5), _this5.autoplaySpeed);
|
|
1560
1059
|
};
|
|
1561
1060
|
|
|
1562
|
-
var
|
|
1563
|
-
|
|
1564
|
-
window.clearTimeout(_this6.loopTimeoutId);
|
|
1565
|
-
};
|
|
1061
|
+
var onRightStart = function onRightStart(event) {
|
|
1062
|
+
event.stopPropagation();
|
|
1566
1063
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
};
|
|
1064
|
+
_this5.onSpin();
|
|
1065
|
+
|
|
1066
|
+
_this5.right();
|
|
1571
1067
|
|
|
1572
|
-
|
|
1573
|
-
_this6.onFinishSpin();
|
|
1574
|
-
window.clearTimeout(_this6.loopTimeoutId);
|
|
1068
|
+
_this5.loopTimeoutId = window.setInterval(_this5.right.bind(_this5), _this5.autoplaySpeed);
|
|
1575
1069
|
};
|
|
1576
1070
|
|
|
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);
|
|
1071
|
+
var onTopStart = function onTopStart(event) {
|
|
1072
|
+
event.stopPropagation();
|
|
1583
1073
|
|
|
1584
|
-
|
|
1585
|
-
}
|
|
1074
|
+
_this5.onSpin();
|
|
1586
1075
|
|
|
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);
|
|
1076
|
+
_this5.top();
|
|
1593
1077
|
|
|
1594
|
-
|
|
1595
|
-
}
|
|
1078
|
+
_this5.loopTimeoutId = window.setInterval(_this5.top.bind(_this5), _this5.autoplaySpeed);
|
|
1079
|
+
};
|
|
1596
1080
|
|
|
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);
|
|
1081
|
+
var onBottomStart = function onBottomStart(event) {
|
|
1082
|
+
event.stopPropagation();
|
|
1603
1083
|
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1084
|
+
_this5.onSpin();
|
|
1606
1085
|
|
|
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);
|
|
1086
|
+
_this5.bottom();
|
|
1613
1087
|
|
|
1614
|
-
|
|
1615
|
-
}
|
|
1088
|
+
_this5.loopTimeoutId = window.setInterval(_this5.bottom.bind(_this5), _this5.autoplaySpeed);
|
|
1089
|
+
};
|
|
1616
1090
|
|
|
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';
|
|
1091
|
+
var onEventEnd = function onEventEnd() {
|
|
1092
|
+
_this5.onFinishSpin();
|
|
1635
1093
|
|
|
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';
|
|
1094
|
+
window.clearTimeout(_this5.loopTimeoutId);
|
|
1095
|
+
};
|
|
1644
1096
|
|
|
1645
|
-
|
|
1097
|
+
var controlsConfig = {
|
|
1098
|
+
container: this.container,
|
|
1099
|
+
controlReverse: this.controlReverse,
|
|
1100
|
+
spinReverse: this.spinReverse,
|
|
1101
|
+
stopAtEdges: this.stopAtEdges
|
|
1102
|
+
};
|
|
1103
|
+
var controlsTriggers = {
|
|
1104
|
+
onLeftStart: onLeftStart,
|
|
1105
|
+
onRightStart: onRightStart,
|
|
1106
|
+
onTopStart: onTopStart,
|
|
1107
|
+
onBottomStart: onBottomStart,
|
|
1108
|
+
onEventEnd: onEventEnd
|
|
1109
|
+
};
|
|
1110
|
+
var controlsElements = (0, _jsCloudimage360ViewUtils.initControls)(controlsConfig, controlsTriggers);
|
|
1111
|
+
this.topElem = controlsElements.top || {};
|
|
1112
|
+
this.bottomElem = controlsElements.bottom || {};
|
|
1113
|
+
this.leftElem = controlsElements.left || {};
|
|
1114
|
+
this.rightElem = controlsElements.right || {};
|
|
1646
1115
|
}
|
|
1647
1116
|
}, {
|
|
1648
|
-
key:
|
|
1117
|
+
key: "attachEvents",
|
|
1649
1118
|
value: function attachEvents(draggable, swipeable, keys) {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
window.addEventListener('resize', (0, _ci.debounce)(function () {
|
|
1653
|
-
_this7.requestResizedImages();
|
|
1654
|
-
}, 80));
|
|
1119
|
+
window.addEventListener('resize', this.requestResizedImages.bind(this));
|
|
1655
1120
|
|
|
1656
1121
|
if (draggable && !this.disableDrag) {
|
|
1122
|
+
this.container.addEventListener('click', this.mouseClick.bind(this));
|
|
1657
1123
|
this.container.addEventListener('mousedown', this.mouseDown.bind(this));
|
|
1658
1124
|
this.container.addEventListener('mousemove', this.mouseMove.bind(this));
|
|
1125
|
+
this.container.addEventListener('mouseleave', this.mouseLeave.bind(this));
|
|
1659
1126
|
document.addEventListener('mouseup', this.mouseUp.bind(this));
|
|
1660
1127
|
}
|
|
1661
1128
|
|
|
1662
1129
|
if (swipeable && !this.disableDrag) {
|
|
1663
|
-
this.container.addEventListener('touchstart', this.touchStart.bind(this), {
|
|
1130
|
+
this.container.addEventListener('touchstart', this.touchStart.bind(this), {
|
|
1131
|
+
passive: true
|
|
1132
|
+
});
|
|
1664
1133
|
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));
|
|
1134
|
+
this.container.addEventListener('touchmove', this.touchMove.bind(this), {
|
|
1135
|
+
passive: true
|
|
1136
|
+
});
|
|
1671
1137
|
}
|
|
1672
1138
|
|
|
1673
1139
|
if (keys) {
|
|
1674
1140
|
document.addEventListener('keydown', this.keyDown.bind(this));
|
|
1675
1141
|
document.addEventListener('keyup', this.keyUp.bind(this));
|
|
1676
|
-
} else {
|
|
1677
|
-
document.addEventListener('keydown', this.keyDownGeneral.bind(this));
|
|
1678
1142
|
}
|
|
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
1143
|
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
mouseLeaveActions.forEach(function (action) {
|
|
1697
|
-
return _this8.applyMouseLeaveAction(action);
|
|
1698
|
-
});
|
|
1144
|
+
document.addEventListener('keydown', this.keyDownGeneral.bind(this));
|
|
1699
1145
|
}
|
|
1700
1146
|
}, {
|
|
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',
|
|
1147
|
+
key: "init",
|
|
1711
1148
|
value: function init(container) {
|
|
1149
|
+
var _this6 = this;
|
|
1150
|
+
|
|
1712
1151
|
var _get360ViewProps = (0, _ci.get360ViewProps)(container),
|
|
1713
1152
|
folder = _get360ViewProps.folder,
|
|
1714
1153
|
apiVersion = _get360ViewProps.apiVersion,
|
|
1715
1154
|
filenameX = _get360ViewProps.filenameX,
|
|
1716
1155
|
filenameY = _get360ViewProps.filenameY,
|
|
1717
|
-
|
|
1156
|
+
imageListX = _get360ViewProps.imageListX,
|
|
1157
|
+
imageListY = _get360ViewProps.imageListY,
|
|
1718
1158
|
indexZeroBase = _get360ViewProps.indexZeroBase,
|
|
1719
1159
|
amountX = _get360ViewProps.amountX,
|
|
1720
1160
|
amountY = _get360ViewProps.amountY,
|
|
1721
1161
|
imageOffset = _get360ViewProps.imageOffset,
|
|
1722
1162
|
_get360ViewProps$drag = _get360ViewProps.draggable,
|
|
1723
|
-
draggable = _get360ViewProps$drag ===
|
|
1163
|
+
draggable = _get360ViewProps$drag === void 0 ? true : _get360ViewProps$drag,
|
|
1724
1164
|
_get360ViewProps$swip = _get360ViewProps.swipeable,
|
|
1725
|
-
swipeable = _get360ViewProps$swip ===
|
|
1165
|
+
swipeable = _get360ViewProps$swip === void 0 ? true : _get360ViewProps$swip,
|
|
1726
1166
|
keys = _get360ViewProps.keys,
|
|
1167
|
+
keysReverse = _get360ViewProps.keysReverse,
|
|
1727
1168
|
bottomCircle = _get360ViewProps.bottomCircle,
|
|
1728
1169
|
bottomCircleOffset = _get360ViewProps.bottomCircleOffset,
|
|
1729
1170
|
boxShadow = _get360ViewProps.boxShadow,
|
|
1730
1171
|
autoplay = _get360ViewProps.autoplay,
|
|
1731
1172
|
autoplayBehavior = _get360ViewProps.autoplayBehavior,
|
|
1732
1173
|
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
1174
|
speed = _get360ViewProps.speed,
|
|
1743
1175
|
autoplayReverse = _get360ViewProps.autoplayReverse,
|
|
1744
|
-
_get360ViewProps$
|
|
1745
|
-
disableDrag = _get360ViewProps$
|
|
1176
|
+
_get360ViewProps$disa = _get360ViewProps.disableDrag,
|
|
1177
|
+
disableDrag = _get360ViewProps$disa === void 0 ? true : _get360ViewProps$disa,
|
|
1746
1178
|
fullscreen = _get360ViewProps.fullscreen,
|
|
1747
1179
|
magnifier = _get360ViewProps.magnifier,
|
|
1748
|
-
magnifyInFullscreen = _get360ViewProps.magnifyInFullscreen,
|
|
1749
|
-
ratio = _get360ViewProps.ratio,
|
|
1750
1180
|
ciToken = _get360ViewProps.ciToken,
|
|
1751
1181
|
ciFilters = _get360ViewProps.ciFilters,
|
|
1752
1182
|
ciTransformation = _get360ViewProps.ciTransformation,
|
|
@@ -1759,25 +1189,26 @@ var CI360Viewer = function () {
|
|
|
1759
1189
|
hide360Logo = _get360ViewProps.hide360Logo,
|
|
1760
1190
|
logoSrc = _get360ViewProps.logoSrc,
|
|
1761
1191
|
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();
|
|
1192
|
+
containerHeight = _get360ViewProps.containerHeight,
|
|
1193
|
+
pointerZoom = _get360ViewProps.pointerZoom;
|
|
1769
1194
|
|
|
1195
|
+
var ciParams = {
|
|
1196
|
+
ciToken: ciToken,
|
|
1197
|
+
ciFilters: ciFilters,
|
|
1198
|
+
ciTransformation: ciTransformation
|
|
1199
|
+
};
|
|
1770
1200
|
this.folder = folder;
|
|
1771
1201
|
this.apiVersion = apiVersion;
|
|
1772
1202
|
this.filenameX = filenameX;
|
|
1773
1203
|
this.filenameY = filenameY;
|
|
1774
|
-
this.
|
|
1204
|
+
this.imageListX = imageListX;
|
|
1205
|
+
this.imageListY = imageListY;
|
|
1775
1206
|
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;
|
|
1207
|
+
this.amountX = imageListX ? JSON.parse(imageListX).length : amountX;
|
|
1208
|
+
this.amountY = imageListY ? JSON.parse(imageListY).length : amountY;
|
|
1209
|
+
this.allowSpinY = !!this.amountY;
|
|
1210
|
+
this.activeImageX = autoplayReverse ? this.amountX : 1;
|
|
1211
|
+
this.activeImageY = autoplayReverse ? this.amountY : 1;
|
|
1781
1212
|
this.spinY = autoplayBehavior === _ci2.AUTOPLAY_BEHAVIOR.SPIN_YX ? true : false;
|
|
1782
1213
|
this.imageOffset = imageOffset;
|
|
1783
1214
|
this.bottomCircle = bottomCircle;
|
|
@@ -1786,20 +1217,14 @@ var CI360Viewer = function () {
|
|
|
1786
1217
|
this.autoplay = autoplay;
|
|
1787
1218
|
this.autoplayBehavior = autoplayBehavior;
|
|
1788
1219
|
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
1220
|
this.speed = speed;
|
|
1795
1221
|
this.reversed = autoplayReverse;
|
|
1796
1222
|
this.disableDrag = disableDrag;
|
|
1797
1223
|
this.fullscreen = fullscreen;
|
|
1798
1224
|
this.magnifier = !this.isMobile && magnifier ? magnifier : false;
|
|
1799
|
-
this.
|
|
1800
|
-
this.
|
|
1225
|
+
this.lazyloadX = lazyload;
|
|
1226
|
+
this.lazyloadY = lazyload;
|
|
1801
1227
|
this.lazySelector = lazySelector;
|
|
1802
|
-
this.ratio = ratio;
|
|
1803
1228
|
this.spinReverse = spinReverse;
|
|
1804
1229
|
this.controlReverse = controlReverse;
|
|
1805
1230
|
this.dragSpeed = dragSpeed;
|
|
@@ -1811,27 +1236,106 @@ var CI360Viewer = function () {
|
|
|
1811
1236
|
this.apiVersion = apiVersion;
|
|
1812
1237
|
this.containerWidth = containerWidth;
|
|
1813
1238
|
this.containerHeight = containerHeight;
|
|
1239
|
+
this.pointerZoom = pointerZoom;
|
|
1240
|
+
this.keysReverse = keysReverse;
|
|
1241
|
+
this.innerBox = (0, _jsCloudimage360ViewUtils.createInnerBox)(this.container);
|
|
1242
|
+
this.iconsContainer = (0, _jsCloudimage360ViewUtils.createIconsContainer)(this.innerBox);
|
|
1243
|
+
this.canvas = (0, _jsCloudimage360ViewUtils.createCanvas)(this.innerBox);
|
|
1244
|
+
this.loader = (0, _jsCloudimage360ViewUtils.createLoader)(this.innerBox);
|
|
1245
|
+
(0, _jsCloudimage360ViewUtils.applyStylesToContainer)(this.container);
|
|
1246
|
+
this.srcXConfig = {
|
|
1247
|
+
folder: folder,
|
|
1248
|
+
filename: filenameX,
|
|
1249
|
+
imageList: imageListX,
|
|
1250
|
+
container: container,
|
|
1251
|
+
innerBox: this.innerBox,
|
|
1252
|
+
apiVersion: apiVersion,
|
|
1253
|
+
ciParams: ciParams,
|
|
1254
|
+
lazyload: lazyload,
|
|
1255
|
+
lazySelector: lazySelector,
|
|
1256
|
+
amount: this.amountX,
|
|
1257
|
+
indexZeroBase: indexZeroBase,
|
|
1258
|
+
fullscreen: this.fullscreenView
|
|
1259
|
+
};
|
|
1260
|
+
this.srcYConfig = _objectSpread(_objectSpread({}, this.srcXConfig), {}, {
|
|
1261
|
+
filename: filenameY,
|
|
1262
|
+
orientation: _ci2.ORIENTATIONS.Y,
|
|
1263
|
+
imageList: imageListY,
|
|
1264
|
+
amount: this.amountY
|
|
1265
|
+
});
|
|
1266
|
+
var srcX = (0, _jsCloudimage360ViewUtils.generateImagesPath)(this.srcXConfig);
|
|
1267
|
+
var srcY = (0, _jsCloudimage360ViewUtils.generateImagesPath)(this.srcYConfig);
|
|
1268
|
+
|
|
1269
|
+
var initLazyload = function initLazyload(image, orientation) {
|
|
1270
|
+
var lazyloadXConfig = _objectSpread(_objectSpread({}, _this6.srcXConfig), {}, {
|
|
1271
|
+
lazyload: false
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
var lazyloadYConfig = _objectSpread(_objectSpread({}, _this6.srcYConfig), {}, {
|
|
1275
|
+
lazyload: false
|
|
1276
|
+
});
|
|
1277
|
+
|
|
1278
|
+
if (orientation === _ci2.ORIENTATIONS.Y) {
|
|
1279
|
+
_this6.lazyloadY = false;
|
|
1280
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(lazyloadXConfig, srcX, onImageLoad.bind(_this6, _ci2.ORIENTATIONS.X));
|
|
1281
|
+
} else {
|
|
1282
|
+
_this6.lazyloadX = false;
|
|
1283
|
+
_this6.lazyloadInitImageX = image;
|
|
1284
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(lazyloadYConfig, srcY, onImageLoad.bind(_this6, _ci2.ORIENTATIONS.Y));
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
var onImageLoad = function onImageLoad(orientation, image, index) {
|
|
1289
|
+
if (orientation !== _ci2.ORIENTATIONS.Y) {
|
|
1290
|
+
_this6.imagesX[index] = image;
|
|
1291
|
+
} else {
|
|
1292
|
+
_this6.imagesY[index] = image;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
var loadedXImages = _this6.imagesX.filter(function (image) {
|
|
1296
|
+
return !!image;
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
var loadedYImages = _this6.imagesY.filter(function (image) {
|
|
1300
|
+
return !!image;
|
|
1301
|
+
});
|
|
1302
|
+
|
|
1303
|
+
var totalAmount = _this6.amountX + _this6.amountY;
|
|
1304
|
+
var totalLoadedImages = _this6.imagesX.length + _this6.imagesY.length;
|
|
1305
|
+
var isFirstImageLoaded = index === 0 && orientation !== _ci2.ORIENTATIONS.Y;
|
|
1306
|
+
var isAllImagesLoaded = loadedXImages.length + loadedYImages.length === _this6.amountX + _this6.amountY;
|
|
1307
|
+
var percentage = Math.round(totalLoadedImages / totalAmount * 100);
|
|
1308
|
+
|
|
1309
|
+
_this6.updatePercentageInLoader(percentage);
|
|
1310
|
+
|
|
1311
|
+
if (_this6.lazyloadX || _this6.lazyloadY) return initLazyload(image, orientation);
|
|
1814
1312
|
|
|
1815
|
-
|
|
1313
|
+
if (isFirstImageLoaded) {
|
|
1314
|
+
_this6.updateContainerSize(image);
|
|
1816
1315
|
|
|
1817
|
-
|
|
1316
|
+
_this6.onFirstImageLoaded(image);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
if (isAllImagesLoaded) {
|
|
1320
|
+
_this6.onAllImagesLoaded();
|
|
1818
1321
|
|
|
1819
|
-
|
|
1820
|
-
|
|
1322
|
+
if (lazyload) {
|
|
1323
|
+
_this6.innerBox.removeChild(_this6.lazyloadInitImageX);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1821
1327
|
|
|
1822
|
-
|
|
1328
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(this.srcXConfig, srcX, onImageLoad.bind(this, _ci2.ORIENTATIONS.X));
|
|
1823
1329
|
|
|
1824
|
-
if (
|
|
1825
|
-
|
|
1330
|
+
if (this.allowSpinY) {
|
|
1331
|
+
(0, _jsCloudimage360ViewUtils.preloadImages)(this.srcYConfig, srcY, onImageLoad.bind(this, _ci2.ORIENTATIONS.Y));
|
|
1826
1332
|
}
|
|
1827
1333
|
|
|
1828
1334
|
this.attachEvents(draggable, swipeable, keys);
|
|
1829
|
-
|
|
1830
|
-
if (onMouseLeave) this.setMouseLeaveActions(onMouseLeave);
|
|
1831
1335
|
}
|
|
1832
1336
|
}]);
|
|
1833
|
-
|
|
1834
1337
|
return CI360Viewer;
|
|
1835
1338
|
}();
|
|
1836
1339
|
|
|
1837
|
-
|
|
1340
|
+
var _default = CI360Viewer;
|
|
1341
|
+
exports.default = _default;
|