js-cloudimage-360-view 2.7.2-beta.1 → 2.7.2-beta.3
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/dist/ci360.service.js +84 -40
- package/dist/ci360.utils.js +4 -3
- package/package.json +2 -1
package/dist/ci360.service.js
CHANGED
|
@@ -692,20 +692,60 @@ var CI360Viewer = function () {
|
|
|
692
692
|
this.update();
|
|
693
693
|
}
|
|
694
694
|
}, {
|
|
695
|
-
key: '
|
|
696
|
-
value: function
|
|
695
|
+
key: 'getContainerResponsiveWidth',
|
|
696
|
+
value: function getContainerResponsiveWidth() {
|
|
697
|
+
var parentEl = this.container.parentNode || {};
|
|
698
|
+
|
|
699
|
+
if (this.containerWidth) {
|
|
700
|
+
if (parentEl.offsetWidth < this.containerWidth) {
|
|
701
|
+
return parentEl.offsetWidth;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
return this.containerWidth;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return parentEl.offsetWidth;
|
|
708
|
+
}
|
|
709
|
+
}, {
|
|
710
|
+
key: 'getContainerResponsiveHeight',
|
|
711
|
+
value: function getContainerResponsiveHeight(width) {
|
|
712
|
+
if (this.containerHeight) {
|
|
713
|
+
if (width < this.containerHeight) {
|
|
714
|
+
return width;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
return this.containerHeight;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return this.container.offsetWidth;
|
|
721
|
+
}
|
|
722
|
+
}, {
|
|
723
|
+
key: 'updateContainerSize',
|
|
724
|
+
value: function updateContainerSize(image) {
|
|
697
725
|
var imageAspectRatio = image.width / image.height;
|
|
698
|
-
var
|
|
726
|
+
var isProvidedHeightLessThanWidth = this.containerHeight < this.containerWidth;
|
|
727
|
+
var containerWidth = this.getContainerResponsiveWidth();
|
|
728
|
+
var containerHeight = this.getContainerResponsiveHeight(containerWidth);
|
|
699
729
|
|
|
700
|
-
this.
|
|
701
|
-
|
|
730
|
+
if (this.containerWidth && this.containerHeight) {
|
|
731
|
+
this.container.style.width = containerWidth + 'px';
|
|
732
|
+
this.container.style.height = containerHeight / imageAspectRatio + 'px';
|
|
702
733
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
if (!this.containerWidth && !this.containerHeight) {
|
|
738
|
+
this.container.style.height = containerHeight / imageAspectRatio + 'px';
|
|
739
|
+
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
if ((isProvidedHeightLessThanWidth || !this.containerWidth) && this.containerHeight) {
|
|
744
|
+
this.container.style.maxWidth = containerHeight * imageAspectRatio + 'px';
|
|
745
|
+
this.container.style.height = containerHeight + 'px';
|
|
706
746
|
} else {
|
|
707
|
-
this.
|
|
708
|
-
this.
|
|
747
|
+
this.container.style.maxWidth = containerWidth + 'px';
|
|
748
|
+
this.container.style.height = containerWidth / imageAspectRatio + 'px';
|
|
709
749
|
}
|
|
710
750
|
}
|
|
711
751
|
}, {
|
|
@@ -717,7 +757,7 @@ var CI360Viewer = function () {
|
|
|
717
757
|
var totalLoadedImages = this.loadedImagesX + this.loadedImagesY;
|
|
718
758
|
|
|
719
759
|
if (this.loadedImagesX === 1 && orientation !== _ci2.ORIENTATIONS.Y) {
|
|
720
|
-
this.
|
|
760
|
+
this.updateContainerSize(event.target);
|
|
721
761
|
}
|
|
722
762
|
|
|
723
763
|
if (totalLoadedImages === totalAmount) {
|
|
@@ -786,12 +826,12 @@ var CI360Viewer = function () {
|
|
|
786
826
|
}, {
|
|
787
827
|
key: 'requestResizedImages',
|
|
788
828
|
value: function requestResizedImages() {
|
|
789
|
-
var srcX = this.getSrc(this.
|
|
829
|
+
var srcX = this.getSrc(this.container, this.folder, this.apiVersion, this.filenameX, this.ciParams);
|
|
790
830
|
|
|
791
831
|
this.requestNewImages(srcX, this.amountX, _ci2.ORIENTATIONS.X);
|
|
792
832
|
|
|
793
833
|
if (this.allowSpinY) {
|
|
794
|
-
var srcY = this.getSrc(this.
|
|
834
|
+
var srcY = this.getSrc(this.container, this.folder, this.apiVersion, this.filenameY, this.ciParams);
|
|
795
835
|
|
|
796
836
|
this.requestNewImages(srcY, this.amountY, _ci2.ORIENTATIONS.Y);
|
|
797
837
|
}
|
|
@@ -823,6 +863,12 @@ var CI360Viewer = function () {
|
|
|
823
863
|
|
|
824
864
|
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
825
865
|
} else {
|
|
866
|
+
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
867
|
+
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
868
|
+
|
|
869
|
+
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
870
|
+
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
871
|
+
|
|
826
872
|
if (this.startPointerZoom || this.startPinchZoom) {
|
|
827
873
|
this.updateImageScale(ctx);
|
|
828
874
|
} else {
|
|
@@ -908,6 +954,8 @@ var CI360Viewer = function () {
|
|
|
908
954
|
value: function onFirstImageLoaded(event) {
|
|
909
955
|
var _this2 = this;
|
|
910
956
|
|
|
957
|
+
this.updateContainerSize(event.target);
|
|
958
|
+
|
|
911
959
|
if (!this.hide360Logo) {
|
|
912
960
|
this.add360ViewIcon();
|
|
913
961
|
}
|
|
@@ -938,7 +986,7 @@ var CI360Viewer = function () {
|
|
|
938
986
|
}
|
|
939
987
|
|
|
940
988
|
if (this.container.offsetWidth === 0) {
|
|
941
|
-
var modalRef = this.container.
|
|
989
|
+
var modalRef = this.container.parentNode || {};
|
|
942
990
|
|
|
943
991
|
this.canvas.width = parseInt(modalRef.style.width) * this.devicePixelRatio;
|
|
944
992
|
this.canvas.style.width = modalRef.style.width;
|
|
@@ -948,7 +996,11 @@ var CI360Viewer = function () {
|
|
|
948
996
|
}
|
|
949
997
|
|
|
950
998
|
if (this.container.offsetWidth > 0) {
|
|
951
|
-
this.
|
|
999
|
+
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
1000
|
+
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
1001
|
+
|
|
1002
|
+
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
1003
|
+
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
952
1004
|
}
|
|
953
1005
|
|
|
954
1006
|
_ctx.drawImage(imagePreview, 0, 0, this.canvas.width, this.canvas.height);
|
|
@@ -969,10 +1021,6 @@ var CI360Viewer = function () {
|
|
|
969
1021
|
});
|
|
970
1022
|
}
|
|
971
1023
|
|
|
972
|
-
if (this.ratio) {
|
|
973
|
-
this.container.style.minHeight = 'auto';
|
|
974
|
-
}
|
|
975
|
-
|
|
976
1024
|
if (this.fullscreenView) {
|
|
977
1025
|
this.addCloseFullscreenView();
|
|
978
1026
|
}
|
|
@@ -1344,15 +1392,15 @@ var CI360Viewer = function () {
|
|
|
1344
1392
|
}
|
|
1345
1393
|
}, {
|
|
1346
1394
|
key: 'getSrc',
|
|
1347
|
-
value: function getSrc(
|
|
1348
|
-
var ciParams = arguments.length >
|
|
1395
|
+
value: function getSrc(container, folder, apiVersion, filename) {
|
|
1396
|
+
var ciParams = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
1349
1397
|
var ciToken = ciParams.ciToken,
|
|
1350
1398
|
ciFilters = ciParams.ciFilters,
|
|
1351
1399
|
ciTransformation = ciParams.ciTransformation;
|
|
1352
1400
|
|
|
1353
1401
|
var src = '' + folder + filename;
|
|
1354
1402
|
|
|
1355
|
-
if (
|
|
1403
|
+
if (ciToken) {
|
|
1356
1404
|
var imageOffsetWidth = container.offsetWidth;
|
|
1357
1405
|
|
|
1358
1406
|
var vesrion = _ci2.falsyValues.indexOf(apiVersion) !== -1 ? null : apiVersion;
|
|
@@ -1380,13 +1428,12 @@ var CI360Viewer = function () {
|
|
|
1380
1428
|
var lazyload = arguments[3];
|
|
1381
1429
|
var lazySelector = arguments[4];
|
|
1382
1430
|
var container = arguments[5];
|
|
1383
|
-
var
|
|
1384
|
-
var ciParams = arguments[7];
|
|
1431
|
+
var ciParams = arguments[6];
|
|
1385
1432
|
|
|
1386
1433
|
var _this5 = this;
|
|
1387
1434
|
|
|
1388
|
-
var apiVersion = arguments[
|
|
1389
|
-
var filename = arguments[
|
|
1435
|
+
var apiVersion = arguments[7];
|
|
1436
|
+
var filename = arguments[8];
|
|
1390
1437
|
|
|
1391
1438
|
if (this.imageList) {
|
|
1392
1439
|
try {
|
|
@@ -1395,7 +1442,7 @@ var CI360Viewer = function () {
|
|
|
1395
1442
|
this.amountX = images.length;
|
|
1396
1443
|
images.forEach(function (src, index) {
|
|
1397
1444
|
var folder = /(http(s?)):\/\//gi.test(src) ? '' : _this5.folder;
|
|
1398
|
-
var resultSrc = _this5.getSrc(
|
|
1445
|
+
var resultSrc = _this5.getSrc(container, folder, apiVersion, filename, ciParams);
|
|
1399
1446
|
var lastIndex = resultSrc.lastIndexOf('//');
|
|
1400
1447
|
var originalSrc = resultSrc.slice(lastIndex);
|
|
1401
1448
|
|
|
@@ -1595,11 +1642,6 @@ var CI360Viewer = function () {
|
|
|
1595
1642
|
this.canvas.style.width = '100%';
|
|
1596
1643
|
this.canvas.style.fontSize = '0';
|
|
1597
1644
|
|
|
1598
|
-
if (this.ratio) {
|
|
1599
|
-
this.container.style.minHeight = this.container.offsetWidth * this.ratio + 'px';
|
|
1600
|
-
this.canvas.height = parseInt(this.container.style.minHeight);
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
1645
|
this.innerBox.appendChild(this.canvas);
|
|
1604
1646
|
}
|
|
1605
1647
|
}, {
|
|
@@ -1609,7 +1651,7 @@ var CI360Viewer = function () {
|
|
|
1609
1651
|
|
|
1610
1652
|
window.addEventListener('resize', (0, _ci.debounce)(function () {
|
|
1611
1653
|
_this7.requestResizedImages();
|
|
1612
|
-
},
|
|
1654
|
+
}, 80));
|
|
1613
1655
|
|
|
1614
1656
|
if (draggable && !this.disableDrag) {
|
|
1615
1657
|
this.container.addEventListener('mousedown', this.mouseDown.bind(this));
|
|
@@ -1705,7 +1747,6 @@ var CI360Viewer = function () {
|
|
|
1705
1747
|
magnifier = _get360ViewProps.magnifier,
|
|
1706
1748
|
magnifyInFullscreen = _get360ViewProps.magnifyInFullscreen,
|
|
1707
1749
|
ratio = _get360ViewProps.ratio,
|
|
1708
|
-
responsive = _get360ViewProps.responsive,
|
|
1709
1750
|
ciToken = _get360ViewProps.ciToken,
|
|
1710
1751
|
ciFilters = _get360ViewProps.ciFilters,
|
|
1711
1752
|
ciTransformation = _get360ViewProps.ciTransformation,
|
|
@@ -1716,7 +1757,9 @@ var CI360Viewer = function () {
|
|
|
1716
1757
|
stopAtEdges = _get360ViewProps.stopAtEdges,
|
|
1717
1758
|
controlReverse = _get360ViewProps.controlReverse,
|
|
1718
1759
|
hide360Logo = _get360ViewProps.hide360Logo,
|
|
1719
|
-
logoSrc = _get360ViewProps.logoSrc
|
|
1760
|
+
logoSrc = _get360ViewProps.logoSrc,
|
|
1761
|
+
containerWidth = _get360ViewProps.containerWidth,
|
|
1762
|
+
containerHeight = _get360ViewProps.containerHeight;
|
|
1720
1763
|
|
|
1721
1764
|
var ciParams = { ciToken: ciToken, ciFilters: ciFilters, ciTransformation: ciTransformation };
|
|
1722
1765
|
|
|
@@ -1764,21 +1807,22 @@ var CI360Viewer = function () {
|
|
|
1764
1807
|
this.stopAtEdges = stopAtEdges;
|
|
1765
1808
|
this.hide360Logo = hide360Logo;
|
|
1766
1809
|
this.logoSrc = logoSrc;
|
|
1767
|
-
this.responsive = responsive;
|
|
1768
1810
|
this.ciParams = ciParams;
|
|
1769
1811
|
this.apiVersion = apiVersion;
|
|
1812
|
+
this.containerWidth = containerWidth;
|
|
1813
|
+
this.containerHeight = containerHeight;
|
|
1770
1814
|
|
|
1771
1815
|
this.applyStylesToContainer();
|
|
1772
1816
|
|
|
1773
1817
|
this.addCanvas();
|
|
1774
1818
|
|
|
1775
|
-
var srcX = this.getSrc(
|
|
1776
|
-
var srcY = this.getSrc(
|
|
1819
|
+
var srcX = this.getSrc(container, folder, apiVersion, filenameX, ciParams);
|
|
1820
|
+
var srcY = this.getSrc(container, folder, apiVersion, filenameY, ciParams);
|
|
1777
1821
|
|
|
1778
|
-
this.preloadImages(amountX, srcX, _ci2.ORIENTATIONS.X, lazyload, lazySelector, container,
|
|
1822
|
+
this.preloadImages(amountX, srcX, _ci2.ORIENTATIONS.X, lazyload, lazySelector, container, ciParams, apiVersion, filenameX);
|
|
1779
1823
|
|
|
1780
1824
|
if (amountY) {
|
|
1781
|
-
this.preloadImages(amountY, srcY, _ci2.ORIENTATIONS.Y, lazyload, lazySelector, container,
|
|
1825
|
+
this.preloadImages(amountY, srcY, _ci2.ORIENTATIONS.Y, lazyload, lazySelector, container, ciParams, apiVersion, filenameY);
|
|
1782
1826
|
}
|
|
1783
1827
|
|
|
1784
1828
|
this.attachEvents(draggable, swipeable, keys);
|
package/dist/ci360.utils.js
CHANGED
|
@@ -41,8 +41,7 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
41
41
|
magnifyInFullscreen: isTrue(image, 'magnify-in-fullscreen') || isTrue(image, 'magnifier-in-fullscreen'),
|
|
42
42
|
bottomCircleOffset: parseInt(attr(image, 'bottom-circle-offset') || attr(image, 'data-bottom-circle-offset') || 5, 10),
|
|
43
43
|
ratio: parseFloat(attr(image, 'ratio') || attr(image, 'data-ratio') || 0) || false,
|
|
44
|
-
|
|
45
|
-
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive') || 'demo',
|
|
44
|
+
ciToken: attr(image, 'responsive') || attr(image, 'data-responsive'),
|
|
46
45
|
ciFilters: attr(image, 'filters') || attr(image, 'data-filters'),
|
|
47
46
|
ciTransformation: attr(image, 'transformation') || attr(image, 'data-transformation'),
|
|
48
47
|
lazyload: isTrue(image, 'lazyload'),
|
|
@@ -51,7 +50,9 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
51
50
|
controlReverse: isTrue(image, 'control-reverse'),
|
|
52
51
|
stopAtEdges: isTrue(image, 'stop-at-edges'),
|
|
53
52
|
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'
|
|
53
|
+
logoSrc: attr(image, 'logo-src') || 'https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg',
|
|
54
|
+
containerWidth: parseInt(attr(image, 'width') || attr(image, 'data-width'), 10) || 0,
|
|
55
|
+
containerHeight: parseInt(attr(image, 'height') || attr(image, 'data-height'), 10) || 0
|
|
55
56
|
};
|
|
56
57
|
};
|
|
57
58
|
|
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.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "scaleflex",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"core-js": "^3.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@babel/core": "^7.16.5",
|
|
39
40
|
"babel-cli": "^6.26.0",
|
|
40
41
|
"babel-core": "^6.26.3",
|
|
41
42
|
"babel-loader": "^7.1.4",
|