js-cloudimage-360-view 2.7.6 → 2.7.9
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 +15 -0
- package/README.md +15 -4
- package/dist/ci360.service.js +147 -69
- package/dist/ci360.utils.js +5 -2
- package/dist/constants/props-require-reload.js +21 -0
- package/dist/index.js +37 -7
- package/dist/static/css/hotspots.css +222 -0
- package/dist/utils/{common → class-names}/add-class.js +0 -0
- package/dist/utils/{common → class-names}/remove-class.js +0 -0
- package/dist/utils/container-elements/index.js +9 -1
- package/dist/utils/container-elements/remove-child-from-parent.js +16 -0
- package/dist/utils/controls/init-controls.js +1 -1
- package/dist/utils/{hotspot → hotspots}/attach-popup-events.js +1 -1
- package/dist/utils/{hotspot → hotspots}/configs-error-handler.js +7 -10
- package/dist/utils/{hotspot → hotspots}/create-popper-instace.js +0 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-carousel-dot.js +1 -1
- package/dist/utils/{hotspot → hotspots}/elements/create-carousel-image.js +0 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-hotspot-icon.js +4 -5
- package/dist/utils/{hotspot → hotspots}/elements/create-hotspot-popup-link.js +0 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-hotspots.js +0 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-images-carousel.js +0 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-modal-description.js +0 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-modal-title.js +0 -0
- package/dist/utils/hotspots/elements/create-model-elements.js +66 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-popup-arrow.js +0 -0
- package/dist/utils/{hotspot → hotspots}/elements/create-popup.js +10 -7
- package/dist/utils/hotspots/elements/create-read-more-btn.js +17 -0
- package/dist/utils/{hotspot/fill-previous-coord-with-previous.js → hotspots/fill-empty-coord-with-previous.js} +3 -3
- package/dist/utils/hotspots/generate-hotspots-configs.js +58 -0
- package/dist/utils/{hotspot → hotspots}/generate-popup-config.js +3 -8
- package/dist/utils/{hotspot → hotspots}/get-hotspot-icon.js +0 -0
- package/dist/utils/{hotspot → hotspots}/get-hotspot-orientation.js +0 -0
- package/dist/utils/{hotspot → hotspots}/get-hotspot-popup-node.js +4 -2
- package/dist/utils/{hotspot → hotspots}/get-popup-node.js +1 -1
- package/dist/utils/{hotspot → hotspots}/hide-hotspot-icon.js +0 -0
- package/dist/utils/{hotspot → hotspots}/hide-hotspots-icons.js +0 -0
- package/dist/utils/{hotspot → hotspots}/is-mouse-on-hotspot.js +0 -0
- package/dist/utils/{hotspot → hotspots}/prepare-hotspots-positions.js +3 -3
- package/dist/utils/{hotspot → hotspots}/set-current-slide.js +0 -0
- package/dist/utils/{hotspot → hotspots}/update-hotspot-icon-position.js +0 -0
- package/dist/utils/{hotspot → hotspots}/update-hotspots.js +10 -9
- package/dist/utils/image-src/is-props-change-require-reload.js +23 -0
- package/dist/utils/index.js +11 -11
- package/package.json +1 -1
- package/dist/constants/image-src-props.js +0 -8
- package/dist/utils/hotspot/elements/create-model-elements.js +0 -49
- package/dist/utils/hotspot/generate-hotspots-configs.js +0 -41
- package/dist/utils/hotspot/get-hotspot-variant.js +0 -20
- package/dist/utils/image-src/is-src-props-changed.js +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -25,6 +25,21 @@ Types of changes:
|
|
|
25
25
|
- ...
|
|
26
26
|
|
|
27
27
|
-------------
|
|
28
|
+
## 2.7.9 - 2022-02-27
|
|
29
|
+
### Fixed
|
|
30
|
+
- typo in documentation
|
|
31
|
+
|
|
32
|
+
## 2.7.8 - 2022-02-27
|
|
33
|
+
### Added
|
|
34
|
+
- possibility to add new view to CI360 views
|
|
35
|
+
### Fixed
|
|
36
|
+
- re-render method
|
|
37
|
+
|
|
38
|
+
## 2.7.7 - 2022-02-24
|
|
39
|
+
### Fixed
|
|
40
|
+
- container width on mobile
|
|
41
|
+
- re-render method
|
|
42
|
+
|
|
28
43
|
## 2.7.6 - 2022-02-20
|
|
29
44
|
### Fixed
|
|
30
45
|
- drag speed
|
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,9 +6,9 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
<img
|
|
10
|
+
alt="The Lounge"
|
|
11
|
+
src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<h1 align="center">
|
|
@@ -105,6 +105,17 @@ window.CI360.init();
|
|
|
105
105
|
> <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2/js-cloudimage-360-view.min.js"></script>
|
|
106
106
|
> <script>window.CI360.init(); // initialize the plugin when you need</script>
|
|
107
107
|
> ```
|
|
108
|
+
|
|
109
|
+
### addView
|
|
110
|
+
|
|
111
|
+
###### Type: **Function**
|
|
112
|
+
|
|
113
|
+
add new view by id to cloudimage 360 views.
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
window.CI360.addView(idOfView: string);
|
|
117
|
+
```
|
|
118
|
+
|
|
108
119
|
### update
|
|
109
120
|
|
|
110
121
|
###### Type: **Function**
|
package/dist/ci360.service.js
CHANGED
|
@@ -19,6 +19,8 @@ var _constants = require("./constants/");
|
|
|
19
19
|
|
|
20
20
|
require("./static/css/style.css");
|
|
21
21
|
|
|
22
|
+
require("./static/css/hotspots.css");
|
|
23
|
+
|
|
22
24
|
var _utils = require("./utils");
|
|
23
25
|
|
|
24
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -26,7 +28,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
26
28
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
29
|
|
|
28
30
|
var CI360Viewer = /*#__PURE__*/function () {
|
|
29
|
-
function CI360Viewer(container, fullscreen) {
|
|
31
|
+
function CI360Viewer(container, fullscreen, hotspotConfig) {
|
|
30
32
|
(0, _classCallCheck2.default)(this, CI360Viewer);
|
|
31
33
|
this.container = container;
|
|
32
34
|
this.movementStart = {
|
|
@@ -50,7 +52,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
50
52
|
this.devicePixelRatio = Math.round(window.devicePixelRatio || 1);
|
|
51
53
|
this.isMobile = !!('ontouchstart' in window || navigator.msMaxTouchPoints);
|
|
52
54
|
this.id = container.id;
|
|
53
|
-
this.
|
|
55
|
+
this.hotspotConfig = hotspotConfig && (0, _utils.generateHotspotsConfigs)(hotspotConfig);
|
|
54
56
|
this.isMagnifyOpen = false;
|
|
55
57
|
this.isDragged = false;
|
|
56
58
|
this.startPointerZoom = false;
|
|
@@ -65,13 +67,14 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
65
67
|
y: 0
|
|
66
68
|
};
|
|
67
69
|
this.isStartedLoadOriginalImages = false;
|
|
70
|
+
this.init(container);
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
(0, _createClass2.default)(CI360Viewer, [{
|
|
71
74
|
key: "mouseDown",
|
|
72
75
|
value: function mouseDown(event) {
|
|
73
76
|
if (!this.imagesLoaded) return;
|
|
74
|
-
|
|
77
|
+
var isMouseOnHotspotElement = (0, _utils.isMouseOnHotspot)();
|
|
75
78
|
var pageX = event.pageX,
|
|
76
79
|
pageY = event.pageY;
|
|
77
80
|
this.hideInitialIcons();
|
|
@@ -92,6 +95,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
92
95
|
};
|
|
93
96
|
this.isClicked = true;
|
|
94
97
|
this.isDragged = false;
|
|
98
|
+
|
|
99
|
+
if (isMouseOnHotspotElement) {
|
|
100
|
+
this.isClicked = false;
|
|
101
|
+
}
|
|
95
102
|
}
|
|
96
103
|
}, {
|
|
97
104
|
key: "mouseUp",
|
|
@@ -215,6 +222,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
215
222
|
|
|
216
223
|
var _zoomSteps = (0, _utils.generateZoomInSteps)(this.pointerZoom);
|
|
217
224
|
|
|
225
|
+
if (this.hotspotConfig) {
|
|
226
|
+
(0, _utils.hideHotspotsIcons)();
|
|
227
|
+
}
|
|
228
|
+
|
|
218
229
|
_zoomSteps.forEach(function (step) {
|
|
219
230
|
setTimeout(function () {
|
|
220
231
|
_this2.zoomIntensity = step;
|
|
@@ -273,6 +284,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
273
284
|
key: "touchStart",
|
|
274
285
|
value: function touchStart(event) {
|
|
275
286
|
if (!this.imagesLoaded) return;
|
|
287
|
+
var isMouseOnHotspotElement = (0, _utils.isMouseOnHotspot)();
|
|
276
288
|
this.hideInitialIcons();
|
|
277
289
|
|
|
278
290
|
if (this.autoplay || this.loopTimeoutId) {
|
|
@@ -289,6 +301,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
289
301
|
y: event.touches[0].clientY
|
|
290
302
|
};
|
|
291
303
|
this.isClicked = true;
|
|
304
|
+
|
|
305
|
+
if (isMouseOnHotspotElement) {
|
|
306
|
+
this.isClicked = false;
|
|
307
|
+
}
|
|
292
308
|
}
|
|
293
309
|
}, {
|
|
294
310
|
key: "touchEnd",
|
|
@@ -680,12 +696,23 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
680
696
|
this.update();
|
|
681
697
|
}
|
|
682
698
|
}
|
|
699
|
+
}, {
|
|
700
|
+
key: "showImageInfo",
|
|
701
|
+
value: function showImageInfo(ctx) {
|
|
702
|
+
ctx.font = "".concat(this.fullscreenView ? 28 : 14, "px serif");
|
|
703
|
+
ctx.fillStyle = this.info === 'white' ? '#FFF' : '#000';
|
|
704
|
+
var imageDimension = "image-dimension: ".concat(this.container.offsetWidth, "x").concat(this.container.offsetHeight, "px");
|
|
705
|
+
var currentXImage = 'active-index-x: ' + this.activeImageX;
|
|
706
|
+
var currentYImage = 'active-index-y: ' + this.activeImageY;
|
|
707
|
+
var imageIndex = [currentXImage, currentYImage].join(' | ');
|
|
708
|
+
ctx.fillText(imageDimension, 20, this.container.offsetHeight - 35);
|
|
709
|
+
ctx.fillText(imageIndex, 20, this.container.offsetHeight - 10);
|
|
710
|
+
}
|
|
683
711
|
}, {
|
|
684
712
|
key: "requestResizedImages",
|
|
685
713
|
value: function requestResizedImages() {
|
|
686
714
|
var responsive = this.ciParams.ciToken;
|
|
687
715
|
var firstImage = this.imagesX[0];
|
|
688
|
-
this.updateContainerAndCanvasSize(firstImage);
|
|
689
716
|
this.update();
|
|
690
717
|
this.speedFactor = (0, _utils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
|
|
691
718
|
var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
|
|
@@ -708,6 +735,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
708
735
|
|
|
709
736
|
var ctx = this.canvas.getContext("2d");
|
|
710
737
|
ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
|
|
738
|
+
this.updateContainerAndCanvasSize(image);
|
|
711
739
|
|
|
712
740
|
if (this.fullscreenView) {
|
|
713
741
|
var _contain = (0, _utils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
|
|
@@ -721,9 +749,17 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
721
749
|
if (this.mouseTracked) {
|
|
722
750
|
this.updateImageScale(ctx);
|
|
723
751
|
} else {
|
|
752
|
+
if (this.hotspotConfig && !this.autoplay) {
|
|
753
|
+
(0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
|
|
754
|
+
}
|
|
755
|
+
|
|
724
756
|
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
725
757
|
}
|
|
726
758
|
}
|
|
759
|
+
|
|
760
|
+
if (this.info) {
|
|
761
|
+
this.showImageInfo(ctx);
|
|
762
|
+
}
|
|
727
763
|
}
|
|
728
764
|
}, {
|
|
729
765
|
key: "updateImageScale",
|
|
@@ -759,13 +795,9 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
759
795
|
value: function onFirstImageLoaded(image) {
|
|
760
796
|
if (!this.hide360Logo && !this.lazyload) this.add360ViewIcon();
|
|
761
797
|
var ctx = this.canvas.getContext("2d");
|
|
798
|
+
this.updateContainerAndCanvasSize(image);
|
|
762
799
|
|
|
763
800
|
if (this.fullscreenView) {
|
|
764
|
-
this.canvas.width = window.innerWidth * this.devicePixelRatio;
|
|
765
|
-
this.canvas.style.width = window.innerWidth + 'px';
|
|
766
|
-
this.canvas.height = window.innerHeight * this.devicePixelRatio;
|
|
767
|
-
this.canvas.style.height = window.innerHeight + 'px';
|
|
768
|
-
|
|
769
801
|
var _contain2 = (0, _utils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
|
|
770
802
|
offsetX = _contain2.offsetX,
|
|
771
803
|
offsetY = _contain2.offsetY,
|
|
@@ -776,17 +808,14 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
776
808
|
x: offsetX,
|
|
777
809
|
y: offsetY
|
|
778
810
|
};
|
|
811
|
+
this.addCloseFullscreenView();
|
|
779
812
|
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
780
813
|
} else {
|
|
781
|
-
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
782
|
-
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
783
|
-
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
784
|
-
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
785
814
|
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
786
815
|
}
|
|
787
816
|
|
|
788
|
-
if (this.
|
|
789
|
-
this.
|
|
817
|
+
if (this.info) {
|
|
818
|
+
this.showImageInfo(ctx);
|
|
790
819
|
}
|
|
791
820
|
|
|
792
821
|
if (this.magnifier) {
|
|
@@ -794,7 +823,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
794
823
|
}
|
|
795
824
|
|
|
796
825
|
if (this.boxShadow && !this.fullscreenView) {
|
|
797
|
-
(0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
826
|
+
this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
798
827
|
}
|
|
799
828
|
|
|
800
829
|
if (this.bottomCircle && !this.fullscreenView) {
|
|
@@ -804,6 +833,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
804
833
|
if (this.fullscreen && !this.fullscreenView) {
|
|
805
834
|
this.addFullscreenIcon();
|
|
806
835
|
}
|
|
836
|
+
|
|
837
|
+
if (this.hotspotConfig && !this.autoplay) {
|
|
838
|
+
(0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
|
|
839
|
+
}
|
|
807
840
|
}
|
|
808
841
|
}, {
|
|
809
842
|
key: "onAllImagesLoaded",
|
|
@@ -870,7 +903,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
870
903
|
event.stopPropagation();
|
|
871
904
|
if (this.mouseTracked) this.togglePointerZoom();
|
|
872
905
|
var fullscreenContainer = (0, _utils.createFullscreenModal)(this.container);
|
|
873
|
-
new CI360Viewer(fullscreenContainer, true);
|
|
906
|
+
new CI360Viewer(fullscreenContainer, true, this.hotspotConfig);
|
|
874
907
|
}
|
|
875
908
|
}, {
|
|
876
909
|
key: "setFullscreenEvents",
|
|
@@ -915,19 +948,33 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
915
948
|
window.clearTimeout(this.loopTimeoutId);
|
|
916
949
|
}
|
|
917
950
|
}, {
|
|
918
|
-
key: "
|
|
919
|
-
value: function
|
|
951
|
+
key: "updateView",
|
|
952
|
+
value: function updateView(forceUpdate, viewers) {
|
|
953
|
+
var _this5 = this;
|
|
954
|
+
|
|
920
955
|
var container = this.container;
|
|
921
956
|
var imageProps = (0, _ci.get360ViewProps)(container);
|
|
922
|
-
var srcPropsChanged = (0, _utils.
|
|
923
|
-
var
|
|
957
|
+
var srcPropsChanged = (0, _utils.isPropsChangeRequireReload)(this, imageProps);
|
|
958
|
+
var reInitView = srcPropsChanged || forceUpdate;
|
|
959
|
+
|
|
960
|
+
if (reInitView) {
|
|
961
|
+
var oldElement = this.container;
|
|
962
|
+
var viewIndex = viewers.findIndex(function (view) {
|
|
963
|
+
return view.id === _this5.container.id;
|
|
964
|
+
});
|
|
965
|
+
container = container.cloneNode(true);
|
|
966
|
+
container.className = container.className.replace(' initialized', '');
|
|
967
|
+
container.innerHTML = '';
|
|
968
|
+
oldElement.parentNode.replaceChild(container, oldElement);
|
|
969
|
+
return viewers.splice(viewIndex, 1, new CI360Viewer(container));
|
|
970
|
+
}
|
|
971
|
+
|
|
924
972
|
container.style.position = 'relative';
|
|
925
973
|
container.style.width = '100%';
|
|
926
974
|
container.style.cursor = 'default';
|
|
927
975
|
container.setAttribute('draggable', 'false');
|
|
928
|
-
if (reloadPlugin) container.innerHTML = '';
|
|
929
976
|
this.stop();
|
|
930
|
-
this.init(container,
|
|
977
|
+
this.init(container, true);
|
|
931
978
|
}
|
|
932
979
|
}, {
|
|
933
980
|
key: "destroy",
|
|
@@ -1050,52 +1097,52 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1050
1097
|
}, {
|
|
1051
1098
|
key: "initControls",
|
|
1052
1099
|
value: function initControls() {
|
|
1053
|
-
var
|
|
1100
|
+
var _this6 = this;
|
|
1054
1101
|
|
|
1055
1102
|
var onLeftStart = function onLeftStart(event) {
|
|
1056
1103
|
event.stopPropagation();
|
|
1057
1104
|
|
|
1058
|
-
|
|
1105
|
+
_this6.onSpin();
|
|
1059
1106
|
|
|
1060
|
-
|
|
1107
|
+
_this6.left();
|
|
1061
1108
|
|
|
1062
|
-
|
|
1109
|
+
_this6.loopTimeoutId = window.setInterval(_this6.left.bind(_this6), _this6.autoplaySpeed);
|
|
1063
1110
|
};
|
|
1064
1111
|
|
|
1065
1112
|
var onRightStart = function onRightStart(event) {
|
|
1066
1113
|
event.stopPropagation();
|
|
1067
1114
|
|
|
1068
|
-
|
|
1115
|
+
_this6.onSpin();
|
|
1069
1116
|
|
|
1070
|
-
|
|
1117
|
+
_this6.right();
|
|
1071
1118
|
|
|
1072
|
-
|
|
1119
|
+
_this6.loopTimeoutId = window.setInterval(_this6.right.bind(_this6), _this6.autoplaySpeed);
|
|
1073
1120
|
};
|
|
1074
1121
|
|
|
1075
1122
|
var onTopStart = function onTopStart(event) {
|
|
1076
1123
|
event.stopPropagation();
|
|
1077
1124
|
|
|
1078
|
-
|
|
1125
|
+
_this6.onSpin();
|
|
1079
1126
|
|
|
1080
|
-
|
|
1127
|
+
_this6.top();
|
|
1081
1128
|
|
|
1082
|
-
|
|
1129
|
+
_this6.loopTimeoutId = window.setInterval(_this6.top.bind(_this6), _this6.autoplaySpeed);
|
|
1083
1130
|
};
|
|
1084
1131
|
|
|
1085
1132
|
var onBottomStart = function onBottomStart(event) {
|
|
1086
1133
|
event.stopPropagation();
|
|
1087
1134
|
|
|
1088
|
-
|
|
1135
|
+
_this6.onSpin();
|
|
1089
1136
|
|
|
1090
|
-
|
|
1137
|
+
_this6.bottom();
|
|
1091
1138
|
|
|
1092
|
-
|
|
1139
|
+
_this6.loopTimeoutId = window.setInterval(_this6.bottom.bind(_this6), _this6.autoplaySpeed);
|
|
1093
1140
|
};
|
|
1094
1141
|
|
|
1095
1142
|
var onEventEnd = function onEventEnd() {
|
|
1096
|
-
|
|
1143
|
+
_this6.onFinishSpin();
|
|
1097
1144
|
|
|
1098
|
-
window.clearTimeout(
|
|
1145
|
+
window.clearTimeout(_this6.loopTimeoutId);
|
|
1099
1146
|
};
|
|
1100
1147
|
|
|
1101
1148
|
var controlsConfig = {
|
|
@@ -1148,10 +1195,9 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1148
1195
|
}, {
|
|
1149
1196
|
key: "init",
|
|
1150
1197
|
value: function init(container) {
|
|
1151
|
-
var
|
|
1198
|
+
var _this7 = this;
|
|
1152
1199
|
|
|
1153
1200
|
var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1154
|
-
var reload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1155
1201
|
|
|
1156
1202
|
var _get360ViewProps = (0, _ci.get360ViewProps)(container),
|
|
1157
1203
|
folder = _get360ViewProps.folder,
|
|
@@ -1193,7 +1239,9 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1193
1239
|
hide360Logo = _get360ViewProps.hide360Logo,
|
|
1194
1240
|
logoSrc = _get360ViewProps.logoSrc,
|
|
1195
1241
|
pointerZoom = _get360ViewProps.pointerZoom,
|
|
1196
|
-
ratio = _get360ViewProps.ratio
|
|
1242
|
+
ratio = _get360ViewProps.ratio,
|
|
1243
|
+
_get360ViewProps$imag = _get360ViewProps.imageInfo,
|
|
1244
|
+
imageInfo = _get360ViewProps$imag === void 0 ? 'black' : _get360ViewProps$imag;
|
|
1197
1245
|
|
|
1198
1246
|
var ciParams = {
|
|
1199
1247
|
ciToken: ciToken,
|
|
@@ -1238,22 +1286,54 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1238
1286
|
this.apiVersion = apiVersion;
|
|
1239
1287
|
this.pointerZoom = pointerZoom > 1 ? Math.min(pointerZoom, 3) : 0;
|
|
1240
1288
|
this.keysReverse = keysReverse;
|
|
1289
|
+
this.info = imageInfo;
|
|
1290
|
+
this.keys = keys;
|
|
1241
1291
|
this.ratio = ratio && JSON.parse(ratio);
|
|
1242
1292
|
|
|
1243
|
-
if (reload) {
|
|
1244
|
-
new CI360Viewer(this.container);
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
1293
|
if (update) {
|
|
1249
|
-
this.
|
|
1250
|
-
|
|
1294
|
+
(0, _utils.removeChildFromParent)(this.innerBox, this.iconsContainer);
|
|
1295
|
+
(0, _utils.removeChildFromParent)(this.innerBox, this.boxShadowEl);
|
|
1296
|
+
(0, _utils.removeChildFromParent)(this.innerBox, this.view360Icon);
|
|
1297
|
+
this.remove360ViewCircleIcon();
|
|
1298
|
+
this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
|
|
1299
|
+
|
|
1300
|
+
if (!this.hide360Logo && !this.lazyload && this.logoSrc) {
|
|
1301
|
+
this.add360ViewIcon();
|
|
1302
|
+
(0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
if (this.magnifier) {
|
|
1306
|
+
this.addMagnifier();
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
if (this.info) {
|
|
1310
|
+
this.showImageInfo(ctx);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
if (this.bottomCircle && !this.fullscreenView) {
|
|
1314
|
+
this.add360ViewCircleIcon();
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
if (this.fullscreen && !this.fullscreenView) {
|
|
1318
|
+
this.addFullscreenIcon();
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
if (this.boxShadow && !this.fullscreenView) {
|
|
1322
|
+
this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
return this.onAllImagesLoaded();
|
|
1251
1326
|
}
|
|
1252
1327
|
|
|
1253
1328
|
this.innerBox = (0, _utils.createInnerBox)(this.container);
|
|
1254
1329
|
this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
|
|
1255
1330
|
this.canvas = (0, _utils.createCanvas)(this.innerBox);
|
|
1256
1331
|
this.loader = (0, _utils.createLoader)(this.innerBox);
|
|
1332
|
+
|
|
1333
|
+
if (this.hotspotConfig && !this.fullscreenView) {
|
|
1334
|
+
(0, _utils.createHotspots)(container, this.hotspotConfig);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1257
1337
|
(0, _utils.applyStylesToContainer)(this.container);
|
|
1258
1338
|
this.srcXConfig = {
|
|
1259
1339
|
folder: folder,
|
|
@@ -1279,60 +1359,58 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1279
1359
|
var srcY = (0, _utils.generateImagesPath)(this.srcYConfig);
|
|
1280
1360
|
|
|
1281
1361
|
var initLazyload = function initLazyload(image, orientation) {
|
|
1282
|
-
var lazyloadXConfig = _objectSpread(_objectSpread({},
|
|
1362
|
+
var lazyloadXConfig = _objectSpread(_objectSpread({}, _this7.srcXConfig), {}, {
|
|
1283
1363
|
lazyload: false
|
|
1284
1364
|
});
|
|
1285
1365
|
|
|
1286
|
-
var lazyloadYConfig = _objectSpread(_objectSpread({},
|
|
1366
|
+
var lazyloadYConfig = _objectSpread(_objectSpread({}, _this7.srcYConfig), {}, {
|
|
1287
1367
|
lazyload: false
|
|
1288
1368
|
});
|
|
1289
1369
|
|
|
1290
1370
|
if (orientation === _constants.ORIENTATIONS.Y) {
|
|
1291
|
-
|
|
1292
|
-
(0, _utils.preloadImages)(lazyloadXConfig, srcX, onImageLoad.bind(
|
|
1371
|
+
_this7.lazyloadY = false;
|
|
1372
|
+
(0, _utils.preloadImages)(lazyloadXConfig, srcX, onImageLoad.bind(_this7, _constants.ORIENTATIONS.X));
|
|
1293
1373
|
} else {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
(0, _utils.preloadImages)(lazyloadYConfig, srcY, onImageLoad.bind(
|
|
1374
|
+
_this7.lazyloadX = false;
|
|
1375
|
+
_this7.lazyloadInitImageX = image;
|
|
1376
|
+
(0, _utils.preloadImages)(lazyloadYConfig, srcY, onImageLoad.bind(_this7, _constants.ORIENTATIONS.Y));
|
|
1297
1377
|
}
|
|
1298
1378
|
};
|
|
1299
1379
|
|
|
1300
1380
|
var onImageLoad = function onImageLoad(orientation, image, index) {
|
|
1301
1381
|
if (orientation !== _constants.ORIENTATIONS.Y) {
|
|
1302
|
-
|
|
1382
|
+
_this7.imagesX[index] = image;
|
|
1303
1383
|
} else {
|
|
1304
|
-
|
|
1384
|
+
_this7.imagesY[index] = image;
|
|
1305
1385
|
}
|
|
1306
1386
|
|
|
1307
|
-
var loadedXImages =
|
|
1387
|
+
var loadedXImages = _this7.imagesX.filter(function (image) {
|
|
1308
1388
|
return !!image;
|
|
1309
1389
|
});
|
|
1310
1390
|
|
|
1311
|
-
var loadedYImages =
|
|
1391
|
+
var loadedYImages = _this7.imagesY.filter(function (image) {
|
|
1312
1392
|
return !!image;
|
|
1313
1393
|
});
|
|
1314
1394
|
|
|
1315
|
-
var totalAmount =
|
|
1316
|
-
var totalLoadedImages =
|
|
1395
|
+
var totalAmount = _this7.amountX + _this7.amountY;
|
|
1396
|
+
var totalLoadedImages = _this7.imagesX.length + _this7.imagesY.length;
|
|
1317
1397
|
var isFirstImageLoaded = index === 0 && orientation !== _constants.ORIENTATIONS.Y;
|
|
1318
|
-
var isAllImagesLoaded = loadedXImages.length + loadedYImages.length ===
|
|
1398
|
+
var isAllImagesLoaded = loadedXImages.length + loadedYImages.length === _this7.amountX + _this7.amountY;
|
|
1319
1399
|
var percentage = Math.round(totalLoadedImages / totalAmount * 100);
|
|
1320
1400
|
|
|
1321
|
-
|
|
1401
|
+
_this7.updatePercentageInLoader(percentage);
|
|
1322
1402
|
|
|
1323
|
-
if (
|
|
1403
|
+
if (_this7.lazyloadX || _this7.lazyloadY) return initLazyload(image, orientation);
|
|
1324
1404
|
|
|
1325
1405
|
if (isFirstImageLoaded) {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
_this6.onFirstImageLoaded(image);
|
|
1406
|
+
_this7.onFirstImageLoaded(image);
|
|
1329
1407
|
}
|
|
1330
1408
|
|
|
1331
1409
|
if (isAllImagesLoaded) {
|
|
1332
|
-
|
|
1410
|
+
_this7.onAllImagesLoaded();
|
|
1333
1411
|
|
|
1334
1412
|
if (lazyload) {
|
|
1335
|
-
|
|
1413
|
+
_this7.innerBox.removeChild(_this7.lazyloadInitImageX);
|
|
1336
1414
|
}
|
|
1337
1415
|
}
|
|
1338
1416
|
};
|
package/dist/ci360.utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setView360Icon = exports.get360ViewProps = exports.debounce = void 0;
|
|
6
|
+
exports.setView360Icon = exports.get360ViewProps = exports.debounce = exports.attr = void 0;
|
|
7
7
|
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
|
|
@@ -46,7 +46,8 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
46
46
|
stopAtEdges: isTrue(image, 'stop-at-edges'),
|
|
47
47
|
hide360Logo: isTrue(image, 'hide-360-logo'),
|
|
48
48
|
logoSrc: attr(image, 'logo-src') || 'https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg',
|
|
49
|
-
ratio: attr(image, 'ratio') || attr(image, 'data-ratio') || null
|
|
49
|
+
ratio: attr(image, 'ratio') || attr(image, 'data-ratio') || null,
|
|
50
|
+
imageInfo: attr(image, 'info') || attr(image, 'data-info') || isTrue(image, 'info')
|
|
50
51
|
};
|
|
51
52
|
};
|
|
52
53
|
|
|
@@ -62,6 +63,8 @@ var attr = function attr(element, attribute) {
|
|
|
62
63
|
return element.getAttribute(attribute);
|
|
63
64
|
};
|
|
64
65
|
|
|
66
|
+
exports.attr = attr;
|
|
67
|
+
|
|
65
68
|
var setView360Icon = function setView360Icon(view360Icon, logoSrc) {
|
|
66
69
|
view360Icon.style.background = "rgba(255,255,255,0.8) url('".concat(logoSrc, "') 50% 50% / contain no-repeat");
|
|
67
70
|
};
|
|
@@ -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;
|
package/dist/index.js
CHANGED
|
@@ -10,11 +10,29 @@ require("core-js/features/array/includes");
|
|
|
10
10
|
|
|
11
11
|
var _ci = _interopRequireDefault(require("./ci360.service"));
|
|
12
12
|
|
|
13
|
+
var _ci2 = require("./ci360.utils");
|
|
14
|
+
|
|
15
|
+
function setContainerId(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
|
+
}
|
|
26
|
+
|
|
13
27
|
function init() {
|
|
14
28
|
var viewers = [];
|
|
15
29
|
var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
|
|
30
|
+
var hotspotsConfigs = window.CI360.hotspots || {};
|
|
16
31
|
[].slice.call(view360Array).forEach(function (container) {
|
|
17
|
-
|
|
32
|
+
var containerWithId = setContainerId(container);
|
|
33
|
+
var hotspotInstanceName = (0, _ci2.attr)(containerWithId, 'hotspot-instance') || (0, _ci2.attr)(containerWithId, 'data-hotspot-instance');
|
|
34
|
+
var hotspotConfig = hotspotsConfigs === null || hotspotsConfigs === void 0 ? void 0 : hotspotsConfigs[hotspotInstanceName];
|
|
35
|
+
viewers.push(new _ci.default(containerWithId, false, hotspotConfig));
|
|
18
36
|
});
|
|
19
37
|
window.CI360._viewers = viewers;
|
|
20
38
|
}
|
|
@@ -43,6 +61,17 @@ function getActiveIndexByID(id, oriantation) {
|
|
|
43
61
|
return currentViewer && currentViewer.activeImageX - 1;
|
|
44
62
|
}
|
|
45
63
|
|
|
64
|
+
function addView(id) {
|
|
65
|
+
var view360Array = Array.from(document.querySelectorAll('.cloudimage-360:not(.initialized)'));
|
|
66
|
+
|
|
67
|
+
if (view360Array.length && id) {
|
|
68
|
+
var newViewContainer = view360Array.filter(function (viewer) {
|
|
69
|
+
return viewer.id === id;
|
|
70
|
+
})[0];
|
|
71
|
+
newViewContainer && window.CI360._viewers.push(new _ci.default(newViewContainer));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
46
75
|
function update() {
|
|
47
76
|
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
48
77
|
var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -53,15 +82,15 @@ function update() {
|
|
|
53
82
|
return viewer.id === id;
|
|
54
83
|
})[0];
|
|
55
84
|
|
|
56
|
-
|
|
85
|
+
view.updateView(forceUpdate, window.CI360._viewers);
|
|
57
86
|
} catch (_unused) {
|
|
58
|
-
console.
|
|
87
|
+
console.warn("Cloudimage-360: there is no view with such id '".concat(id, "', you may need to run window.addView('").concat(id, "') before run update'"));
|
|
59
88
|
}
|
|
89
|
+
} else {
|
|
90
|
+
window.CI360._viewers.forEach(function (viewer) {
|
|
91
|
+
viewer.updateView(forceUpdate, window.CI360._viewers);
|
|
92
|
+
});
|
|
60
93
|
}
|
|
61
|
-
|
|
62
|
-
return window.CI360._viewers.forEach(function (viewer) {
|
|
63
|
-
viewer.updatePlugin(forceUpdate);
|
|
64
|
-
});
|
|
65
94
|
}
|
|
66
95
|
|
|
67
96
|
function isNoViewers() {
|
|
@@ -73,6 +102,7 @@ window.CI360.init = init;
|
|
|
73
102
|
window.CI360.destroy = destroy;
|
|
74
103
|
window.CI360.getActiveIndexByID = getActiveIndexByID;
|
|
75
104
|
window.CI360.update = update;
|
|
105
|
+
window.CI360.addView = addView;
|
|
76
106
|
|
|
77
107
|
if (!window.CI360.notInitOnLoad) {
|
|
78
108
|
init();
|