js-cloudimage-360-view 2.7.1 → 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.
@@ -1,19 +1,23 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.debounce = exports.normalizeZoomFactor = exports.getMaxZoomIntensity = exports.isTwoFingers = exports.pad = exports.removeClass = exports.addClass = exports.contain = exports.getSizeAccordingToPixelRatio = exports.getResponsiveWidthOfContainer = exports.magnify = exports.setView360Icon = exports.get360ViewProps = undefined;
6
+ exports.setView360Icon = exports.get360ViewProps = exports.debounce = void 0;
7
7
 
8
- var _ci = require('./ci360.constants');
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) {
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
- imageList: attr(image, 'image-list') || attr(image, 'data-image-list') || null,
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),
@@ -21,27 +25,19 @@ var get360ViewProps = function get360ViewProps(image) {
21
25
  speed: parseInt(attr(image, 'speed') || attr(image, 'data-speed') || 80, 10),
22
26
  dragSpeed: parseInt(attr(image, 'drag-speed') || attr(image, 'data-drag-speed') || 150, 10),
23
27
  keys: isTrue(image, 'keys'),
28
+ keysReverse: isTrue(image, 'keys-reverse'),
24
29
  boxShadow: attr(image, 'box-shadow') || attr(image, 'data-box-shadow'),
25
30
  autoplay: isTrue(image, 'autoplay'),
26
31
  autoplayBehavior: attr(image, 'autoplay-behavior') || attr(image, 'data-autoplay-behavior') || _ci.AUTOPLAY_BEHAVIOR.SPIN_X,
27
32
  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.CLICK_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
33
  autoplayReverse: isTrue(image, 'autoplay-reverse'),
34
+ pointerZoom: parseFloat(attr(image, 'pointer-zoom') || attr(image, 'data-pointer-zoom') || 0, 10),
36
35
  bottomCircle: isTrue(image, 'bottom-circle'),
37
36
  disableDrag: isTrue(image, 'disable-drag'),
38
37
  fullscreen: isTrue(image, 'fullscreen') || isTrue(image, 'full-screen'),
39
38
  magnifier: (attr(image, 'magnifier') !== null || attr(image, 'data-magnifier') !== null) && parseInt(attr(image, 'magnifier') || attr(image, 'data-magnifier'), 10),
40
- magnifyInFullscreen: isTrue(image, 'magnify-in-fullscreen') || isTrue(image, 'magnifier-in-fullscreen'),
41
39
  bottomCircleOffset: parseInt(attr(image, 'bottom-circle-offset') || attr(image, 'data-bottom-circle-offset') || 5, 10),
42
- ratio: parseFloat(attr(image, 'ratio') || attr(image, 'data-ratio') || 0) || false,
43
- responsive: isTrue(image, 'responsive'),
44
- ciToken: attr(image, 'responsive') || attr(image, 'data-responsive') || 'demo',
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'),
47
43
  lazyload: isTrue(image, 'lazyload'),
@@ -50,14 +46,17 @@ var get360ViewProps = function get360ViewProps(image) {
50
46
  controlReverse: isTrue(image, 'control-reverse'),
51
47
  stopAtEdges: isTrue(image, 'stop-at-edges'),
52
48
  hide360Logo: isTrue(image, 'hide-360-logo'),
53
- 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
54
52
  };
55
53
  };
56
54
 
55
+ exports.get360ViewProps = get360ViewProps;
56
+
57
57
  var isTrue = function isTrue(image, type) {
58
58
  var imgProp = attr(image, type);
59
- var imgDataProp = attr(image, 'data-' + type);
60
-
59
+ var imgDataProp = attr(image, "data-".concat(type));
61
60
  return imgProp !== null && imgProp !== 'false' || imgDataProp !== null && imgDataProp !== 'false';
62
61
  };
63
62
 
@@ -66,201 +65,23 @@ var attr = function attr(element, attribute) {
66
65
  };
67
66
 
68
67
  var setView360Icon = function setView360Icon(view360Icon, logoSrc) {
69
- view360Icon.style.background = 'rgba(255,255,255,0.8) url(\'' + logoSrc + '\') 50% 50% / contain no-repeat';
68
+ view360Icon.style.background = "rgba(255,255,255,0.8) url('".concat(logoSrc, "') 50% 50% / contain no-repeat");
70
69
  };
71
70
 
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';
158
-
159
- return (Math.ceil(currentSize / 100) * 100).toString();
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'), ' ');
229
- };
230
-
231
- var pad = function pad(n) {
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
- };
71
+ exports.setView360Icon = setView360Icon;
238
72
 
239
73
  var debounce = function debounce(func, timeout) {
240
- var timer = void 0;
74
+ var timer;
241
75
  return function () {
242
- 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++) {
243
77
  args[_key] = arguments[_key];
244
78
  }
245
79
 
246
80
  clearTimeout(timer);
247
-
248
81
  timer = setTimeout(function () {
249
- func.apply(undefined, args);
82
+ func.apply(_this, args);
250
83
  }, timeout);
251
84
  };
252
85
  };
253
86
 
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
87
  exports.debounce = debounce;
package/dist/index.js CHANGED
@@ -1,25 +1,21 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- require('core-js/features/array/for-each');
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- require('core-js/features/array/filter');
5
+ require("core-js/features/array/for-each");
6
6
 
7
- require('core-js/features/array/includes');
7
+ require("core-js/features/array/filter");
8
8
 
9
- var _ci = require('./ci360.service');
9
+ require("core-js/features/array/includes");
10
10
 
11
- var _ci2 = _interopRequireDefault(_ci);
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 _ci2.default(container));
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.1",
3
+ "version": "2.7.2-beta.4",
4
4
  "main": "dist/index.js",
5
5
  "description": "",
6
6
  "author": "scaleflex",
@@ -23,34 +23,37 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "start-demo": "webpack-dev-server --mode development --config config/webpack-demo.config.js",
26
- "clean-build": "del build",
26
+ "clean-build": "rm -rf build",
27
27
  "build": "npm run clean-build && webpack --mode production --config config/webpack-build.config.js",
28
- "clean-dist": "del dist",
28
+ "clean-dist": "rm -rf dist",
29
29
  "dist": "npm run clean-dist && babel src -d dist --copy-files",
30
- "clean-demo": "del examples/dist",
30
+ "clean-demo": "rm -rf examples/dist",
31
31
  "build-demo": "npm run clean-demo && webpack --mode production --config config/webpack-demo.config.js",
32
32
  "deploy-demo": "gh-pages -d examples/dist",
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-cli": "^6.26.0",
40
- "babel-core": "^6.26.3",
41
- "babel-loader": "^7.1.4",
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-2": "^6.24.1",
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.29.6",
56
+ "webpack": "^4.46.0",
54
57
  "webpack-cli": "^3.3.0",
55
58
  "webpack-dev-server": "^3.2.1"
56
59
  }