js-cloudimage-360-view 2.7.2-beta.3 → 2.7.2-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +2 -0
- package/dist/ci360.constants.js +8 -13
- package/dist/ci360.service.js +734 -1229
- package/dist/ci360.utils.js +17 -198
- package/dist/index.js +7 -11
- package/package.json +10 -8
package/dist/ci360.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,25 +25,18 @@ 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
|
-
ratio: parseFloat(attr(image, 'ratio') || attr(image, 'data-ratio') || 0) || false,
|
|
44
40
|
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive'),
|
|
45
41
|
ciFilters: attr(image, 'filters') || attr(image, 'data-filters'),
|
|
46
42
|
ciTransformation: attr(image, 'transformation') || attr(image, 'data-transformation'),
|
|
@@ -56,10 +52,11 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
56
52
|
};
|
|
57
53
|
};
|
|
58
54
|
|
|
55
|
+
exports.get360ViewProps = get360ViewProps;
|
|
56
|
+
|
|
59
57
|
var isTrue = function isTrue(image, type) {
|
|
60
58
|
var imgProp = attr(image, type);
|
|
61
|
-
var imgDataProp = attr(image,
|
|
62
|
-
|
|
59
|
+
var imgDataProp = attr(image, "data-".concat(type));
|
|
63
60
|
return imgProp !== null && imgProp !== 'false' || imgDataProp !== null && imgDataProp !== 'false';
|
|
64
61
|
};
|
|
65
62
|
|
|
@@ -68,201 +65,23 @@ var attr = function attr(element, attribute) {
|
|
|
68
65
|
};
|
|
69
66
|
|
|
70
67
|
var setView360Icon = function setView360Icon(view360Icon, logoSrc) {
|
|
71
|
-
view360Icon.style.background =
|
|
68
|
+
view360Icon.style.background = "rgba(255,255,255,0.8) url('".concat(logoSrc, "') 50% 50% / contain no-repeat");
|
|
72
69
|
};
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
76
|
-
var src = arguments[2];
|
|
77
|
-
var glass = arguments[3];
|
|
78
|
-
var zoom = arguments[4];
|
|
79
|
-
|
|
80
|
-
var w = void 0,
|
|
81
|
-
h = void 0,
|
|
82
|
-
bw = void 0;
|
|
83
|
-
var _offset$x = offset.x,
|
|
84
|
-
offsetX = _offset$x === undefined ? 0 : _offset$x,
|
|
85
|
-
_offset$y = offset.y,
|
|
86
|
-
offsetY = _offset$y === undefined ? 0 : _offset$y;
|
|
87
|
-
|
|
88
|
-
var backgroundSizeX = (container.offsetWidth - offsetX * 2) * zoom;
|
|
89
|
-
var backgroundSizeY = (container.offsetHeight - offsetY * 2) * zoom;
|
|
90
|
-
|
|
91
|
-
glass.setAttribute("class", "cloudimage-360-img-magnifier-glass");
|
|
92
|
-
container.prepend(glass);
|
|
93
|
-
|
|
94
|
-
glass.style.backgroundImage = "url('" + src + "')";
|
|
95
|
-
glass.style.backgroundSize = backgroundSizeX + 'px ' + backgroundSizeY + 'px';
|
|
96
|
-
|
|
97
|
-
bw = 3;
|
|
98
|
-
w = glass.offsetWidth / 2;
|
|
99
|
-
h = glass.offsetHeight / 2;
|
|
100
|
-
|
|
101
|
-
glass.addEventListener("mousemove", moveMagnifier);
|
|
102
|
-
container.addEventListener("mousemove", moveMagnifier);
|
|
103
|
-
|
|
104
|
-
glass.addEventListener("touchmove", moveMagnifier, { passive: true });
|
|
105
|
-
container.addEventListener("touchmove", moveMagnifier, { passive: true });
|
|
106
|
-
|
|
107
|
-
function moveMagnifier(e) {
|
|
108
|
-
var pos = void 0,
|
|
109
|
-
x = void 0,
|
|
110
|
-
y = void 0;
|
|
111
|
-
|
|
112
|
-
pos = getCursorPos(e);
|
|
113
|
-
x = pos.x;
|
|
114
|
-
y = pos.y;
|
|
115
|
-
|
|
116
|
-
if (x > container.offsetWidth - w / zoom) {
|
|
117
|
-
x = container.offsetWidth - w / zoom;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (x < w / zoom) {
|
|
121
|
-
x = w / zoom;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (y > container.offsetHeight - h / zoom) {
|
|
125
|
-
y = container.offsetHeight - h / zoom;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (y < h / zoom) {
|
|
129
|
-
y = h / zoom;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
glass.style.left = x - w + "px";
|
|
133
|
-
glass.style.top = y - h + "px";
|
|
134
|
-
|
|
135
|
-
var backgroundPosX = (x - offsetX) * zoom - w + bw;
|
|
136
|
-
|
|
137
|
-
var backgroundPosY = (y - offsetY) * zoom - h + bw;
|
|
138
|
-
|
|
139
|
-
glass.style.backgroundPosition = '-' + backgroundPosX + 'px -' + backgroundPosY + 'px';
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getCursorPos(e) {
|
|
143
|
-
var a = void 0,
|
|
144
|
-
x = 0,
|
|
145
|
-
y = 0;
|
|
146
|
-
e = e || window.event;
|
|
147
|
-
a = container.getBoundingClientRect();
|
|
148
|
-
x = e.pageX - a.left;
|
|
149
|
-
y = e.pageY - a.top;
|
|
150
|
-
x = x - window.pageXOffset;
|
|
151
|
-
y = y - window.pageYOffset;
|
|
152
|
-
|
|
153
|
-
return { x: x, y: y };
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
var getSizeLimit = function getSizeLimit(currentSize) {
|
|
158
|
-
if (currentSize <= 25) return '25';
|
|
159
|
-
if (currentSize <= 50) return '50';
|
|
160
|
-
|
|
161
|
-
return (Math.ceil(currentSize / 100) * 100).toString();
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
var getSizeAccordingToPixelRatio = function getSizeAccordingToPixelRatio(size) {
|
|
165
|
-
var splittedSizes = size.toString().split('x');
|
|
166
|
-
var result = [];
|
|
167
|
-
|
|
168
|
-
[].forEach.call(splittedSizes, function (size) {
|
|
169
|
-
result.push(size * Math.round(window.devicePixelRatio || 1));
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
return result.join('x');
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var getResponsiveWidthOfContainer = function getResponsiveWidthOfContainer(width) {
|
|
176
|
-
return getSizeLimit(width);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
var fit = function fit(contains) {
|
|
180
|
-
return function (parentWidth, parentHeight, childWidth, childHeight) {
|
|
181
|
-
var scale = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
|
182
|
-
var offsetX = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.5;
|
|
183
|
-
var offsetY = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0.5;
|
|
184
|
-
|
|
185
|
-
var childRatio = childWidth / childHeight;
|
|
186
|
-
var parentRatio = parentWidth / parentHeight;
|
|
187
|
-
var width = parentWidth * scale;
|
|
188
|
-
var height = parentHeight * scale;
|
|
189
|
-
|
|
190
|
-
if (contains ? childRatio > parentRatio : childRatio < parentRatio) {
|
|
191
|
-
height = width / childRatio;
|
|
192
|
-
} else {
|
|
193
|
-
width = height * childRatio;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
width: width,
|
|
198
|
-
height: height,
|
|
199
|
-
offsetX: (parentWidth - width) * offsetX,
|
|
200
|
-
offsetY: (parentHeight - height) * offsetY
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
var isTwoFingers = function isTwoFingers(event) {
|
|
206
|
-
return event.targetTouches.length === 2;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
var getMaxZoomIntensity = function getMaxZoomIntensity(width, maxScale) {
|
|
210
|
-
var maxWidth = maxScale * width;
|
|
211
|
-
var maxIntensity = maxWidth - width;
|
|
212
|
-
|
|
213
|
-
return maxIntensity;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
var normalizeZoomFactor = function normalizeZoomFactor(event, pointerZoomFactor) {
|
|
217
|
-
var scrollEvent = Math.abs(event.deltaY);
|
|
218
|
-
var zoomFactor = scrollEvent < 125 ? -pointerZoomFactor * 10 : -pointerZoomFactor;
|
|
219
|
-
|
|
220
|
-
return zoomFactor;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
var contain = fit(true);
|
|
224
|
-
|
|
225
|
-
var addClass = function addClass(el, className) {
|
|
226
|
-
if (el.classList) el.classList.add(className);else el.className += ' ' + className;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
var removeClass = function removeClass(el, className) {
|
|
230
|
-
if (el.classList) el.classList.remove(className);else el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
var pad = function pad(n) {
|
|
234
|
-
var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
235
|
-
|
|
236
|
-
n = n + '';
|
|
237
|
-
|
|
238
|
-
return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n;
|
|
239
|
-
};
|
|
71
|
+
exports.setView360Icon = setView360Icon;
|
|
240
72
|
|
|
241
73
|
var debounce = function debounce(func, timeout) {
|
|
242
|
-
var timer
|
|
74
|
+
var timer;
|
|
243
75
|
return function () {
|
|
244
|
-
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++) {
|
|
245
77
|
args[_key] = arguments[_key];
|
|
246
78
|
}
|
|
247
79
|
|
|
248
80
|
clearTimeout(timer);
|
|
249
|
-
|
|
250
81
|
timer = setTimeout(function () {
|
|
251
|
-
func.apply(
|
|
82
|
+
func.apply(_this, args);
|
|
252
83
|
}, timeout);
|
|
253
84
|
};
|
|
254
85
|
};
|
|
255
86
|
|
|
256
|
-
exports.get360ViewProps = get360ViewProps;
|
|
257
|
-
exports.setView360Icon = setView360Icon;
|
|
258
|
-
exports.magnify = magnify;
|
|
259
|
-
exports.getResponsiveWidthOfContainer = getResponsiveWidthOfContainer;
|
|
260
|
-
exports.getSizeAccordingToPixelRatio = getSizeAccordingToPixelRatio;
|
|
261
|
-
exports.contain = contain;
|
|
262
|
-
exports.addClass = addClass;
|
|
263
|
-
exports.removeClass = removeClass;
|
|
264
|
-
exports.pad = pad;
|
|
265
|
-
exports.isTwoFingers = isTwoFingers;
|
|
266
|
-
exports.getMaxZoomIntensity = getMaxZoomIntensity;
|
|
267
|
-
exports.normalizeZoomFactor = normalizeZoomFactor;
|
|
268
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.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "scaleflex",
|
|
@@ -33,25 +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-
|
|
42
|
-
"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",
|
|
43
45
|
"babel-plugin-array-includes": "^2.0.3",
|
|
44
46
|
"babel-preset-env": "^1.7.0",
|
|
45
47
|
"babel-preset-es2015": "^6.24.1",
|
|
46
48
|
"babel-preset-minify": "^0.5.0",
|
|
47
|
-
"babel-preset-stage-
|
|
49
|
+
"babel-preset-stage-0": "^6.24.1",
|
|
48
50
|
"css-loader": "^2.1.1",
|
|
49
51
|
"gh-pages": "^2.0.1",
|
|
50
52
|
"highlight.js": "^10.4.1",
|
|
51
53
|
"html-webpack-plugin": "^3.2.0",
|
|
52
54
|
"mobile-detect": "^1.4.3",
|
|
53
55
|
"style-loader": "^0.23.1",
|
|
54
|
-
"webpack": "^4.
|
|
56
|
+
"webpack": "^4.46.0",
|
|
55
57
|
"webpack-cli": "^3.3.0",
|
|
56
58
|
"webpack-dev-server": "^3.2.1"
|
|
57
59
|
}
|