js-cloudimage-360-view 2.7.4 → 2.7.5
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 +8 -0
- package/README.md +46 -4
- package/dist/ci360.service.js +42 -8
- package/dist/ci360.utils.js +1 -2
- package/dist/constants/image-src-props.js +8 -0
- package/dist/index.js +22 -0
- package/dist/utils/image-src/is-src-props-changed.js +23 -0
- package/dist/utils/index.js +11 -2
- package/dist/utils/spin-y/get-moving-direction.js +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -25,6 +25,14 @@ Types of changes:
|
|
|
25
25
|
- ...
|
|
26
26
|
|
|
27
27
|
-------------
|
|
28
|
+
## 2.7.5 - 2022-01-08
|
|
29
|
+
### Added
|
|
30
|
+
- update method to re-render or re-init the plugin
|
|
31
|
+
### Fixed
|
|
32
|
+
- drag speed on mobile
|
|
33
|
+
- error when drag speed is too high
|
|
34
|
+
- error in dependencies
|
|
35
|
+
|
|
28
36
|
## 2.7.4 - 2022-01-26
|
|
29
37
|
### Fixed
|
|
30
38
|
- typo in documentation file
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://github.com/scaleflex/js-cloudimage-360-view/releases)
|
|
2
2
|
[](#contributing)
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
4
|
[](https://www.scaleflex.it/en/home)
|
|
@@ -6,11 +6,16 @@
|
|
|
6
6
|
[](https://twitter.com/intent/tweet?text=Engage%20your%20customers%20with%20a%20stunning%20360%20viewvof%20your%20products&url=https://scaleflex.github.io/js-cloudimage-360-view/&via=cloudimage&hashtags=images,cloudimage)
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<a href="https://www.cloudimage.io
|
|
9
|
+
<a href="https://www.cloudimage.io/#gh-light-mode-only">
|
|
10
10
|
<img
|
|
11
11
|
alt="The Lounge"
|
|
12
12
|
src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
|
|
13
13
|
</a>
|
|
14
|
+
<a href="https://www.cloudimage.io/#gh-dark-mode-only">
|
|
15
|
+
<img
|
|
16
|
+
alt="The Lounge"
|
|
17
|
+
src="https://scaleflex.cloudimg.io/v7/cloudimage.io/cloudimage-logo-light.png?vh=b798ab&w=350">
|
|
18
|
+
</a>
|
|
14
19
|
</p>
|
|
15
20
|
|
|
16
21
|
<h1 align="center">
|
|
@@ -70,7 +75,7 @@ To see the Cloudimage 360 view plugin in action, please check out the
|
|
|
70
75
|
Add script tag with CDN link to js-cloudimage-360-view lib after all content in body tag
|
|
71
76
|
|
|
72
77
|
```javascript
|
|
73
|
-
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2.7.
|
|
78
|
+
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2.7.5/js-cloudimage-360-view.min.js"></script>
|
|
74
79
|
```
|
|
75
80
|
|
|
76
81
|
## <a name="initialize"></a>Step 2: Initialize
|
|
@@ -107,6 +112,36 @@ window.CI360.init();
|
|
|
107
112
|
> <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2/js-cloudimage-360-view.min.js"></script>
|
|
108
113
|
> <script>window.CI360.init(); // initialize the plugin when you need</script>
|
|
109
114
|
> ```
|
|
115
|
+
### update
|
|
116
|
+
|
|
117
|
+
###### Type: **Function**
|
|
118
|
+
```javascript
|
|
119
|
+
window.CI360.update(idOfInstance, forceUpdate);
|
|
120
|
+
```
|
|
121
|
+
Update cloudimage 360 viewer instance.<br/>
|
|
122
|
+
For any update in source attributes after plugin initialization (e.g. `data-folder`, `data-filename-x`, `data-amount-y`),
|
|
123
|
+
the plugin will re-init.
|
|
124
|
+
### Properties
|
|
125
|
+
#### `idOfInstance`: string
|
|
126
|
+
The id of the instance
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<div
|
|
130
|
+
id="cloudimage-360-car"
|
|
131
|
+
class="cloudimage-360"
|
|
132
|
+
data-folder="https://scaleflex.airstore.io/demo/360-car/"
|
|
133
|
+
data-filename-x="iris-{index}.jpeg"
|
|
134
|
+
data-amount-x="36"
|
|
135
|
+
></div>
|
|
136
|
+
```
|
|
137
|
+
```javascript
|
|
138
|
+
window.CI360.update('cloudimage-360-car');
|
|
139
|
+
```
|
|
140
|
+
#### `forceUpdate`: bool
|
|
141
|
+
Force the plugin to re-init.
|
|
142
|
+
```javascript
|
|
143
|
+
window.CI360.update(null, true);
|
|
144
|
+
```
|
|
110
145
|
|
|
111
146
|
### destroy
|
|
112
147
|
|
|
@@ -127,8 +162,15 @@ window.CI360.destroy();
|
|
|
127
162
|
Get the {index} of the image that is being viewed.
|
|
128
163
|
|
|
129
164
|
```javascript
|
|
130
|
-
window.CI360.getActiveIndexByID(
|
|
165
|
+
window.CI360.getActiveIndexByID(idOfInstance: string, oriantation: string);
|
|
131
166
|
```
|
|
167
|
+
### Properties
|
|
168
|
+
#### `idOfInstance`: string
|
|
169
|
+
The id of the instance
|
|
170
|
+
|
|
171
|
+
#### `oriantation`: string
|
|
172
|
+
The oriantation of the active index
|
|
173
|
+
|
|
132
174
|
## <a name="customize-elements"></a> Customize elements
|
|
133
175
|
|
|
134
176
|
You can customize elements by adding the following classes:
|
package/dist/ci360.service.js
CHANGED
|
@@ -175,6 +175,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
175
175
|
if (this.pointerZoom && this.mouseTracked) {
|
|
176
176
|
this.togglePointerZoom();
|
|
177
177
|
}
|
|
178
|
+
|
|
179
|
+
if (this.isMagnifyOpen) {
|
|
180
|
+
this.closeMagnifier();
|
|
181
|
+
}
|
|
178
182
|
}
|
|
179
183
|
}, {
|
|
180
184
|
key: "togglePointerZoom",
|
|
@@ -302,11 +306,16 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
302
306
|
key: "touchMove",
|
|
303
307
|
value: function touchMove(event) {
|
|
304
308
|
if (!this.isClicked || !this.imagesLoaded) return;
|
|
309
|
+
|
|
310
|
+
if (event.cancelable) {
|
|
311
|
+
event.preventDefault();
|
|
312
|
+
}
|
|
313
|
+
|
|
305
314
|
var nextPositions = {
|
|
306
315
|
x: event.touches[0].clientX,
|
|
307
316
|
y: event.touches[0].clientY
|
|
308
317
|
};
|
|
309
|
-
this.movingDirection = (0, _utils.getMovingDirection)(this.isStartSpin, this.allowSpinY, this.intialPositions, nextPositions);
|
|
318
|
+
this.movingDirection = (0, _utils.getMovingDirection)(this.isStartSpin, this.allowSpinY, this.intialPositions, nextPositions, this.movingDirection);
|
|
310
319
|
this.onMoveHandler(event);
|
|
311
320
|
}
|
|
312
321
|
}, {
|
|
@@ -927,6 +936,21 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
927
936
|
if (this.bottomCircle) this.show360ViewCircleIcon();
|
|
928
937
|
window.clearTimeout(this.loopTimeoutId);
|
|
929
938
|
}
|
|
939
|
+
}, {
|
|
940
|
+
key: "updatePlugin",
|
|
941
|
+
value: function updatePlugin(forceUpdate) {
|
|
942
|
+
var container = this.container;
|
|
943
|
+
var imageProps = (0, _ci.get360ViewProps)(container);
|
|
944
|
+
var srcPropsChanged = (0, _utils.isSrcPropsChanged)(this, imageProps);
|
|
945
|
+
var reloadPlugin = srcPropsChanged || forceUpdate;
|
|
946
|
+
container.style.position = 'relative';
|
|
947
|
+
container.style.width = '100%';
|
|
948
|
+
container.style.cursor = 'default';
|
|
949
|
+
container.setAttribute('draggable', 'false');
|
|
950
|
+
if (reloadPlugin) container.innerHTML = '';
|
|
951
|
+
this.stop();
|
|
952
|
+
this.init(container, !reloadPlugin, reloadPlugin);
|
|
953
|
+
}
|
|
930
954
|
}, {
|
|
931
955
|
key: "destroy",
|
|
932
956
|
value: function destroy() {
|
|
@@ -1133,9 +1157,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1133
1157
|
passive: true
|
|
1134
1158
|
});
|
|
1135
1159
|
this.container.addEventListener('touchend', this.touchEnd.bind(this));
|
|
1136
|
-
this.container.addEventListener('touchmove', this.touchMove.bind(this)
|
|
1137
|
-
passive: true
|
|
1138
|
-
});
|
|
1160
|
+
this.container.addEventListener('touchmove', this.touchMove.bind(this));
|
|
1139
1161
|
}
|
|
1140
1162
|
|
|
1141
1163
|
if (keys) {
|
|
@@ -1150,6 +1172,9 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1150
1172
|
value: function init(container) {
|
|
1151
1173
|
var _this6 = this;
|
|
1152
1174
|
|
|
1175
|
+
var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1176
|
+
var reload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1177
|
+
|
|
1153
1178
|
var _get360ViewProps = (0, _ci.get360ViewProps)(container),
|
|
1154
1179
|
folder = _get360ViewProps.folder,
|
|
1155
1180
|
apiVersion = _get360ViewProps.apiVersion,
|
|
@@ -1160,7 +1185,6 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1160
1185
|
indexZeroBase = _get360ViewProps.indexZeroBase,
|
|
1161
1186
|
amountX = _get360ViewProps.amountX,
|
|
1162
1187
|
amountY = _get360ViewProps.amountY,
|
|
1163
|
-
imageOffset = _get360ViewProps.imageOffset,
|
|
1164
1188
|
_get360ViewProps$drag = _get360ViewProps.draggable,
|
|
1165
1189
|
draggable = _get360ViewProps$drag === void 0 ? true : _get360ViewProps$drag,
|
|
1166
1190
|
_get360ViewProps$swip = _get360ViewProps.swipeable,
|
|
@@ -1212,7 +1236,6 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1212
1236
|
this.activeImageX = autoplayReverse ? this.amountX : 1;
|
|
1213
1237
|
this.activeImageY = autoplayReverse ? this.amountY : 1;
|
|
1214
1238
|
this.spinY = autoplayBehavior === _constants.AUTOPLAY_BEHAVIOR.SPIN_YX ? true : false;
|
|
1215
|
-
this.imageOffset = imageOffset;
|
|
1216
1239
|
this.bottomCircle = bottomCircle;
|
|
1217
1240
|
this.bottomCircleOffset = bottomCircleOffset;
|
|
1218
1241
|
this.boxShadow = boxShadow;
|
|
@@ -1223,13 +1246,13 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1223
1246
|
this.reversed = autoplayReverse;
|
|
1224
1247
|
this.disableDrag = disableDrag;
|
|
1225
1248
|
this.fullscreen = fullscreen;
|
|
1226
|
-
this.magnifier = !this.isMobile && magnifier ? magnifier :
|
|
1249
|
+
this.magnifier = !this.isMobile && magnifier > 1 ? Math.min(magnifier, 5) : 0;
|
|
1227
1250
|
this.lazyloadX = lazyload;
|
|
1228
1251
|
this.lazyloadY = lazyload;
|
|
1229
1252
|
this.lazySelector = lazySelector;
|
|
1230
1253
|
this.spinReverse = spinReverse;
|
|
1231
1254
|
this.controlReverse = controlReverse;
|
|
1232
|
-
this.dragSpeed =
|
|
1255
|
+
this.dragSpeed = Math.max(magnifier, 50);
|
|
1233
1256
|
this.autoplaySpeed = this.speed * 36 / this.amountX;
|
|
1234
1257
|
this.stopAtEdges = stopAtEdges;
|
|
1235
1258
|
this.hide360Logo = hide360Logo;
|
|
@@ -1240,6 +1263,17 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1240
1263
|
this.containerHeight = containerHeight;
|
|
1241
1264
|
this.pointerZoom = pointerZoom > 1 ? Math.min(pointerZoom, 3) : 0;
|
|
1242
1265
|
this.keysReverse = keysReverse;
|
|
1266
|
+
|
|
1267
|
+
if (reload) {
|
|
1268
|
+
new CI360Viewer(this.container);
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
if (update) {
|
|
1273
|
+
this.onAllImagesLoaded();
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1243
1277
|
this.innerBox = (0, _utils.createInnerBox)(this.container);
|
|
1244
1278
|
this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
|
|
1245
1279
|
this.canvas = (0, _utils.createCanvas)(this.innerBox);
|
package/dist/ci360.utils.js
CHANGED
|
@@ -21,7 +21,6 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
21
21
|
indexZeroBase: parseInt(attr(image, 'index-zero-base') || attr(image, 'data-index-zero-base') || 0, 10),
|
|
22
22
|
amountX: parseInt(attr(image, 'amount') || attr(image, 'data-amount') || attr(image, 'amount-x') || attr(image, 'data-amount-x') || 36, 10),
|
|
23
23
|
amountY: parseInt(attr(image, 'amount-y') || attr(image, 'data-amount-y') || 0, 10),
|
|
24
|
-
imageOffset: parseInt(attr(image, 'image-offset') || attr(image, 'data-image-offset')),
|
|
25
24
|
speed: parseInt(attr(image, 'speed') || attr(image, 'data-speed') || 80, 10),
|
|
26
25
|
dragSpeed: parseInt(attr(image, 'drag-speed') || attr(image, 'data-drag-speed') || 150, 10),
|
|
27
26
|
keys: isTrue(image, 'keys'),
|
|
@@ -35,7 +34,7 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
35
34
|
bottomCircle: isTrue(image, 'bottom-circle'),
|
|
36
35
|
disableDrag: isTrue(image, 'disable-drag'),
|
|
37
36
|
fullscreen: isTrue(image, 'fullscreen') || isTrue(image, 'full-screen'),
|
|
38
|
-
magnifier: (attr(image, 'magnifier') !== null || attr(image, 'data-magnifier') !== null) &&
|
|
37
|
+
magnifier: (attr(image, 'magnifier') !== null || attr(image, 'data-magnifier') !== null) && parseFloat(attr(image, 'magnifier') || attr(image, 'data-magnifier'), 10),
|
|
39
38
|
bottomCircleOffset: parseInt(attr(image, 'bottom-circle-offset') || attr(image, 'data-bottom-circle-offset') || 5, 10),
|
|
40
39
|
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive'),
|
|
41
40
|
ciFilters: attr(image, 'filters') || attr(image, 'data-filters'),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IMAGE_SRC_PROPS = void 0;
|
|
7
|
+
var IMAGE_SRC_PROPS = ['folder', 'filenameX', 'filenameY', 'apiVersion', 'imageListX', 'imageListY', 'indexZeroBase', 'amountX', 'amountY', 'lazySelector'];
|
|
8
|
+
exports.IMAGE_SRC_PROPS = IMAGE_SRC_PROPS;
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,27 @@ function getActiveIndexByID(id, oriantation) {
|
|
|
43
43
|
return currentViewer && currentViewer.activeImageX - 1;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function update() {
|
|
47
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
48
|
+
var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
49
|
+
|
|
50
|
+
if (id) {
|
|
51
|
+
try {
|
|
52
|
+
var view = window.CI360._viewers.filter(function (viewer) {
|
|
53
|
+
return viewer.id === id;
|
|
54
|
+
})[0];
|
|
55
|
+
|
|
56
|
+
return view.updatePlugin(forceUpdate);
|
|
57
|
+
} catch (_unused) {
|
|
58
|
+
console.error("Cloudimage-360: there is no view with such id '".concat(id, "'"));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return window.CI360._viewers.forEach(function (viewer) {
|
|
63
|
+
viewer.updatePlugin(forceUpdate);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
46
67
|
function isNoViewers() {
|
|
47
68
|
return !(window.CI360._viewers && window.CI360._viewers.length > 0);
|
|
48
69
|
}
|
|
@@ -51,6 +72,7 @@ window.CI360 = window.CI360 || {};
|
|
|
51
72
|
window.CI360.init = init;
|
|
52
73
|
window.CI360.destroy = destroy;
|
|
53
74
|
window.CI360.getActiveIndexByID = getActiveIndexByID;
|
|
75
|
+
window.CI360.update = update;
|
|
54
76
|
|
|
55
77
|
if (!window.CI360.notInitOnLoad) {
|
|
56
78
|
init();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isSrcPropsChanged = void 0;
|
|
7
|
+
|
|
8
|
+
var _imageSrcProps = require("../../constants/image-src-props");
|
|
9
|
+
|
|
10
|
+
var isSrcPropsChanged = function isSrcPropsChanged(currentProps, changedProps) {
|
|
11
|
+
return Object.keys(changedProps).reduce(function (acc, current) {
|
|
12
|
+
var isPropChanged = currentProps[current] !== changedProps[current];
|
|
13
|
+
var isSrcProp = _imageSrcProps.IMAGE_SRC_PROPS.indexOf(current) !== -1;
|
|
14
|
+
|
|
15
|
+
if (isSrcProp && isPropChanged) {
|
|
16
|
+
acc = true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return acc;
|
|
20
|
+
}, false);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.isSrcPropsChanged = isSrcPropsChanged;
|
package/dist/utils/index.js
CHANGED
|
@@ -26,7 +26,8 @@ var _exportNames = {
|
|
|
26
26
|
createHotspots: true,
|
|
27
27
|
generateHotspotsConfigs: true,
|
|
28
28
|
isMouseOnHotspot: true,
|
|
29
|
-
hideHotspotsIcons: true
|
|
29
|
+
hideHotspotsIcons: true,
|
|
30
|
+
isSrcPropsChanged: true
|
|
30
31
|
};
|
|
31
32
|
Object.defineProperty(exports, "addClass", {
|
|
32
33
|
enumerable: true,
|
|
@@ -130,6 +131,12 @@ Object.defineProperty(exports, "isMouseOnHotspot", {
|
|
|
130
131
|
return _isMouseOnHotspot.isMouseOnHotspot;
|
|
131
132
|
}
|
|
132
133
|
});
|
|
134
|
+
Object.defineProperty(exports, "isSrcPropsChanged", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function get() {
|
|
137
|
+
return _isSrcPropsChanged.isSrcPropsChanged;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
133
140
|
Object.defineProperty(exports, "loop", {
|
|
134
141
|
enumerable: true,
|
|
135
142
|
get: function get() {
|
|
@@ -225,4 +232,6 @@ var _generateHotspotsConfigs = require("./hotspot/generate-hotspots-configs");
|
|
|
225
232
|
|
|
226
233
|
var _isMouseOnHotspot = require("./hotspot/is-mouse-on-hotspot");
|
|
227
234
|
|
|
228
|
-
var _hideHotspotsIcons = require("./hotspot/hide-hotspots-icons");
|
|
235
|
+
var _hideHotspotsIcons = require("./hotspot/hide-hotspots-icons");
|
|
236
|
+
|
|
237
|
+
var _isSrcPropsChanged = require("./image-src/is-src-props-changed");
|
|
@@ -8,7 +8,7 @@ exports.getMovingDirection = void 0;
|
|
|
8
8
|
var _orientations = require("../../constants/orientations");
|
|
9
9
|
|
|
10
10
|
var getMovingDirection = function getMovingDirection(isStartSpin, allowSpinY, prevPosition, nextPositions, currentMovingDirection) {
|
|
11
|
-
var movingDirection;
|
|
11
|
+
var movingDirection = _orientations.ORIENTATIONS.CENTER;
|
|
12
12
|
if (isStartSpin) return currentMovingDirection;
|
|
13
13
|
var differenceInPositionX = Math.abs(prevPosition.x - nextPositions.x);
|
|
14
14
|
var differenceInPositionY = Math.abs(prevPosition.y - nextPositions.y);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-cloudimage-360-view",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "scaleflex",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"publish-demo": "npm run build-demo && npm run deploy-demo"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@babel/runtime": "^7.17.0",
|
|
36
37
|
"@popperjs/core": "^2.11.2",
|
|
37
38
|
"core-js": "^3.0.0"
|
|
38
39
|
},
|