js-cloudimage-360-view 2.7.2-beta.0 → 2.7.2-beta.1
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.constants.js +4 -1
- package/dist/ci360.service.js +47 -26
- package/dist/ci360.utils.js +1 -0
- package/package.json +1 -1
package/dist/ci360.constants.js
CHANGED
|
@@ -28,9 +28,12 @@ var AUTOPLAY_BEHAVIOR = {
|
|
|
28
28
|
var ORGINAL_SIZE_REGEX = /width=\d+|w=\d+|h=\d+|&width=\d+|&w=\d+|&h=\d+|func=\w+|\?$/g;
|
|
29
29
|
var AND_SYMBOL_REGEX = /\?&/g;
|
|
30
30
|
|
|
31
|
+
var falsyValues = [false, 0, null, undefined, 'false', "0", 'null', 'undefined'];
|
|
32
|
+
|
|
31
33
|
exports.TO_START_POINTER_ZOOM = TO_START_POINTER_ZOOM;
|
|
32
34
|
exports.MOUSE_LEAVE_ACTIONS = MOUSE_LEAVE_ACTIONS;
|
|
33
35
|
exports.ORIENTATIONS = ORIENTATIONS;
|
|
34
36
|
exports.AUTOPLAY_BEHAVIOR = AUTOPLAY_BEHAVIOR;
|
|
35
37
|
exports.ORGINAL_SIZE_REGEX = ORGINAL_SIZE_REGEX;
|
|
36
|
-
exports.AND_SYMBOL_REGEX = AND_SYMBOL_REGEX;
|
|
38
|
+
exports.AND_SYMBOL_REGEX = AND_SYMBOL_REGEX;
|
|
39
|
+
exports.falsyValues = falsyValues;
|
package/dist/ci360.service.js
CHANGED
|
@@ -691,6 +691,23 @@ var CI360Viewer = function () {
|
|
|
691
691
|
this.moveActiveYIndexDown(1);
|
|
692
692
|
this.update();
|
|
693
693
|
}
|
|
694
|
+
}, {
|
|
695
|
+
key: 'updateCanvasSize',
|
|
696
|
+
value: function updateCanvasSize(image) {
|
|
697
|
+
var imageAspectRatio = image.width / image.height;
|
|
698
|
+
var wrapperEl = this.container.parentNode;
|
|
699
|
+
|
|
700
|
+
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
701
|
+
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
702
|
+
|
|
703
|
+
if (wrapperEl.offsetHeight < image.height) {
|
|
704
|
+
this.canvas.height = wrapperEl.offsetHeight / this.devicePixelRatio;
|
|
705
|
+
this.canvas.style.height = wrapperEl.offsetHeight + 'px';
|
|
706
|
+
} else {
|
|
707
|
+
this.canvas.height = this.container.offsetWidth * this.devicePixelRatio / imageAspectRatio;
|
|
708
|
+
this.canvas.style.height = this.container.offsetWidth / imageAspectRatio + 'px';
|
|
709
|
+
}
|
|
710
|
+
}
|
|
694
711
|
}, {
|
|
695
712
|
key: 'onLoadResizedImages',
|
|
696
713
|
value: function onLoadResizedImages(orientation, event) {
|
|
@@ -699,6 +716,10 @@ var CI360Viewer = function () {
|
|
|
699
716
|
var totalAmount = this.amountX + this.amountY;
|
|
700
717
|
var totalLoadedImages = this.loadedImagesX + this.loadedImagesY;
|
|
701
718
|
|
|
719
|
+
if (this.loadedImagesX === 1 && orientation !== _ci2.ORIENTATIONS.Y) {
|
|
720
|
+
this.updateCanvasSize(event.target);
|
|
721
|
+
}
|
|
722
|
+
|
|
702
723
|
if (totalLoadedImages === totalAmount) {
|
|
703
724
|
this.replaceImages(orientation);
|
|
704
725
|
this.update();
|
|
@@ -765,12 +786,12 @@ var CI360Viewer = function () {
|
|
|
765
786
|
}, {
|
|
766
787
|
key: 'requestResizedImages',
|
|
767
788
|
value: function requestResizedImages() {
|
|
768
|
-
var srcX = this.getSrc(this.responsive, this.container, this.folder, this.filenameX, this.ciParams);
|
|
789
|
+
var srcX = this.getSrc(this.responsive, this.container, this.folder, this.apiVersion, this.filenameX, this.ciParams);
|
|
769
790
|
|
|
770
791
|
this.requestNewImages(srcX, this.amountX, _ci2.ORIENTATIONS.X);
|
|
771
792
|
|
|
772
793
|
if (this.allowSpinY) {
|
|
773
|
-
var srcY = this.getSrc(this.responsive, this.container, this.folder, this.filenameY, this.ciParams);
|
|
794
|
+
var srcY = this.getSrc(this.responsive, this.container, this.folder, this.apiVersion, this.filenameY, this.ciParams);
|
|
774
795
|
|
|
775
796
|
this.requestNewImages(srcY, this.amountY, _ci2.ORIENTATIONS.Y);
|
|
776
797
|
}
|
|
@@ -802,11 +823,6 @@ var CI360Viewer = function () {
|
|
|
802
823
|
|
|
803
824
|
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
804
825
|
} else {
|
|
805
|
-
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
806
|
-
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
807
|
-
this.canvas.height = this.container.offsetWidth * this.devicePixelRatio / image.width * image.height;
|
|
808
|
-
this.canvas.style.height = this.container.offsetWidth / image.width * image.height + 'px';
|
|
809
|
-
|
|
810
826
|
if (this.startPointerZoom || this.startPinchZoom) {
|
|
811
827
|
this.updateImageScale(ctx);
|
|
812
828
|
} else {
|
|
@@ -932,11 +948,7 @@ var CI360Viewer = function () {
|
|
|
932
948
|
}
|
|
933
949
|
|
|
934
950
|
if (this.container.offsetWidth > 0) {
|
|
935
|
-
this.
|
|
936
|
-
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
937
|
-
|
|
938
|
-
this.canvas.height = this.container.offsetWidth * this.devicePixelRatio / event.target.width * event.target.height;
|
|
939
|
-
this.canvas.style.height = this.container.offsetWidth / event.target.width * event.target.height + 'px';
|
|
951
|
+
this.updateCanvasSize(event.target);
|
|
940
952
|
}
|
|
941
953
|
|
|
942
954
|
_ctx.drawImage(imagePreview, 0, 0, this.canvas.width, this.canvas.height);
|
|
@@ -1332,16 +1344,20 @@ var CI360Viewer = function () {
|
|
|
1332
1344
|
}
|
|
1333
1345
|
}, {
|
|
1334
1346
|
key: 'getSrc',
|
|
1335
|
-
value: function getSrc(responsive, container, folder,
|
|
1336
|
-
var
|
|
1337
|
-
|
|
1338
|
-
|
|
1347
|
+
value: function getSrc(responsive, container, folder, apiVersion, filename) {
|
|
1348
|
+
var ciParams = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1349
|
+
var ciToken = ciParams.ciToken,
|
|
1350
|
+
ciFilters = ciParams.ciFilters,
|
|
1351
|
+
ciTransformation = ciParams.ciTransformation;
|
|
1339
1352
|
|
|
1340
1353
|
var src = '' + folder + filename;
|
|
1341
1354
|
|
|
1342
|
-
if (responsive) {
|
|
1355
|
+
if (!!responsive.length) {
|
|
1343
1356
|
var imageOffsetWidth = container.offsetWidth;
|
|
1344
1357
|
|
|
1358
|
+
var vesrion = _ci2.falsyValues.indexOf(apiVersion) !== -1 ? null : apiVersion;
|
|
1359
|
+
var finalApiVersion = vesrion ? vesrion + '/' : '';
|
|
1360
|
+
|
|
1345
1361
|
if (this.fullscreenView) {
|
|
1346
1362
|
var containerRatio = container.offsetHeight / container.offsetWidth;
|
|
1347
1363
|
|
|
@@ -1352,7 +1368,7 @@ var CI360Viewer = function () {
|
|
|
1352
1368
|
|
|
1353
1369
|
var ciSizeNext = (0, _ci.getSizeAccordingToPixelRatio)((0, _ci.getResponsiveWidthOfContainer)(imageOffsetWidth));
|
|
1354
1370
|
|
|
1355
|
-
src = 'https://' + ciToken + '.cloudimg.io/
|
|
1371
|
+
src = 'https://' + ciToken + '.cloudimg.io/' + finalApiVersion + src + '?' + (ciTransformation ? ciTransformation : 'width=' + ciSizeNext) + (ciFilters ? '&f=' + ciFilters : '');
|
|
1356
1372
|
}
|
|
1357
1373
|
|
|
1358
1374
|
return src;
|
|
@@ -1364,11 +1380,13 @@ var CI360Viewer = function () {
|
|
|
1364
1380
|
var lazyload = arguments[3];
|
|
1365
1381
|
var lazySelector = arguments[4];
|
|
1366
1382
|
var container = arguments[5];
|
|
1383
|
+
var responsive = arguments[6];
|
|
1384
|
+
var ciParams = arguments[7];
|
|
1367
1385
|
|
|
1368
1386
|
var _this5 = this;
|
|
1369
1387
|
|
|
1370
|
-
var
|
|
1371
|
-
var
|
|
1388
|
+
var apiVersion = arguments[8];
|
|
1389
|
+
var filename = arguments[9];
|
|
1372
1390
|
|
|
1373
1391
|
if (this.imageList) {
|
|
1374
1392
|
try {
|
|
@@ -1377,7 +1395,7 @@ var CI360Viewer = function () {
|
|
|
1377
1395
|
this.amountX = images.length;
|
|
1378
1396
|
images.forEach(function (src, index) {
|
|
1379
1397
|
var folder = /(http(s?)):\/\//gi.test(src) ? '' : _this5.folder;
|
|
1380
|
-
var resultSrc = _this5.getSrc(responsive, container, folder,
|
|
1398
|
+
var resultSrc = _this5.getSrc(responsive, container, folder, apiVersion, filename, ciParams);
|
|
1381
1399
|
var lastIndex = resultSrc.lastIndexOf('//');
|
|
1382
1400
|
var originalSrc = resultSrc.slice(lastIndex);
|
|
1383
1401
|
|
|
@@ -1591,7 +1609,7 @@ var CI360Viewer = function () {
|
|
|
1591
1609
|
|
|
1592
1610
|
window.addEventListener('resize', (0, _ci.debounce)(function () {
|
|
1593
1611
|
_this7.requestResizedImages();
|
|
1594
|
-
},
|
|
1612
|
+
}, 50));
|
|
1595
1613
|
|
|
1596
1614
|
if (draggable && !this.disableDrag) {
|
|
1597
1615
|
this.container.addEventListener('mousedown', this.mouseDown.bind(this));
|
|
@@ -1651,6 +1669,7 @@ var CI360Viewer = function () {
|
|
|
1651
1669
|
value: function init(container) {
|
|
1652
1670
|
var _get360ViewProps = (0, _ci.get360ViewProps)(container),
|
|
1653
1671
|
folder = _get360ViewProps.folder,
|
|
1672
|
+
apiVersion = _get360ViewProps.apiVersion,
|
|
1654
1673
|
filenameX = _get360ViewProps.filenameX,
|
|
1655
1674
|
filenameY = _get360ViewProps.filenameY,
|
|
1656
1675
|
imageList = _get360ViewProps.imageList,
|
|
@@ -1706,6 +1725,7 @@ var CI360Viewer = function () {
|
|
|
1706
1725
|
this.addLoader();
|
|
1707
1726
|
|
|
1708
1727
|
this.folder = folder;
|
|
1728
|
+
this.apiVersion = apiVersion;
|
|
1709
1729
|
this.filenameX = filenameX;
|
|
1710
1730
|
this.filenameY = filenameY;
|
|
1711
1731
|
this.imageList = imageList;
|
|
@@ -1746,18 +1766,19 @@ var CI360Viewer = function () {
|
|
|
1746
1766
|
this.logoSrc = logoSrc;
|
|
1747
1767
|
this.responsive = responsive;
|
|
1748
1768
|
this.ciParams = ciParams;
|
|
1769
|
+
this.apiVersion = apiVersion;
|
|
1749
1770
|
|
|
1750
1771
|
this.applyStylesToContainer();
|
|
1751
1772
|
|
|
1752
1773
|
this.addCanvas();
|
|
1753
1774
|
|
|
1754
|
-
var srcX = this.getSrc(responsive, container, folder, filenameX, ciParams);
|
|
1755
|
-
var srcY = this.getSrc(responsive, container, folder, filenameY, ciParams);
|
|
1775
|
+
var srcX = this.getSrc(responsive, container, folder, apiVersion, filenameX, ciParams);
|
|
1776
|
+
var srcY = this.getSrc(responsive, container, folder, apiVersion, filenameY, ciParams);
|
|
1756
1777
|
|
|
1757
|
-
this.preloadImages(amountX, srcX, _ci2.ORIENTATIONS.X, lazyload, lazySelector, container, responsive, ciParams);
|
|
1778
|
+
this.preloadImages(amountX, srcX, _ci2.ORIENTATIONS.X, lazyload, lazySelector, container, responsive, ciParams, apiVersion, filenameX);
|
|
1758
1779
|
|
|
1759
1780
|
if (amountY) {
|
|
1760
|
-
this.preloadImages(amountY, srcY, _ci2.ORIENTATIONS.Y, lazyload, lazySelector, container, responsive, ciParams);
|
|
1781
|
+
this.preloadImages(amountY, srcY, _ci2.ORIENTATIONS.Y, lazyload, lazySelector, container, responsive, ciParams, apiVersion, filenameY);
|
|
1761
1782
|
}
|
|
1762
1783
|
|
|
1763
1784
|
this.attachEvents(draggable, swipeable, keys);
|
package/dist/ci360.utils.js
CHANGED
|
@@ -11,6 +11,7 @@ var _ci = require('./ci360.constants');
|
|
|
11
11
|
var get360ViewProps = function get360ViewProps(image) {
|
|
12
12
|
return {
|
|
13
13
|
folder: attr(image, 'folder') || attr(image, 'data-folder') || '/',
|
|
14
|
+
apiVersion: attr(image, 'api-version') || attr(image, 'data-api-version') || attr(image, 'apiVersion') || attr(image, 'data-apiVersion') || "v7",
|
|
14
15
|
filenameX: attr(image, 'filename') || attr(image, 'data-filename') || attr(image, 'filename-x') || attr(image, 'data-filename-x') || 'image-{index}.jpg',
|
|
15
16
|
filenameY: attr(image, 'filename-y') || attr(image, 'data-filename-y') || 'image-y-{index}.jpg',
|
|
16
17
|
imageList: attr(image, 'image-list') || attr(image, 'data-image-list') || null,
|