js-cloudimage-360-view 2.7.2-beta.1 → 2.7.2-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +2 -0
- package/dist/ci360.constants.js +8 -13
- package/dist/ci360.service.js +752 -1203
- package/dist/ci360.utils.js +21 -201
- package/dist/index.js +7 -11
- package/package.json +10 -7
package/dist/ci360.utils.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.setView360Icon = exports.get360ViewProps = exports.debounce = void 0;
|
|
7
7
|
|
|
8
|
-
var _ci = require(
|
|
8
|
+
var _ci = require("./ci360.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) {
|
|
@@ -14,7 +16,8 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
14
16
|
apiVersion: attr(image, 'api-version') || attr(image, 'data-api-version') || attr(image, 'apiVersion') || attr(image, 'data-apiVersion') || "v7",
|
|
15
17
|
filenameX: attr(image, 'filename') || attr(image, 'data-filename') || attr(image, 'filename-x') || attr(image, 'data-filename-x') || 'image-{index}.jpg',
|
|
16
18
|
filenameY: attr(image, 'filename-y') || attr(image, 'data-filename-y') || 'image-y-{index}.jpg',
|
|
17
|
-
|
|
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,
|
|
18
21
|
indexZeroBase: parseInt(attr(image, 'index-zero-base') || attr(image, 'data-index-zero-base') || 0, 10),
|
|
19
22
|
amountX: parseInt(attr(image, 'amount') || attr(image, 'data-amount') || attr(image, 'amount-x') || attr(image, 'data-amount-x') || 36, 10),
|
|
20
23
|
amountY: parseInt(attr(image, 'amount-y') || attr(image, 'data-amount-y') || 0, 10),
|
|
@@ -22,27 +25,19 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
22
25
|
speed: parseInt(attr(image, 'speed') || attr(image, 'data-speed') || 80, 10),
|
|
23
26
|
dragSpeed: parseInt(attr(image, 'drag-speed') || attr(image, 'data-drag-speed') || 150, 10),
|
|
24
27
|
keys: isTrue(image, 'keys'),
|
|
28
|
+
keysReverse: isTrue(image, 'keys-reverse'),
|
|
25
29
|
boxShadow: attr(image, 'box-shadow') || attr(image, 'data-box-shadow'),
|
|
26
30
|
autoplay: isTrue(image, 'autoplay'),
|
|
27
31
|
autoplayBehavior: attr(image, 'autoplay-behavior') || attr(image, 'data-autoplay-behavior') || _ci.AUTOPLAY_BEHAVIOR.SPIN_X,
|
|
28
32
|
playOnce: isTrue(image, 'play-once'),
|
|
29
|
-
disablePointerZoom: isTrue(image, 'disable-pointer-zoom'),
|
|
30
|
-
disablePinchZoom: isTrue(image, 'disable-pinch-zoom'),
|
|
31
|
-
onMouseLeave: attr(image, 'on-mouse-leave') || attr(image, 'data-on-mouse-leave'),
|
|
32
|
-
toStartPointerZoom: attr(image, 'to-start-pointer-zoom') || attr(image, 'data-to-start-pointer-zoom') || _ci.TO_START_POINTER_ZOOM.CLICK_TO_START,
|
|
33
|
-
pointerZoomFactor: parseInt(attr(image, 'pointer-zoom-factor') || attr(image, 'data-pointer-zoom-factor') || 2, 10),
|
|
34
|
-
pinchZoomFactor: parseInt(attr(image, 'pinch-zoom-factor') || attr(image, 'data-pinch-zoom-factor') || 2, 10),
|
|
35
|
-
maxScale: parseFloat(attr(image, 'max-scale') || attr(image, 'data-max-scale') || 100, 10),
|
|
36
33
|
autoplayReverse: isTrue(image, 'autoplay-reverse'),
|
|
34
|
+
pointerZoom: parseFloat(attr(image, 'pointer-zoom') || attr(image, 'data-pointer-zoom') || 0, 10),
|
|
37
35
|
bottomCircle: isTrue(image, 'bottom-circle'),
|
|
38
36
|
disableDrag: isTrue(image, 'disable-drag'),
|
|
39
37
|
fullscreen: isTrue(image, 'fullscreen') || isTrue(image, 'full-screen'),
|
|
40
38
|
magnifier: (attr(image, 'magnifier') !== null || attr(image, 'data-magnifier') !== null) && parseInt(attr(image, 'magnifier') || attr(image, 'data-magnifier'), 10),
|
|
41
|
-
magnifyInFullscreen: isTrue(image, 'magnify-in-fullscreen') || isTrue(image, 'magnifier-in-fullscreen'),
|
|
42
39
|
bottomCircleOffset: parseInt(attr(image, 'bottom-circle-offset') || attr(image, 'data-bottom-circle-offset') || 5, 10),
|
|
43
|
-
|
|
44
|
-
responsive: isTrue(image, 'responsive'),
|
|
45
|
-
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive') || 'demo',
|
|
40
|
+
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive'),
|
|
46
41
|
ciFilters: attr(image, 'filters') || attr(image, 'data-filters'),
|
|
47
42
|
ciTransformation: attr(image, 'transformation') || attr(image, 'data-transformation'),
|
|
48
43
|
lazyload: isTrue(image, 'lazyload'),
|
|
@@ -51,14 +46,17 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
51
46
|
controlReverse: isTrue(image, 'control-reverse'),
|
|
52
47
|
stopAtEdges: isTrue(image, 'stop-at-edges'),
|
|
53
48
|
hide360Logo: isTrue(image, 'hide-360-logo'),
|
|
54
|
-
logoSrc: attr(image, 'logo-src') || 'https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg'
|
|
49
|
+
logoSrc: attr(image, 'logo-src') || 'https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg',
|
|
50
|
+
containerWidth: parseInt(attr(image, 'width') || attr(image, 'data-width'), 10) || 0,
|
|
51
|
+
containerHeight: parseInt(attr(image, 'height') || attr(image, 'data-height'), 10) || 0
|
|
55
52
|
};
|
|
56
53
|
};
|
|
57
54
|
|
|
55
|
+
exports.get360ViewProps = get360ViewProps;
|
|
56
|
+
|
|
58
57
|
var isTrue = function isTrue(image, type) {
|
|
59
58
|
var imgProp = attr(image, type);
|
|
60
|
-
var imgDataProp = attr(image,
|
|
61
|
-
|
|
59
|
+
var imgDataProp = attr(image, "data-".concat(type));
|
|
62
60
|
return imgProp !== null && imgProp !== 'false' || imgDataProp !== null && imgDataProp !== 'false';
|
|
63
61
|
};
|
|
64
62
|
|
|
@@ -67,201 +65,23 @@ var attr = function attr(element, attribute) {
|
|
|
67
65
|
};
|
|
68
66
|
|
|
69
67
|
var setView360Icon = function setView360Icon(view360Icon, logoSrc) {
|
|
70
|
-
view360Icon.style.background =
|
|
68
|
+
view360Icon.style.background = "rgba(255,255,255,0.8) url('".concat(logoSrc, "') 50% 50% / contain no-repeat");
|
|
71
69
|
};
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
75
|
-
var src = arguments[2];
|
|
76
|
-
var glass = arguments[3];
|
|
77
|
-
var zoom = arguments[4];
|
|
78
|
-
|
|
79
|
-
var w = void 0,
|
|
80
|
-
h = void 0,
|
|
81
|
-
bw = void 0;
|
|
82
|
-
var _offset$x = offset.x,
|
|
83
|
-
offsetX = _offset$x === undefined ? 0 : _offset$x,
|
|
84
|
-
_offset$y = offset.y,
|
|
85
|
-
offsetY = _offset$y === undefined ? 0 : _offset$y;
|
|
86
|
-
|
|
87
|
-
var backgroundSizeX = (container.offsetWidth - offsetX * 2) * zoom;
|
|
88
|
-
var backgroundSizeY = (container.offsetHeight - offsetY * 2) * zoom;
|
|
89
|
-
|
|
90
|
-
glass.setAttribute("class", "cloudimage-360-img-magnifier-glass");
|
|
91
|
-
container.prepend(glass);
|
|
92
|
-
|
|
93
|
-
glass.style.backgroundImage = "url('" + src + "')";
|
|
94
|
-
glass.style.backgroundSize = backgroundSizeX + 'px ' + backgroundSizeY + 'px';
|
|
95
|
-
|
|
96
|
-
bw = 3;
|
|
97
|
-
w = glass.offsetWidth / 2;
|
|
98
|
-
h = glass.offsetHeight / 2;
|
|
99
|
-
|
|
100
|
-
glass.addEventListener("mousemove", moveMagnifier);
|
|
101
|
-
container.addEventListener("mousemove", moveMagnifier);
|
|
102
|
-
|
|
103
|
-
glass.addEventListener("touchmove", moveMagnifier, { passive: true });
|
|
104
|
-
container.addEventListener("touchmove", moveMagnifier, { passive: true });
|
|
105
|
-
|
|
106
|
-
function moveMagnifier(e) {
|
|
107
|
-
var pos = void 0,
|
|
108
|
-
x = void 0,
|
|
109
|
-
y = void 0;
|
|
110
|
-
|
|
111
|
-
pos = getCursorPos(e);
|
|
112
|
-
x = pos.x;
|
|
113
|
-
y = pos.y;
|
|
114
|
-
|
|
115
|
-
if (x > container.offsetWidth - w / zoom) {
|
|
116
|
-
x = container.offsetWidth - w / zoom;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (x < w / zoom) {
|
|
120
|
-
x = w / zoom;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (y > container.offsetHeight - h / zoom) {
|
|
124
|
-
y = container.offsetHeight - h / zoom;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (y < h / zoom) {
|
|
128
|
-
y = h / zoom;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
glass.style.left = x - w + "px";
|
|
132
|
-
glass.style.top = y - h + "px";
|
|
133
|
-
|
|
134
|
-
var backgroundPosX = (x - offsetX) * zoom - w + bw;
|
|
135
|
-
|
|
136
|
-
var backgroundPosY = (y - offsetY) * zoom - h + bw;
|
|
137
|
-
|
|
138
|
-
glass.style.backgroundPosition = '-' + backgroundPosX + 'px -' + backgroundPosY + 'px';
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function getCursorPos(e) {
|
|
142
|
-
var a = void 0,
|
|
143
|
-
x = 0,
|
|
144
|
-
y = 0;
|
|
145
|
-
e = e || window.event;
|
|
146
|
-
a = container.getBoundingClientRect();
|
|
147
|
-
x = e.pageX - a.left;
|
|
148
|
-
y = e.pageY - a.top;
|
|
149
|
-
x = x - window.pageXOffset;
|
|
150
|
-
y = y - window.pageYOffset;
|
|
151
|
-
|
|
152
|
-
return { x: x, y: y };
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
var getSizeLimit = function getSizeLimit(currentSize) {
|
|
157
|
-
if (currentSize <= 25) return '25';
|
|
158
|
-
if (currentSize <= 50) return '50';
|
|
159
|
-
|
|
160
|
-
return (Math.ceil(currentSize / 100) * 100).toString();
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
var getSizeAccordingToPixelRatio = function getSizeAccordingToPixelRatio(size) {
|
|
164
|
-
var splittedSizes = size.toString().split('x');
|
|
165
|
-
var result = [];
|
|
166
|
-
|
|
167
|
-
[].forEach.call(splittedSizes, function (size) {
|
|
168
|
-
result.push(size * Math.round(window.devicePixelRatio || 1));
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return result.join('x');
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
var getResponsiveWidthOfContainer = function getResponsiveWidthOfContainer(width) {
|
|
175
|
-
return getSizeLimit(width);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
var fit = function fit(contains) {
|
|
179
|
-
return function (parentWidth, parentHeight, childWidth, childHeight) {
|
|
180
|
-
var scale = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
|
181
|
-
var offsetX = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.5;
|
|
182
|
-
var offsetY = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0.5;
|
|
183
|
-
|
|
184
|
-
var childRatio = childWidth / childHeight;
|
|
185
|
-
var parentRatio = parentWidth / parentHeight;
|
|
186
|
-
var width = parentWidth * scale;
|
|
187
|
-
var height = parentHeight * scale;
|
|
188
|
-
|
|
189
|
-
if (contains ? childRatio > parentRatio : childRatio < parentRatio) {
|
|
190
|
-
height = width / childRatio;
|
|
191
|
-
} else {
|
|
192
|
-
width = height * childRatio;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return {
|
|
196
|
-
width: width,
|
|
197
|
-
height: height,
|
|
198
|
-
offsetX: (parentWidth - width) * offsetX,
|
|
199
|
-
offsetY: (parentHeight - height) * offsetY
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
var isTwoFingers = function isTwoFingers(event) {
|
|
205
|
-
return event.targetTouches.length === 2;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
var getMaxZoomIntensity = function getMaxZoomIntensity(width, maxScale) {
|
|
209
|
-
var maxWidth = maxScale * width;
|
|
210
|
-
var maxIntensity = maxWidth - width;
|
|
211
|
-
|
|
212
|
-
return maxIntensity;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
var normalizeZoomFactor = function normalizeZoomFactor(event, pointerZoomFactor) {
|
|
216
|
-
var scrollEvent = Math.abs(event.deltaY);
|
|
217
|
-
var zoomFactor = scrollEvent < 125 ? -pointerZoomFactor * 10 : -pointerZoomFactor;
|
|
218
|
-
|
|
219
|
-
return zoomFactor;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
var contain = fit(true);
|
|
223
|
-
|
|
224
|
-
var addClass = function addClass(el, className) {
|
|
225
|
-
if (el.classList) el.classList.add(className);else el.className += ' ' + className;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
var removeClass = function removeClass(el, className) {
|
|
229
|
-
if (el.classList) el.classList.remove(className);else el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
var pad = function pad(n) {
|
|
233
|
-
var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
234
|
-
|
|
235
|
-
n = n + '';
|
|
236
|
-
|
|
237
|
-
return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n;
|
|
238
|
-
};
|
|
71
|
+
exports.setView360Icon = setView360Icon;
|
|
239
72
|
|
|
240
73
|
var debounce = function debounce(func, timeout) {
|
|
241
|
-
var timer
|
|
74
|
+
var timer;
|
|
242
75
|
return function () {
|
|
243
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
76
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
244
77
|
args[_key] = arguments[_key];
|
|
245
78
|
}
|
|
246
79
|
|
|
247
80
|
clearTimeout(timer);
|
|
248
|
-
|
|
249
81
|
timer = setTimeout(function () {
|
|
250
|
-
func.apply(
|
|
82
|
+
func.apply(_this, args);
|
|
251
83
|
}, timeout);
|
|
252
84
|
};
|
|
253
85
|
};
|
|
254
86
|
|
|
255
|
-
exports.get360ViewProps = get360ViewProps;
|
|
256
|
-
exports.setView360Icon = setView360Icon;
|
|
257
|
-
exports.magnify = magnify;
|
|
258
|
-
exports.getResponsiveWidthOfContainer = getResponsiveWidthOfContainer;
|
|
259
|
-
exports.getSizeAccordingToPixelRatio = getSizeAccordingToPixelRatio;
|
|
260
|
-
exports.contain = contain;
|
|
261
|
-
exports.addClass = addClass;
|
|
262
|
-
exports.removeClass = removeClass;
|
|
263
|
-
exports.pad = pad;
|
|
264
|
-
exports.isTwoFingers = isTwoFingers;
|
|
265
|
-
exports.getMaxZoomIntensity = getMaxZoomIntensity;
|
|
266
|
-
exports.normalizeZoomFactor = normalizeZoomFactor;
|
|
267
87
|
exports.debounce = debounce;
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
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
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
var _ci = _interopRequireDefault(require("./ci360.service"));
|
|
14
12
|
|
|
15
13
|
function init() {
|
|
16
14
|
var viewers = [];
|
|
17
15
|
var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
|
|
18
|
-
|
|
19
16
|
[].slice.call(view360Array).forEach(function (container) {
|
|
20
|
-
viewers.push(new
|
|
17
|
+
viewers.push(new _ci.default(container));
|
|
21
18
|
});
|
|
22
|
-
|
|
23
19
|
window.CI360._viewers = viewers;
|
|
24
20
|
}
|
|
25
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-cloudimage-360-view",
|
|
3
|
-
"version": "2.7.2-beta.
|
|
3
|
+
"version": "2.7.2-beta.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "scaleflex",
|
|
@@ -33,24 +33,27 @@
|
|
|
33
33
|
"publish-demo": "npm run build-demo && npm run deploy-demo"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"core-js": "^3.0.0"
|
|
36
|
+
"core-js": "^3.0.0",
|
|
37
|
+
"js-cloudimage-360-view-utils": "^1.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"babel
|
|
40
|
-
"babel
|
|
41
|
-
"babel-
|
|
40
|
+
"@babel/cli": "^7.16.7",
|
|
41
|
+
"@babel/core": "^7.16.7",
|
|
42
|
+
"@babel/plugin-transform-runtime": "^7.16.5",
|
|
43
|
+
"@babel/preset-env": "^7.16.5",
|
|
44
|
+
"babel-loader": "^8.2.3",
|
|
42
45
|
"babel-plugin-array-includes": "^2.0.3",
|
|
43
46
|
"babel-preset-env": "^1.7.0",
|
|
44
47
|
"babel-preset-es2015": "^6.24.1",
|
|
45
48
|
"babel-preset-minify": "^0.5.0",
|
|
46
|
-
"babel-preset-stage-
|
|
49
|
+
"babel-preset-stage-0": "^6.24.1",
|
|
47
50
|
"css-loader": "^2.1.1",
|
|
48
51
|
"gh-pages": "^2.0.1",
|
|
49
52
|
"highlight.js": "^10.4.1",
|
|
50
53
|
"html-webpack-plugin": "^3.2.0",
|
|
51
54
|
"mobile-detect": "^1.4.3",
|
|
52
55
|
"style-loader": "^0.23.1",
|
|
53
|
-
"webpack": "^4.
|
|
56
|
+
"webpack": "^4.46.0",
|
|
54
57
|
"webpack-cli": "^3.3.0",
|
|
55
58
|
"webpack-dev-server": "^3.2.1"
|
|
56
59
|
}
|