js-cloudimage-360-view 2.7.4 → 2.7.7
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 +18 -0
- package/README.md +78 -19
- package/dist/ci360.service.js +141 -51
- package/dist/ci360.utils.js +6 -5
- package/dist/constants/image-src-props.js +8 -0
- package/dist/index.js +28 -1
- 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-src-props-changed.js +23 -0
- package/dist/utils/index.js +36 -36
- package/dist/utils/responsive/get-image-aspect-ratio.js +39 -0
- package/dist/utils/spin-y/get-moving-direction.js +1 -1
- package/package.json +2 -1
- 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/responsive/get-container-responsive-height.js +0 -20
- package/dist/utils/responsive/get-container-responsive-width.js +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -25,6 +25,24 @@ Types of changes:
|
|
|
25
25
|
- ...
|
|
26
26
|
|
|
27
27
|
-------------
|
|
28
|
+
## 2.7.7 - 2022-02-24
|
|
29
|
+
### Fixed
|
|
30
|
+
- container width on mobile
|
|
31
|
+
- re-render method
|
|
32
|
+
|
|
33
|
+
## 2.7.6 - 2022-02-20
|
|
34
|
+
### Fixed
|
|
35
|
+
- drag speed
|
|
36
|
+
- responsive canvas width and height
|
|
37
|
+
|
|
38
|
+
## 2.7.5 - 2022-02-08
|
|
39
|
+
### Added
|
|
40
|
+
- update method to re-render or re-init the plugin
|
|
41
|
+
### Fixed
|
|
42
|
+
- drag speed on mobile
|
|
43
|
+
- error when drag speed is too high
|
|
44
|
+
- error in dependencies
|
|
45
|
+
|
|
28
46
|
## 2.7.4 - 2022-01-26
|
|
29
47
|
### Fixed
|
|
30
48
|
- 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,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
|
-
<img
|
|
9
|
+
<img
|
|
11
10
|
alt="The Lounge"
|
|
12
11
|
src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
|
|
13
|
-
</a>
|
|
14
12
|
</p>
|
|
15
13
|
|
|
16
14
|
<h1 align="center">
|
|
@@ -70,7 +68,7 @@ To see the Cloudimage 360 view plugin in action, please check out the
|
|
|
70
68
|
Add script tag with CDN link to js-cloudimage-360-view lib after all content in body tag
|
|
71
69
|
|
|
72
70
|
```javascript
|
|
73
|
-
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2.7.
|
|
71
|
+
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2.7.5/js-cloudimage-360-view.min.js"></script>
|
|
74
72
|
```
|
|
75
73
|
|
|
76
74
|
## <a name="initialize"></a>Step 2: Initialize
|
|
@@ -107,6 +105,36 @@ window.CI360.init();
|
|
|
107
105
|
> <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2/js-cloudimage-360-view.min.js"></script>
|
|
108
106
|
> <script>window.CI360.init(); // initialize the plugin when you need</script>
|
|
109
107
|
> ```
|
|
108
|
+
### update
|
|
109
|
+
|
|
110
|
+
###### Type: **Function**
|
|
111
|
+
```javascript
|
|
112
|
+
window.CI360.update(idOfInstance, forceUpdate);
|
|
113
|
+
```
|
|
114
|
+
Update cloudimage 360 viewer instance.<br/>
|
|
115
|
+
For any update in source attributes after plugin initialization (e.g. `data-folder`, `data-filename-x`, `data-amount-y`),
|
|
116
|
+
the plugin will re-init.
|
|
117
|
+
### Properties
|
|
118
|
+
#### `idOfInstance`: string
|
|
119
|
+
The id of the instance
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<div
|
|
123
|
+
id="cloudimage-360-car"
|
|
124
|
+
class="cloudimage-360"
|
|
125
|
+
data-folder="https://scaleflex.airstore.io/demo/360-car/"
|
|
126
|
+
data-filename-x="iris-{index}.jpeg"
|
|
127
|
+
data-amount-x="36"
|
|
128
|
+
></div>
|
|
129
|
+
```
|
|
130
|
+
```javascript
|
|
131
|
+
window.CI360.update('cloudimage-360-car');
|
|
132
|
+
```
|
|
133
|
+
#### `forceUpdate`: bool
|
|
134
|
+
Force the plugin to re-init.
|
|
135
|
+
```javascript
|
|
136
|
+
window.CI360.update(null, true);
|
|
137
|
+
```
|
|
110
138
|
|
|
111
139
|
### destroy
|
|
112
140
|
|
|
@@ -127,8 +155,15 @@ window.CI360.destroy();
|
|
|
127
155
|
Get the {index} of the image that is being viewed.
|
|
128
156
|
|
|
129
157
|
```javascript
|
|
130
|
-
window.CI360.getActiveIndexByID(
|
|
158
|
+
window.CI360.getActiveIndexByID(idOfInstance: string, oriantation: string);
|
|
131
159
|
```
|
|
160
|
+
### Properties
|
|
161
|
+
#### `idOfInstance`: string
|
|
162
|
+
The id of the instance
|
|
163
|
+
|
|
164
|
+
#### `oriantation`: string
|
|
165
|
+
The oriantation of the active index
|
|
166
|
+
|
|
132
167
|
## <a name="customize-elements"></a> Customize elements
|
|
133
168
|
|
|
134
169
|
You can customize elements by adding the following classes:
|
|
@@ -266,25 +301,49 @@ Open 360 spin view in full screen modal.
|
|
|
266
301
|
|
|
267
302
|
Magnifier to zoom image.
|
|
268
303
|
|
|
269
|
-
###
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
###### ~~Type: **Number** (height / width) | Default: **none** | _optional_~~
|
|
304
|
+
### data-ratio (or ratio)
|
|
273
305
|
|
|
274
|
-
~~Prevents page from jumping.~~
|
|
275
|
-
### data-width (or width)
|
|
276
306
|
|
|
277
|
-
###### Type: **Number** | Default: **none** | _optional_
|
|
307
|
+
###### Type: **Number** (width / height) or JSON object | Default: **none** | _optional_
|
|
308
|
+
#### `ratio`: string
|
|
278
309
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
### data-height (or height)
|
|
310
|
+
Setting the height relative to the container width according to the provided ratio</br>
|
|
311
|
+
In the following example, the height should be 0.3 the container width
|
|
282
312
|
|
|
283
|
-
|
|
313
|
+
```html
|
|
314
|
+
<div
|
|
315
|
+
id="cloudimage-360-car"
|
|
316
|
+
class="cloudimage-360"
|
|
317
|
+
data-folder="https://scaleflex.airstore.io/demo/360-car/"
|
|
318
|
+
data-filename-x="iris-{index}.jpeg"
|
|
319
|
+
data-amount-x="36"
|
|
320
|
+
data-ratio="2"
|
|
321
|
+
></div>
|
|
322
|
+
```
|
|
323
|
+
<a href="https://codesandbox.io/s/js-cloudimage-360-view-g4wyt1?file=/index.html"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
|
|
324
|
+
#### `ratio`: JSON
|
|
325
|
+
Setting the height relative to the container width at any window size.
|
|
284
326
|
|
|
285
|
-
|
|
286
|
-
|
|
327
|
+
In the following example, the height should be 1.3 the container width at window size less than or equal to 567px
|
|
328
|
+
and 2.22 at window size less than or equal to 768px.
|
|
287
329
|
|
|
330
|
+
```html
|
|
331
|
+
<div
|
|
332
|
+
id="cloudimage-360-car"
|
|
333
|
+
class="cloudimage-360"
|
|
334
|
+
data-folder="https://scaleflex.airstore.io/demo/360-car/"
|
|
335
|
+
data-filename-x="iris-{index}.jpeg"
|
|
336
|
+
data-amount-x="36"
|
|
337
|
+
data-ratio='{
|
|
338
|
+
"576": "1.3",
|
|
339
|
+
"768": "2.22",
|
|
340
|
+
"992": "2.23",
|
|
341
|
+
"1200": "3",
|
|
342
|
+
"2400": "3.2"
|
|
343
|
+
}'
|
|
344
|
+
></div>
|
|
345
|
+
```
|
|
346
|
+
<a href="https://codesandbox.io/s/js-cloudimage-360-view-5tssb7?file=/index.html"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
|
|
288
347
|
### data-autoplay-reverse (or autoplay-reverse)
|
|
289
348
|
|
|
290
349
|
###### Type: **Bool** | Default: **false** | _optional_
|
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",
|
|
@@ -175,6 +182,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
175
182
|
if (this.pointerZoom && this.mouseTracked) {
|
|
176
183
|
this.togglePointerZoom();
|
|
177
184
|
}
|
|
185
|
+
|
|
186
|
+
if (this.isMagnifyOpen) {
|
|
187
|
+
this.closeMagnifier();
|
|
188
|
+
}
|
|
178
189
|
}
|
|
179
190
|
}, {
|
|
180
191
|
key: "togglePointerZoom",
|
|
@@ -211,6 +222,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
211
222
|
|
|
212
223
|
var _zoomSteps = (0, _utils.generateZoomInSteps)(this.pointerZoom);
|
|
213
224
|
|
|
225
|
+
if (this.hotspotConfig) {
|
|
226
|
+
(0, _utils.hideHotspotsIcons)();
|
|
227
|
+
}
|
|
228
|
+
|
|
214
229
|
_zoomSteps.forEach(function (step) {
|
|
215
230
|
setTimeout(function () {
|
|
216
231
|
_this2.zoomIntensity = step;
|
|
@@ -269,6 +284,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
269
284
|
key: "touchStart",
|
|
270
285
|
value: function touchStart(event) {
|
|
271
286
|
if (!this.imagesLoaded) return;
|
|
287
|
+
var isMouseOnHotspotElement = (0, _utils.isMouseOnHotspot)();
|
|
272
288
|
this.hideInitialIcons();
|
|
273
289
|
|
|
274
290
|
if (this.autoplay || this.loopTimeoutId) {
|
|
@@ -285,6 +301,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
285
301
|
y: event.touches[0].clientY
|
|
286
302
|
};
|
|
287
303
|
this.isClicked = true;
|
|
304
|
+
|
|
305
|
+
if (isMouseOnHotspotElement) {
|
|
306
|
+
this.isClicked = false;
|
|
307
|
+
}
|
|
288
308
|
}
|
|
289
309
|
}, {
|
|
290
310
|
key: "touchEnd",
|
|
@@ -302,11 +322,16 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
302
322
|
key: "touchMove",
|
|
303
323
|
value: function touchMove(event) {
|
|
304
324
|
if (!this.isClicked || !this.imagesLoaded) return;
|
|
325
|
+
|
|
326
|
+
if (event.cancelable) {
|
|
327
|
+
event.preventDefault();
|
|
328
|
+
}
|
|
329
|
+
|
|
305
330
|
var nextPositions = {
|
|
306
331
|
x: event.touches[0].clientX,
|
|
307
332
|
y: event.touches[0].clientY
|
|
308
333
|
};
|
|
309
|
-
this.movingDirection = (0, _utils.getMovingDirection)(this.isStartSpin, this.allowSpinY, this.intialPositions, nextPositions);
|
|
334
|
+
this.movingDirection = (0, _utils.getMovingDirection)(this.isStartSpin, this.allowSpinY, this.intialPositions, nextPositions, this.movingDirection);
|
|
310
335
|
this.onMoveHandler(event);
|
|
311
336
|
}
|
|
312
337
|
}, {
|
|
@@ -630,13 +655,9 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
630
655
|
(0, _utils.loop)(this.autoplayBehavior, this.spinY, reversed, loopTriggers);
|
|
631
656
|
}
|
|
632
657
|
}, {
|
|
633
|
-
key: "
|
|
634
|
-
value: function
|
|
635
|
-
var
|
|
636
|
-
var imageAspectRatio = image.width / image.height;
|
|
637
|
-
var isProvidedHeightLessThanWidth = this.containerHeight < this.containerWidth;
|
|
638
|
-
var containerWidth = (0, _utils.getContainerResponsiveWidth)(parentEl, this.containerWidth);
|
|
639
|
-
var containerHeight = (0, _utils.getContainerResponsiveHeight)(this.container, containerWidth, this.containerHeight);
|
|
658
|
+
key: "updateContainerAndCanvasSize",
|
|
659
|
+
value: function updateContainerAndCanvasSize(image) {
|
|
660
|
+
var imageAspectRatio = (0, _utils.getImageAspectRatio)(image, this.ratio);
|
|
640
661
|
|
|
641
662
|
if (this.fullscreenView) {
|
|
642
663
|
this.container.width = window.innerWidth * this.devicePixelRatio;
|
|
@@ -647,24 +668,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
647
668
|
return;
|
|
648
669
|
}
|
|
649
670
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
if (!this.containerWidth && !this.containerHeight) {
|
|
657
|
-
this.container.style.height = containerHeight / imageAspectRatio + 'px';
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
if ((isProvidedHeightLessThanWidth || !this.containerWidth) && this.containerHeight) {
|
|
662
|
-
this.container.style.maxWidth = containerHeight * imageAspectRatio + 'px';
|
|
663
|
-
this.container.style.height = containerHeight + 'px';
|
|
664
|
-
} else {
|
|
665
|
-
this.container.style.maxWidth = containerWidth + 'px';
|
|
666
|
-
this.container.style.height = containerWidth / imageAspectRatio + 'px';
|
|
667
|
-
}
|
|
671
|
+
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
672
|
+
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
673
|
+
this.canvas.height = this.container.offsetWidth / imageAspectRatio * this.devicePixelRatio;
|
|
674
|
+
this.canvas.style.height = this.container.offsetWidth / imageAspectRatio + 'px';
|
|
668
675
|
}
|
|
669
676
|
}, {
|
|
670
677
|
key: "onResizedImageLoad",
|
|
@@ -689,12 +696,23 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
689
696
|
this.update();
|
|
690
697
|
}
|
|
691
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
|
+
}
|
|
692
711
|
}, {
|
|
693
712
|
key: "requestResizedImages",
|
|
694
713
|
value: function requestResizedImages() {
|
|
695
714
|
var responsive = this.ciParams.ciToken;
|
|
696
715
|
var firstImage = this.imagesX[0];
|
|
697
|
-
this.updateContainerSize(firstImage);
|
|
698
716
|
this.update();
|
|
699
717
|
this.speedFactor = (0, _utils.getSpeedFactor)(this.dragSpeed, this.amountX, this.container.offsetWidth);
|
|
700
718
|
var srcX = (0, _utils.generateImagesPath)(this.srcXConfig);
|
|
@@ -717,10 +735,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
717
735
|
|
|
718
736
|
var ctx = this.canvas.getContext("2d");
|
|
719
737
|
ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
|
|
720
|
-
this.
|
|
721
|
-
this.canvas.style.width = this.container.offsetWidth + 'px';
|
|
722
|
-
this.canvas.height = this.container.offsetHeight * this.devicePixelRatio;
|
|
723
|
-
this.canvas.style.height = this.container.offsetHeight + 'px';
|
|
738
|
+
this.updateContainerAndCanvasSize(image);
|
|
724
739
|
|
|
725
740
|
if (this.fullscreenView) {
|
|
726
741
|
var _contain = (0, _utils.contain)(this.canvas.width, this.canvas.height, image.width, image.height),
|
|
@@ -734,9 +749,17 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
734
749
|
if (this.mouseTracked) {
|
|
735
750
|
this.updateImageScale(ctx);
|
|
736
751
|
} else {
|
|
752
|
+
if (this.hotspotConfig && !this.autoplay) {
|
|
753
|
+
(0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
|
|
754
|
+
}
|
|
755
|
+
|
|
737
756
|
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
738
757
|
}
|
|
739
758
|
}
|
|
759
|
+
|
|
760
|
+
if (this.info) {
|
|
761
|
+
this.showImageInfo(ctx);
|
|
762
|
+
}
|
|
740
763
|
}
|
|
741
764
|
}, {
|
|
742
765
|
key: "updateImageScale",
|
|
@@ -789,6 +812,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
789
812
|
x: offsetX,
|
|
790
813
|
y: offsetY
|
|
791
814
|
};
|
|
815
|
+
this.addCloseFullscreenView();
|
|
792
816
|
ctx.drawImage(image, offsetX, offsetY, width, height);
|
|
793
817
|
} else {
|
|
794
818
|
this.canvas.width = this.container.offsetWidth * this.devicePixelRatio;
|
|
@@ -798,8 +822,8 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
798
822
|
ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
|
|
799
823
|
}
|
|
800
824
|
|
|
801
|
-
if (this.
|
|
802
|
-
this.
|
|
825
|
+
if (this.info) {
|
|
826
|
+
this.showImageInfo(ctx);
|
|
803
827
|
}
|
|
804
828
|
|
|
805
829
|
if (this.magnifier) {
|
|
@@ -807,7 +831,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
807
831
|
}
|
|
808
832
|
|
|
809
833
|
if (this.boxShadow && !this.fullscreenView) {
|
|
810
|
-
(0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
834
|
+
this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
811
835
|
}
|
|
812
836
|
|
|
813
837
|
if (this.bottomCircle && !this.fullscreenView) {
|
|
@@ -817,6 +841,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
817
841
|
if (this.fullscreen && !this.fullscreenView) {
|
|
818
842
|
this.addFullscreenIcon();
|
|
819
843
|
}
|
|
844
|
+
|
|
845
|
+
if (this.hotspotConfig && !this.autoplay) {
|
|
846
|
+
(0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
|
|
847
|
+
}
|
|
820
848
|
}
|
|
821
849
|
}, {
|
|
822
850
|
key: "onAllImagesLoaded",
|
|
@@ -883,7 +911,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
883
911
|
event.stopPropagation();
|
|
884
912
|
if (this.mouseTracked) this.togglePointerZoom();
|
|
885
913
|
var fullscreenContainer = (0, _utils.createFullscreenModal)(this.container);
|
|
886
|
-
new CI360Viewer(fullscreenContainer, true);
|
|
914
|
+
new CI360Viewer(fullscreenContainer, true, this.hotspotConfig);
|
|
887
915
|
}
|
|
888
916
|
}, {
|
|
889
917
|
key: "setFullscreenEvents",
|
|
@@ -927,6 +955,21 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
927
955
|
if (this.bottomCircle) this.show360ViewCircleIcon();
|
|
928
956
|
window.clearTimeout(this.loopTimeoutId);
|
|
929
957
|
}
|
|
958
|
+
}, {
|
|
959
|
+
key: "updatePlugin",
|
|
960
|
+
value: function updatePlugin(forceUpdate) {
|
|
961
|
+
var container = this.container;
|
|
962
|
+
var imageProps = (0, _ci.get360ViewProps)(container);
|
|
963
|
+
var srcPropsChanged = (0, _utils.isSrcPropsChanged)(this, imageProps);
|
|
964
|
+
var reloadPlugin = srcPropsChanged || forceUpdate;
|
|
965
|
+
container.style.position = 'relative';
|
|
966
|
+
container.style.width = '100%';
|
|
967
|
+
container.style.cursor = 'default';
|
|
968
|
+
container.setAttribute('draggable', 'false');
|
|
969
|
+
if (reloadPlugin) container.innerHTML = '';
|
|
970
|
+
this.stop();
|
|
971
|
+
this.init(container, !reloadPlugin, reloadPlugin);
|
|
972
|
+
}
|
|
930
973
|
}, {
|
|
931
974
|
key: "destroy",
|
|
932
975
|
value: function destroy() {
|
|
@@ -1133,9 +1176,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1133
1176
|
passive: true
|
|
1134
1177
|
});
|
|
1135
1178
|
this.container.addEventListener('touchend', this.touchEnd.bind(this));
|
|
1136
|
-
this.container.addEventListener('touchmove', this.touchMove.bind(this)
|
|
1137
|
-
passive: true
|
|
1138
|
-
});
|
|
1179
|
+
this.container.addEventListener('touchmove', this.touchMove.bind(this));
|
|
1139
1180
|
}
|
|
1140
1181
|
|
|
1141
1182
|
if (keys) {
|
|
@@ -1150,6 +1191,9 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1150
1191
|
value: function init(container) {
|
|
1151
1192
|
var _this6 = this;
|
|
1152
1193
|
|
|
1194
|
+
var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1195
|
+
var reload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1196
|
+
|
|
1153
1197
|
var _get360ViewProps = (0, _ci.get360ViewProps)(container),
|
|
1154
1198
|
folder = _get360ViewProps.folder,
|
|
1155
1199
|
apiVersion = _get360ViewProps.apiVersion,
|
|
@@ -1160,7 +1204,6 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1160
1204
|
indexZeroBase = _get360ViewProps.indexZeroBase,
|
|
1161
1205
|
amountX = _get360ViewProps.amountX,
|
|
1162
1206
|
amountY = _get360ViewProps.amountY,
|
|
1163
|
-
imageOffset = _get360ViewProps.imageOffset,
|
|
1164
1207
|
_get360ViewProps$drag = _get360ViewProps.draggable,
|
|
1165
1208
|
draggable = _get360ViewProps$drag === void 0 ? true : _get360ViewProps$drag,
|
|
1166
1209
|
_get360ViewProps$swip = _get360ViewProps.swipeable,
|
|
@@ -1190,9 +1233,10 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1190
1233
|
controlReverse = _get360ViewProps.controlReverse,
|
|
1191
1234
|
hide360Logo = _get360ViewProps.hide360Logo,
|
|
1192
1235
|
logoSrc = _get360ViewProps.logoSrc,
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1236
|
+
pointerZoom = _get360ViewProps.pointerZoom,
|
|
1237
|
+
ratio = _get360ViewProps.ratio,
|
|
1238
|
+
_get360ViewProps$imag = _get360ViewProps.imageInfo,
|
|
1239
|
+
imageInfo = _get360ViewProps$imag === void 0 ? 'black' : _get360ViewProps$imag;
|
|
1196
1240
|
|
|
1197
1241
|
var ciParams = {
|
|
1198
1242
|
ciToken: ciToken,
|
|
@@ -1212,7 +1256,6 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1212
1256
|
this.activeImageX = autoplayReverse ? this.amountX : 1;
|
|
1213
1257
|
this.activeImageY = autoplayReverse ? this.amountY : 1;
|
|
1214
1258
|
this.spinY = autoplayBehavior === _constants.AUTOPLAY_BEHAVIOR.SPIN_YX ? true : false;
|
|
1215
|
-
this.imageOffset = imageOffset;
|
|
1216
1259
|
this.bottomCircle = bottomCircle;
|
|
1217
1260
|
this.bottomCircleOffset = bottomCircleOffset;
|
|
1218
1261
|
this.boxShadow = boxShadow;
|
|
@@ -1223,27 +1266,74 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1223
1266
|
this.reversed = autoplayReverse;
|
|
1224
1267
|
this.disableDrag = disableDrag;
|
|
1225
1268
|
this.fullscreen = fullscreen;
|
|
1226
|
-
this.magnifier = !this.isMobile && magnifier ? magnifier :
|
|
1269
|
+
this.magnifier = !this.isMobile && magnifier > 1 ? Math.min(magnifier, 5) : 0;
|
|
1227
1270
|
this.lazyloadX = lazyload;
|
|
1228
1271
|
this.lazyloadY = lazyload;
|
|
1229
1272
|
this.lazySelector = lazySelector;
|
|
1230
1273
|
this.spinReverse = spinReverse;
|
|
1231
1274
|
this.controlReverse = controlReverse;
|
|
1232
|
-
this.dragSpeed = dragSpeed;
|
|
1275
|
+
this.dragSpeed = Math.max(dragSpeed, 50);
|
|
1233
1276
|
this.autoplaySpeed = this.speed * 36 / this.amountX;
|
|
1234
1277
|
this.stopAtEdges = stopAtEdges;
|
|
1235
1278
|
this.hide360Logo = hide360Logo;
|
|
1236
1279
|
this.logoSrc = logoSrc;
|
|
1237
1280
|
this.ciParams = ciParams;
|
|
1238
1281
|
this.apiVersion = apiVersion;
|
|
1239
|
-
this.containerWidth = containerWidth;
|
|
1240
|
-
this.containerHeight = containerHeight;
|
|
1241
1282
|
this.pointerZoom = pointerZoom > 1 ? Math.min(pointerZoom, 3) : 0;
|
|
1242
1283
|
this.keysReverse = keysReverse;
|
|
1284
|
+
this.info = imageInfo;
|
|
1285
|
+
this.ratio = ratio && JSON.parse(ratio);
|
|
1286
|
+
|
|
1287
|
+
if (reload) {
|
|
1288
|
+
new CI360Viewer(this.container);
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
if (update) {
|
|
1293
|
+
(0, _utils.removeChildFromParent)(this.innerBox, this.iconsContainer);
|
|
1294
|
+
(0, _utils.removeChildFromParent)(this.innerBox, this.boxShadowEl);
|
|
1295
|
+
(0, _utils.removeChildFromParent)(this.innerBox, this.view360Icon);
|
|
1296
|
+
this.remove360ViewCircleIcon();
|
|
1297
|
+
this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
|
|
1298
|
+
|
|
1299
|
+
if (!this.hide360Logo && !this.lazyload && this.logoSrc) {
|
|
1300
|
+
this.add360ViewIcon();
|
|
1301
|
+
(0, _ci.setView360Icon)(this.view360Icon, this.logoSrc);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
if (this.magnifier) {
|
|
1305
|
+
this.addMagnifier();
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
if (this.info) {
|
|
1309
|
+
this.showImageInfo(ctx);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
if (this.bottomCircle && !this.fullscreenView) {
|
|
1313
|
+
this.add360ViewCircleIcon();
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
if (this.fullscreen && !this.fullscreenView) {
|
|
1317
|
+
this.addFullscreenIcon();
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
if (this.boxShadow && !this.fullscreenView) {
|
|
1321
|
+
this.boxShadowEl = (0, _utils.createBoxShadow)(this.boxShadow, this.innerBox);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
this.onAllImagesLoaded();
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1243
1328
|
this.innerBox = (0, _utils.createInnerBox)(this.container);
|
|
1244
1329
|
this.iconsContainer = (0, _utils.createIconsContainer)(this.innerBox);
|
|
1245
1330
|
this.canvas = (0, _utils.createCanvas)(this.innerBox);
|
|
1246
1331
|
this.loader = (0, _utils.createLoader)(this.innerBox);
|
|
1332
|
+
|
|
1333
|
+
if (this.hotspotConfig && !this.fullscreenView) {
|
|
1334
|
+
(0, _utils.createHotspots)(container, this.hotspotConfig);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1247
1337
|
(0, _utils.applyStylesToContainer)(this.container);
|
|
1248
1338
|
this.srcXConfig = {
|
|
1249
1339
|
folder: folder,
|
|
@@ -1313,7 +1403,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1313
1403
|
if (_this6.lazyloadX || _this6.lazyloadY) return initLazyload(image, orientation);
|
|
1314
1404
|
|
|
1315
1405
|
if (isFirstImageLoaded) {
|
|
1316
|
-
_this6.
|
|
1406
|
+
_this6.updateContainerAndCanvasSize(image);
|
|
1317
1407
|
|
|
1318
1408
|
_this6.onFirstImageLoaded(image);
|
|
1319
1409
|
}
|
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
|
|
|
@@ -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'),
|
|
@@ -47,8 +46,8 @@ var get360ViewProps = function get360ViewProps(image) {
|
|
|
47
46
|
stopAtEdges: isTrue(image, 'stop-at-edges'),
|
|
48
47
|
hide360Logo: isTrue(image, 'hide-360-logo'),
|
|
49
48
|
logoSrc: attr(image, 'logo-src') || 'https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg',
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
ratio: attr(image, 'ratio') || attr(image, 'data-ratio') || null,
|
|
50
|
+
imageInfo: attr(image, 'info') || attr(image, 'data-info') || isTrue(image, 'info')
|
|
52
51
|
};
|
|
53
52
|
};
|
|
54
53
|
|
|
@@ -64,6 +63,8 @@ var attr = function attr(element, attribute) {
|
|
|
64
63
|
return element.getAttribute(attribute);
|
|
65
64
|
};
|
|
66
65
|
|
|
66
|
+
exports.attr = attr;
|
|
67
|
+
|
|
67
68
|
var setView360Icon = function setView360Icon(view360Icon, logoSrc) {
|
|
68
69
|
view360Icon.style.background = "rgba(255,255,255,0.8) url('".concat(logoSrc, "') 50% 50% / contain no-repeat");
|
|
69
70
|
};
|
|
@@ -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;
|