js-cloudimage-360-view 3.0.0-beta.2 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/LICENSE +13 -1
- package/README.md +404 -145
- package/dist/ci360.service.js +878 -1163
- package/dist/ci360.utils.js +28 -204
- package/dist/constants/auto-play-behavior.js +13 -0
- package/dist/constants/falsy-values.js +8 -0
- package/dist/constants/index.js +43 -0
- package/dist/constants/orientations.js +12 -0
- package/dist/constants/props-require-reload.js +21 -0
- package/dist/constants/regex.js +10 -0
- package/dist/index.js +73 -12
- package/dist/static/css/hotspots.css +222 -0
- package/dist/static/css/style.css +116 -7
- package/dist/utils/auto-play/get-speed-factor.js +14 -0
- package/dist/utils/auto-play/is-completed-one-cycle.js +32 -0
- package/dist/utils/auto-play/loop.js +67 -0
- package/dist/utils/class-names/add-class.js +18 -0
- package/dist/utils/class-names/remove-class.js +16 -0
- package/dist/utils/container-elements/apply-styles-to-container.js +16 -0
- package/dist/utils/container-elements/create-360-view-circle-icon.js +16 -0
- package/dist/utils/container-elements/create-360-view-icon.js +15 -0
- package/dist/utils/container-elements/create-box-shadow.js +16 -0
- package/dist/utils/container-elements/create-canvas.js +16 -0
- package/dist/utils/container-elements/create-close-fullscreen-icon.js +14 -0
- package/dist/utils/container-elements/create-fullscreen-icon.js +14 -0
- package/dist/utils/container-elements/create-fullscreen-modal.js +20 -0
- package/dist/utils/container-elements/create-icons-container.js +15 -0
- package/dist/utils/container-elements/create-inner-box.js +15 -0
- package/dist/utils/container-elements/create-loader.js +15 -0
- package/dist/utils/container-elements/create-magnifier-icon.js +14 -0
- package/dist/utils/container-elements/index.js +109 -0
- package/dist/utils/container-elements/remove-child-from-parent.js +16 -0
- package/dist/utils/controls/get-item-skipped.js +13 -0
- package/dist/utils/controls/init-controls.js +77 -0
- package/dist/utils/hotspots/attach-events/hide-popup.js +15 -0
- package/dist/utils/hotspots/attach-events/show-popup.js +14 -0
- package/dist/utils/hotspots/configs-error-handler.js +27 -0
- package/dist/utils/hotspots/create-popper-instace.js +32 -0
- package/dist/utils/hotspots/elements/create-carousel-dot.js +26 -0
- package/dist/utils/hotspots/elements/create-carousel-image.js +22 -0
- package/dist/utils/hotspots/elements/create-hotspot-icon.js +66 -0
- package/dist/utils/hotspots/elements/create-hotspot-popup-link.js +23 -0
- package/dist/utils/hotspots/elements/create-hotspots.js +25 -0
- package/dist/utils/hotspots/elements/create-images-carousel.js +27 -0
- package/dist/utils/hotspots/elements/create-modal-description.js +15 -0
- package/dist/utils/hotspots/elements/create-modal-title.js +15 -0
- package/dist/utils/hotspots/elements/create-model-elements.js +66 -0
- package/dist/utils/hotspots/elements/create-popup-arrow.js +16 -0
- package/dist/utils/hotspots/elements/create-popup.js +67 -0
- package/dist/utils/hotspots/elements/create-read-more-btn.js +17 -0
- package/dist/utils/hotspots/fill-empty-coord-with-previous.js +26 -0
- package/dist/utils/hotspots/generate-hotspots-configs.js +58 -0
- package/dist/utils/hotspots/generate-popup-config.js +29 -0
- package/dist/utils/hotspots/get-hotspot-icon.js +14 -0
- package/dist/utils/hotspots/get-hotspot-orientation.js +21 -0
- package/dist/utils/hotspots/get-hotspot-popup-node.js +14 -0
- package/dist/utils/hotspots/get-popup-node.js +14 -0
- package/dist/utils/hotspots/hide-hotspot-icon.js +13 -0
- package/dist/utils/hotspots/hide-hotspots-icons.js +18 -0
- package/dist/utils/hotspots/is-mouse-on-hotspot.js +14 -0
- package/dist/utils/hotspots/prepare-hotspots-positions.js +28 -0
- package/dist/utils/hotspots/set-current-slide.js +23 -0
- package/dist/utils/hotspots/toggle-popup-events.js +23 -0
- package/dist/utils/hotspots/update-hotspot-icon-position.js +21 -0
- package/dist/utils/hotspots/update-hotspots.js +48 -0
- package/dist/utils/image-src/generate-images-path.js +42 -0
- package/dist/utils/image-src/is-props-change-require-reload.js +23 -0
- package/dist/utils/index.js +237 -0
- package/dist/utils/load-images/images-from-folder/prepare-images-from-folder.js +34 -0
- package/dist/utils/load-images/images-from-list/prepare-images-from-list.js +35 -0
- package/dist/utils/load-images/lazyload/init-lazyload.js +49 -0
- package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-folder.js +18 -0
- package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-list.js +29 -0
- package/dist/utils/load-images/load-image-as-promise.js +54 -0
- package/dist/utils/load-images/load-images-relative-to-container-size.js +58 -0
- package/dist/utils/load-images/load-original-images.js +58 -0
- package/dist/utils/load-images/pad.js +14 -0
- package/dist/utils/load-images/preload-images.js +35 -0
- package/dist/utils/load-images/preload-original-images.js +35 -0
- package/dist/utils/magnify/get-current-original-image.js +29 -0
- package/dist/utils/magnify/get-cursor-position.js +24 -0
- package/dist/utils/magnify/magnify.js +54 -0
- package/dist/utils/magnify/move-magnifier.js +47 -0
- package/dist/utils/responsive/contain.js +11 -0
- package/dist/utils/responsive/fit.js +33 -0
- package/dist/utils/responsive/get-image-aspect-ratio.js +39 -0
- package/dist/utils/responsive/get-responsive-width-of-container.js +14 -0
- package/dist/utils/responsive/get-size-according-to-pixel-ratio.js +17 -0
- package/dist/utils/responsive/get-size-limit.js +14 -0
- package/dist/utils/spin-y/get-moving-direction.js +21 -0
- package/dist/utils/zoom/generate-zoom-in-steps.js +20 -0
- package/dist/utils/zoom/generate-zoom-out-steps.js +20 -0
- package/package.json +13 -8
- package/dist/ci360.constants.js +0 -36
package/dist/ci360.utils.js
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.setView360Icon = exports.isTrue = exports.get360ViewProps = exports.debounce = exports.attr = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _constants = require("./constants");
|
|
9
|
+
|
|
10
|
+
var _this = void 0;
|
|
9
11
|
|
|
10
12
|
//TODO [deprecated]: remove filename, amount in the upcoming versions
|
|
11
13
|
var get360ViewProps = function get360ViewProps(image) {
|
|
12
14
|
return {
|
|
13
15
|
folder: attr(image, 'folder') || attr(image, 'data-folder') || '/',
|
|
16
|
+
apiVersion: attr(image, 'api-version') || attr(image, 'data-api-version') || attr(image, 'apiVersion') || attr(image, 'data-apiVersion') || "v7",
|
|
14
17
|
filenameX: attr(image, 'filename') || attr(image, 'data-filename') || attr(image, 'filename-x') || attr(image, 'data-filename-x') || 'image-{index}.jpg',
|
|
15
18
|
filenameY: attr(image, 'filename-y') || attr(image, 'data-filename-y') || 'image-y-{index}.jpg',
|
|
16
|
-
|
|
19
|
+
imageListX: attr(image, 'image-list-x') || attr(image, 'data-image-list-x') || null,
|
|
20
|
+
imageListY: attr(image, 'image-list-y') || attr(image, 'data-image-list-y') || null,
|
|
17
21
|
indexZeroBase: parseInt(attr(image, 'index-zero-base') || attr(image, 'data-index-zero-base') || 0, 10),
|
|
18
22
|
amountX: parseInt(attr(image, 'amount') || attr(image, 'data-amount') || attr(image, 'amount-x') || attr(image, 'data-amount-x') || 36, 10),
|
|
19
23
|
amountY: parseInt(attr(image, 'amount-y') || attr(image, 'data-amount-y') || 0, 10),
|
|
20
|
-
imageOffset: parseInt(attr(image, 'image-offset') || attr(image, 'data-image-offset')),
|
|
21
24
|
speed: parseInt(attr(image, 'speed') || attr(image, 'data-speed') || 80, 10),
|
|
22
25
|
dragSpeed: parseInt(attr(image, 'drag-speed') || attr(image, 'data-drag-speed') || 150, 10),
|
|
23
26
|
keys: isTrue(image, 'keys'),
|
|
27
|
+
keysReverse: isTrue(image, 'keys-reverse'),
|
|
24
28
|
boxShadow: attr(image, 'box-shadow') || attr(image, 'data-box-shadow'),
|
|
25
29
|
autoplay: isTrue(image, 'autoplay'),
|
|
26
|
-
autoplayBehavior: attr(image, 'autoplay-behavior') || attr(image, 'data-autoplay-behavior') ||
|
|
30
|
+
autoplayBehavior: attr(image, 'autoplay-behavior') || attr(image, 'data-autoplay-behavior') || _constants.AUTOPLAY_BEHAVIOR.SPIN_X,
|
|
27
31
|
playOnce: isTrue(image, 'play-once'),
|
|
28
|
-
disablePointerZoom: isTrue(image, 'disable-pointer-zoom'),
|
|
29
|
-
disablePinchZoom: isTrue(image, 'disable-pinch-zoom'),
|
|
30
|
-
onMouseLeave: attr(image, 'on-mouse-leave') || attr(image, 'data-on-mouse-leave'),
|
|
31
|
-
toStartPointerZoom: attr(image, 'to-start-pointer-zoom') || attr(image, 'data-to-start-pointer-zoom') || _ci.TO_START_POINTER_ZOOM.SCROLL_TO_START,
|
|
32
|
-
pointerZoomFactor: parseInt(attr(image, 'pointer-zoom-factor') || attr(image, 'data-pointer-zoom-factor') || 2, 10),
|
|
33
|
-
pinchZoomFactor: parseInt(attr(image, 'pinch-zoom-factor') || attr(image, 'data-pinch-zoom-factor') || 2, 10),
|
|
34
|
-
maxScale: parseFloat(attr(image, 'max-scale') || attr(image, 'data-max-scale') || 100, 10),
|
|
35
32
|
autoplayReverse: isTrue(image, 'autoplay-reverse'),
|
|
33
|
+
pointerZoom: parseFloat(attr(image, 'pointer-zoom') || attr(image, 'data-pointer-zoom') || 0, 10),
|
|
36
34
|
bottomCircle: isTrue(image, 'bottom-circle'),
|
|
37
35
|
disableDrag: isTrue(image, 'disable-drag'),
|
|
38
36
|
fullscreen: isTrue(image, 'fullscreen') || isTrue(image, 'full-screen'),
|
|
39
|
-
magnifier: (attr(image, 'magnifier') !== null || attr(image, 'data-magnifier') !== null) &&
|
|
40
|
-
magnifyInFullscreen: isTrue(image, 'magnify-in-fullscreen') || isTrue(image, 'magnifier-in-fullscreen'),
|
|
37
|
+
magnifier: (attr(image, 'magnifier') !== null || attr(image, 'data-magnifier') !== null) && parseFloat(attr(image, 'magnifier') || attr(image, 'data-magnifier'), 10),
|
|
41
38
|
bottomCircleOffset: parseInt(attr(image, 'bottom-circle-offset') || attr(image, 'data-bottom-circle-offset') || 5, 10),
|
|
42
|
-
|
|
43
|
-
responsive: isTrue(image, 'responsive'),
|
|
44
|
-
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive') || 'demo',
|
|
39
|
+
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive'),
|
|
45
40
|
ciFilters: attr(image, 'filters') || attr(image, 'data-filters'),
|
|
46
41
|
ciTransformation: attr(image, 'transformation') || attr(image, 'data-transformation'),
|
|
47
42
|
lazyload: isTrue(image, 'lazyload'),
|
|
@@ -50,217 +45,46 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
50
45
|
controlReverse: isTrue(image, 'control-reverse'),
|
|
51
46
|
stopAtEdges: isTrue(image, 'stop-at-edges'),
|
|
52
47
|
hide360Logo: isTrue(image, 'hide-360-logo'),
|
|
53
|
-
logoSrc: attr(image, 'logo-src') || 'https://scaleflex.
|
|
48
|
+
logoSrc: attr(image, 'logo-src') || 'https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/360_view.svg',
|
|
49
|
+
ratio: attr(image, 'ratio') || attr(image, 'data-ratio'),
|
|
50
|
+
imageInfo: attr(image, 'info') || attr(image, 'data-info') || isTrue(image, 'info')
|
|
54
51
|
};
|
|
55
52
|
};
|
|
56
53
|
|
|
54
|
+
exports.get360ViewProps = get360ViewProps;
|
|
55
|
+
|
|
57
56
|
var isTrue = function isTrue(image, type) {
|
|
58
57
|
var imgProp = attr(image, type);
|
|
59
|
-
var imgDataProp = attr(image,
|
|
60
|
-
|
|
58
|
+
var imgDataProp = attr(image, "data-".concat(type));
|
|
61
59
|
return imgProp !== null && imgProp !== 'false' || imgDataProp !== null && imgDataProp !== 'false';
|
|
62
60
|
};
|
|
63
61
|
|
|
62
|
+
exports.isTrue = isTrue;
|
|
63
|
+
|
|
64
64
|
var attr = function attr(element, attribute) {
|
|
65
65
|
return element.getAttribute(attribute);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
view360Icon.style.background = 'rgba(255,255,255,0.8) url(\'' + logoSrc + '\') 50% 50% / contain no-repeat';
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
var magnify = function magnify(container) {
|
|
73
|
-
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
74
|
-
var src = arguments[2];
|
|
75
|
-
var glass = arguments[3];
|
|
76
|
-
var zoom = arguments[4];
|
|
77
|
-
|
|
78
|
-
var w = void 0,
|
|
79
|
-
h = void 0,
|
|
80
|
-
bw = void 0;
|
|
81
|
-
var _offset$x = offset.x,
|
|
82
|
-
offsetX = _offset$x === undefined ? 0 : _offset$x,
|
|
83
|
-
_offset$y = offset.y,
|
|
84
|
-
offsetY = _offset$y === undefined ? 0 : _offset$y;
|
|
85
|
-
|
|
86
|
-
var backgroundSizeX = (container.offsetWidth - offsetX * 2) * zoom;
|
|
87
|
-
var backgroundSizeY = (container.offsetHeight - offsetY * 2) * zoom;
|
|
88
|
-
|
|
89
|
-
glass.setAttribute("class", "cloudimage-360-img-magnifier-glass");
|
|
90
|
-
container.prepend(glass);
|
|
91
|
-
|
|
92
|
-
glass.style.backgroundImage = "url('" + src + "')";
|
|
93
|
-
glass.style.backgroundSize = backgroundSizeX + 'px ' + backgroundSizeY + 'px';
|
|
94
|
-
|
|
95
|
-
bw = 3;
|
|
96
|
-
w = glass.offsetWidth / 2;
|
|
97
|
-
h = glass.offsetHeight / 2;
|
|
98
|
-
|
|
99
|
-
glass.addEventListener("mousemove", moveMagnifier);
|
|
100
|
-
container.addEventListener("mousemove", moveMagnifier);
|
|
101
|
-
|
|
102
|
-
glass.addEventListener("touchmove", moveMagnifier, { passive: true });
|
|
103
|
-
container.addEventListener("touchmove", moveMagnifier, { passive: true });
|
|
104
|
-
|
|
105
|
-
function moveMagnifier(e) {
|
|
106
|
-
var pos = void 0,
|
|
107
|
-
x = void 0,
|
|
108
|
-
y = void 0;
|
|
109
|
-
|
|
110
|
-
pos = getCursorPos(e);
|
|
111
|
-
x = pos.x;
|
|
112
|
-
y = pos.y;
|
|
113
|
-
|
|
114
|
-
if (x > container.offsetWidth - w / zoom) {
|
|
115
|
-
x = container.offsetWidth - w / zoom;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (x < w / zoom) {
|
|
119
|
-
x = w / zoom;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (y > container.offsetHeight - h / zoom) {
|
|
123
|
-
y = container.offsetHeight - h / zoom;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (y < h / zoom) {
|
|
127
|
-
y = h / zoom;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
glass.style.left = x - w + "px";
|
|
131
|
-
glass.style.top = y - h + "px";
|
|
132
|
-
|
|
133
|
-
var backgroundPosX = (x - offsetX) * zoom - w + bw;
|
|
134
|
-
|
|
135
|
-
var backgroundPosY = (y - offsetY) * zoom - h + bw;
|
|
136
|
-
|
|
137
|
-
glass.style.backgroundPosition = '-' + backgroundPosX + 'px -' + backgroundPosY + 'px';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function getCursorPos(e) {
|
|
141
|
-
var a = void 0,
|
|
142
|
-
x = 0,
|
|
143
|
-
y = 0;
|
|
144
|
-
e = e || window.event;
|
|
145
|
-
a = container.getBoundingClientRect();
|
|
146
|
-
x = e.pageX - a.left;
|
|
147
|
-
y = e.pageY - a.top;
|
|
148
|
-
x = x - window.pageXOffset;
|
|
149
|
-
y = y - window.pageYOffset;
|
|
150
|
-
|
|
151
|
-
return { x: x, y: y };
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
var getSizeLimit = function getSizeLimit(currentSize) {
|
|
156
|
-
if (currentSize <= 25) return '25';
|
|
157
|
-
if (currentSize <= 50) return '50';
|
|
68
|
+
exports.attr = attr;
|
|
158
69
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
var getSizeAccordingToPixelRatio = function getSizeAccordingToPixelRatio(size) {
|
|
163
|
-
var splittedSizes = size.toString().split('x');
|
|
164
|
-
var result = [];
|
|
165
|
-
|
|
166
|
-
[].forEach.call(splittedSizes, function (size) {
|
|
167
|
-
result.push(size * Math.round(window.devicePixelRatio || 1));
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
return result.join('x');
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
var getResponsiveWidthOfContainer = function getResponsiveWidthOfContainer(width) {
|
|
174
|
-
return getSizeLimit(width);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
var fit = function fit(contains) {
|
|
178
|
-
return function (parentWidth, parentHeight, childWidth, childHeight) {
|
|
179
|
-
var scale = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
|
180
|
-
var offsetX = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.5;
|
|
181
|
-
var offsetY = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0.5;
|
|
182
|
-
|
|
183
|
-
var childRatio = childWidth / childHeight;
|
|
184
|
-
var parentRatio = parentWidth / parentHeight;
|
|
185
|
-
var width = parentWidth * scale;
|
|
186
|
-
var height = parentHeight * scale;
|
|
187
|
-
|
|
188
|
-
if (contains ? childRatio > parentRatio : childRatio < parentRatio) {
|
|
189
|
-
height = width / childRatio;
|
|
190
|
-
} else {
|
|
191
|
-
width = height * childRatio;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
width: width,
|
|
196
|
-
height: height,
|
|
197
|
-
offsetX: (parentWidth - width) * offsetX,
|
|
198
|
-
offsetY: (parentHeight - height) * offsetY
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
var isTwoFingers = function isTwoFingers(event) {
|
|
204
|
-
return event.targetTouches.length === 2;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
var getMaxZoomIntensity = function getMaxZoomIntensity(width, maxScale) {
|
|
208
|
-
var maxWidth = maxScale * width;
|
|
209
|
-
var maxIntensity = maxWidth - width;
|
|
210
|
-
|
|
211
|
-
return maxIntensity;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
var normalizeZoomFactor = function normalizeZoomFactor(event, pointerZoomFactor) {
|
|
215
|
-
var scrollEvent = Math.abs(event.deltaY);
|
|
216
|
-
var zoomFactor = scrollEvent < 125 ? -pointerZoomFactor * 10 : -pointerZoomFactor;
|
|
217
|
-
|
|
218
|
-
return zoomFactor;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
var contain = fit(true);
|
|
222
|
-
|
|
223
|
-
var addClass = function addClass(el, className) {
|
|
224
|
-
if (el.classList) el.classList.add(className);else el.className += ' ' + className;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
var removeClass = function removeClass(el, className) {
|
|
228
|
-
if (el.classList) el.classList.remove(className);else el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
|
70
|
+
var setView360Icon = function setView360Icon(view360Icon, logoSrc) {
|
|
71
|
+
view360Icon.style.background = "rgba(255,255,255,0.8) url('".concat(logoSrc, "') 50% 50% / contain no-repeat");
|
|
229
72
|
};
|
|
230
73
|
|
|
231
|
-
|
|
232
|
-
var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
233
|
-
|
|
234
|
-
n = n + '';
|
|
235
|
-
|
|
236
|
-
return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n;
|
|
237
|
-
};
|
|
74
|
+
exports.setView360Icon = setView360Icon;
|
|
238
75
|
|
|
239
76
|
var debounce = function debounce(func, timeout) {
|
|
240
|
-
var timer
|
|
77
|
+
var timer;
|
|
241
78
|
return function () {
|
|
242
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
79
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
243
80
|
args[_key] = arguments[_key];
|
|
244
81
|
}
|
|
245
82
|
|
|
246
83
|
clearTimeout(timer);
|
|
247
|
-
|
|
248
84
|
timer = setTimeout(function () {
|
|
249
|
-
func.apply(
|
|
85
|
+
func.apply(_this, args);
|
|
250
86
|
}, timeout);
|
|
251
87
|
};
|
|
252
88
|
};
|
|
253
89
|
|
|
254
|
-
exports.get360ViewProps = get360ViewProps;
|
|
255
|
-
exports.setView360Icon = setView360Icon;
|
|
256
|
-
exports.magnify = magnify;
|
|
257
|
-
exports.getResponsiveWidthOfContainer = getResponsiveWidthOfContainer;
|
|
258
|
-
exports.getSizeAccordingToPixelRatio = getSizeAccordingToPixelRatio;
|
|
259
|
-
exports.contain = contain;
|
|
260
|
-
exports.addClass = addClass;
|
|
261
|
-
exports.removeClass = removeClass;
|
|
262
|
-
exports.pad = pad;
|
|
263
|
-
exports.isTwoFingers = isTwoFingers;
|
|
264
|
-
exports.getMaxZoomIntensity = getMaxZoomIntensity;
|
|
265
|
-
exports.normalizeZoomFactor = normalizeZoomFactor;
|
|
266
90
|
exports.debounce = debounce;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AUTOPLAY_BEHAVIOR = void 0;
|
|
7
|
+
var AUTOPLAY_BEHAVIOR = {
|
|
8
|
+
SPIN_X: 'spin-x',
|
|
9
|
+
SPIN_Y: 'spin-y',
|
|
10
|
+
SPIN_XY: 'spin-xy',
|
|
11
|
+
SPIN_YX: 'spin-yx'
|
|
12
|
+
};
|
|
13
|
+
exports.AUTOPLAY_BEHAVIOR = AUTOPLAY_BEHAVIOR;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AND_SYMBOL_REGEX", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _regex.AND_SYMBOL_REGEX;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "AUTOPLAY_BEHAVIOR", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _autoPlayBehavior.AUTOPLAY_BEHAVIOR;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "FALSY_VALUES", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _falsyValues.FALSY_VALUES;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "ORGINAL_SIZE_REGEX", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _regex.ORGINAL_SIZE_REGEX;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "ORIENTATIONS", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _orientations.ORIENTATIONS;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
var _autoPlayBehavior = require("./auto-play-behavior");
|
|
38
|
+
|
|
39
|
+
var _falsyValues = require("./falsy-values");
|
|
40
|
+
|
|
41
|
+
var _orientations = require("./orientations");
|
|
42
|
+
|
|
43
|
+
var _regex = require("./regex");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PROPS_REQUIRE_RELOAD = void 0;
|
|
7
|
+
var PROPS_REQUIRE_RELOAD = ['folder', //images source
|
|
8
|
+
'filenameX', //images source
|
|
9
|
+
'filenameY', //images source
|
|
10
|
+
'apiVersion', //images source
|
|
11
|
+
'imageListX', //images source
|
|
12
|
+
'imageListY', //images source
|
|
13
|
+
'indexZeroBase', //images source
|
|
14
|
+
'lazySelector', //images source
|
|
15
|
+
'keys', // events
|
|
16
|
+
'stopAtEdges', // events
|
|
17
|
+
'disableDrag', // events
|
|
18
|
+
'controlReverse', // events
|
|
19
|
+
'disableDrag' // events
|
|
20
|
+
];
|
|
21
|
+
exports.PROPS_REQUIRE_RELOAD = PROPS_REQUIRE_RELOAD;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ORGINAL_SIZE_REGEX = exports.AND_SYMBOL_REGEX = void 0;
|
|
7
|
+
var ORGINAL_SIZE_REGEX = /width=\d+|w=\d+|h=\d+|&width=\d+|&w=\d+|&h=\d+|func=\w+|\?$/g;
|
|
8
|
+
exports.ORGINAL_SIZE_REGEX = ORGINAL_SIZE_REGEX;
|
|
9
|
+
var AND_SYMBOL_REGEX = /\?&/g;
|
|
10
|
+
exports.AND_SYMBOL_REGEX = AND_SYMBOL_REGEX;
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
require(
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
require(
|
|
5
|
+
require("core-js/features/array/for-each");
|
|
6
6
|
|
|
7
|
-
require(
|
|
7
|
+
require("core-js/features/array/filter");
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
require("core-js/features/array/includes");
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _ci = _interopRequireDefault(require("./ci360.service"));
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
var _ci2 = require("./ci360.utils");
|
|
14
|
+
|
|
15
|
+
function getContainerWithId(container) {
|
|
16
|
+
var containerId = container.id;
|
|
17
|
+
|
|
18
|
+
if (!containerId) {
|
|
19
|
+
var uniqueId = Math.floor(Math.random() * 10000);
|
|
20
|
+
var generatedContainerId = "cloudimage-360-view-".concat(uniqueId);
|
|
21
|
+
container.id = generatedContainerId;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return container;
|
|
25
|
+
}
|
|
14
26
|
|
|
15
27
|
function init() {
|
|
16
28
|
var viewers = [];
|
|
17
29
|
var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
|
|
30
|
+
[].slice.call(view360Array).forEach(function (_container) {
|
|
31
|
+
var container = getContainerWithId(_container);
|
|
32
|
+
var isHotspotsEnabled = (0, _ci2.isTrue)(container, 'hotspots');
|
|
18
33
|
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
if (!isHotspotsEnabled) {
|
|
35
|
+
viewers.push(new _ci.default(container));
|
|
36
|
+
}
|
|
21
37
|
});
|
|
22
|
-
|
|
23
38
|
window.CI360._viewers = viewers;
|
|
24
39
|
}
|
|
25
40
|
|
|
@@ -33,24 +48,70 @@ function destroy() {
|
|
|
33
48
|
window.CI360._viewers = [];
|
|
34
49
|
}
|
|
35
50
|
|
|
36
|
-
function getActiveIndexByID(id) {
|
|
51
|
+
function getActiveIndexByID(id, oriantation) {
|
|
37
52
|
if (isNoViewers()) return;
|
|
38
53
|
|
|
39
54
|
var currentViewer = window.CI360._viewers.filter(function (viewer) {
|
|
40
55
|
return viewer.id === id;
|
|
41
56
|
})[0];
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
if (oriantation === 'y') {
|
|
59
|
+
return currentViewer && currentViewer.activeImageY - 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return currentViewer && currentViewer.activeImageX - 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function add(id) {
|
|
66
|
+
var view360Array = Array.from(document.querySelectorAll('.cloudimage-360:not(.initialized)'));
|
|
67
|
+
|
|
68
|
+
if (view360Array.length && id) {
|
|
69
|
+
var newViewContainer = view360Array.filter(function (viewer) {
|
|
70
|
+
return viewer.id === id;
|
|
71
|
+
})[0];
|
|
72
|
+
newViewContainer && window.CI360._viewers.push(new _ci.default(newViewContainer));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function update() {
|
|
77
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
78
|
+
var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
79
|
+
|
|
80
|
+
if (id) {
|
|
81
|
+
var view = window.CI360._viewers.filter(function (viewer) {
|
|
82
|
+
return viewer.id === id;
|
|
83
|
+
})[0];
|
|
84
|
+
|
|
85
|
+
view.updateView(forceUpdate, window.CI360._viewers);
|
|
86
|
+
} else {
|
|
87
|
+
window.CI360._viewers.forEach(function (viewer) {
|
|
88
|
+
viewer.updateView(forceUpdate, window.CI360._viewers);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
44
91
|
}
|
|
45
92
|
|
|
46
93
|
function isNoViewers() {
|
|
47
94
|
return !(window.CI360._viewers && window.CI360._viewers.length > 0);
|
|
48
95
|
}
|
|
49
96
|
|
|
97
|
+
function addHotspots(instanceId, config) {
|
|
98
|
+
var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
|
|
99
|
+
var container = Array.from(view360Array).find(function (view) {
|
|
100
|
+
return view.id === instanceId;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (container) {
|
|
104
|
+
window.CI360._viewers.push(new _ci.default(container, false, config));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
50
108
|
window.CI360 = window.CI360 || {};
|
|
51
109
|
window.CI360.init = init;
|
|
52
110
|
window.CI360.destroy = destroy;
|
|
53
111
|
window.CI360.getActiveIndexByID = getActiveIndexByID;
|
|
112
|
+
window.CI360.update = update;
|
|
113
|
+
window.CI360.add = add;
|
|
114
|
+
window.CI360.addHotspots = addHotspots;
|
|
54
115
|
|
|
55
116
|
if (!window.CI360.notInitOnLoad) {
|
|
56
117
|
init();
|