js-cloudimage-360-view 2.7.12 → 3.0.0
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 +206 -88
- package/dist/ci360.service.js +16 -5
- package/dist/static/css/hotspots.css +8 -3
- package/dist/static/css/style.css +2 -0
- package/dist/utils/hotspots/elements/create-carousel-image.js +3 -2
- package/dist/utils/hotspots/elements/create-images-carousel.js +3 -3
- package/dist/utils/hotspots/elements/create-popup.js +7 -3
- package/dist/utils/hotspots/fill-empty-coord-with-previous.js +3 -3
- package/dist/utils/hotspots/generate-hotspots-configs.js +3 -3
- package/dist/utils/hotspots/generate-popup-config.js +1 -1
- package/dist/utils/hotspots/prepare-hotspots-positions.js +4 -4
- package/dist/utils/hotspots/update-hotspots.js +2 -2
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -25,6 +25,14 @@ Types of changes:
|
|
|
25
25
|
- ...
|
|
26
26
|
|
|
27
27
|
-------------
|
|
28
|
+
## 3.0.0 - 2022-03-25
|
|
29
|
+
### Added
|
|
30
|
+
- possiblity to add makers or hotspots to each image
|
|
31
|
+
- possiblity add views after init the plugin
|
|
32
|
+
- possiblity to update views
|
|
33
|
+
### Fixed
|
|
34
|
+
- hide 360 logo after play once
|
|
35
|
+
|
|
28
36
|
## 2.7.12 - 2022-03-19
|
|
29
37
|
### Changed
|
|
30
38
|
- hotspots init method
|
package/README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
[](https://github.com/scaleflex/js-cloudimage-360-view/releases)
|
|
2
3
|
[](#contributing)
|
|
3
4
|
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](https://www.scaleflex.
|
|
5
|
+
[](https://www.scaleflex.com/en/home)
|
|
5
6
|
|
|
6
7
|
[](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
8
|
|
|
8
9
|
<p align="center">
|
|
9
|
-
<img
|
|
10
|
+
<img
|
|
10
11
|
alt="The Lounge"
|
|
11
12
|
src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
|
|
12
13
|
</p>
|
|
@@ -30,15 +31,14 @@
|
|
|
30
31
|
</p>
|
|
31
32
|
|
|
32
33
|
A simple, interactive resource that can be used to provide a virtual tour of your product.
|
|
33
|
-
|
|
34
|
-
<p align="center">
|
|
34
|
+
<p align="left">
|
|
35
35
|
<img
|
|
36
36
|
alt="The Lounge"
|
|
37
|
-
src="https://scaleflex.
|
|
37
|
+
src="https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/demo-min.gif?vh=ecac07">
|
|
38
38
|
</p>
|
|
39
39
|
|
|
40
40
|
powered by [Cloudimage](https://www.cloudimage.io/)
|
|
41
|
-
([Watch the video here](https://www.youtube.com/watch?
|
|
41
|
+
([Watch the video here](https://www.youtube.com/watch?v=tk4j_MpqvM8))
|
|
42
42
|
|
|
43
43
|
## <a name="table_of_contents"></a>Table of contents
|
|
44
44
|
|
|
@@ -49,6 +49,7 @@ powered by [Cloudimage](https://www.cloudimage.io/)
|
|
|
49
49
|
* [Customize elements](#customize-elements)
|
|
50
50
|
* [Configuration](#configuration)
|
|
51
51
|
* [Controls](#controls)
|
|
52
|
+
* [Hotspots](#hotspots)
|
|
52
53
|
* [Cloudimage responsive integration](#cloudimage-responsive-integration)
|
|
53
54
|
* [Lazy loading integration](#lazy-loading)
|
|
54
55
|
* [Best practices](#best-practices)
|
|
@@ -68,7 +69,7 @@ To see the Cloudimage 360 view plugin in action, please check out the
|
|
|
68
69
|
Add script tag with CDN link to js-cloudimage-360-view lib after all content in body tag
|
|
69
70
|
|
|
70
71
|
```javascript
|
|
71
|
-
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/
|
|
72
|
+
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/3.0.0/js-cloudimage-360-view.min.js"></script>
|
|
72
73
|
```
|
|
73
74
|
|
|
74
75
|
## <a name="initialize"></a>Step 2: Initialize
|
|
@@ -79,9 +80,10 @@ After adding the js-cloudimage-360-view lib, simply initialize it with **class n
|
|
|
79
80
|
```html
|
|
80
81
|
<div
|
|
81
82
|
class="cloudimage-360"
|
|
82
|
-
|
|
83
|
-
data-
|
|
84
|
-
data-
|
|
83
|
+
id="gurkha-suv"
|
|
84
|
+
data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
|
|
85
|
+
data-filename-x="orange-{index}.jpg"
|
|
86
|
+
data-amount-x="73"
|
|
85
87
|
></div>
|
|
86
88
|
```
|
|
87
89
|
|
|
@@ -102,7 +104,7 @@ window.CI360.init();
|
|
|
102
104
|
> NOTE: initialization of the plugin runs on the script load. In case you need to postpone the initialization of the plugin you can disable it with **notInitOnLoad** param
|
|
103
105
|
> ```javascript
|
|
104
106
|
> <script>window.CI360 = { notInitOnLoad: true }</script>
|
|
105
|
-
> <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/
|
|
107
|
+
> <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/3.0.0/js-cloudimage-360-view.min.js"></script>
|
|
106
108
|
> <script>window.CI360.init(); // initialize the plugin when you need</script>
|
|
107
109
|
> ```
|
|
108
110
|
|
|
@@ -110,39 +112,42 @@ window.CI360.init();
|
|
|
110
112
|
|
|
111
113
|
###### Type: **Function**
|
|
112
114
|
|
|
113
|
-
add new view by id to cloudimage 360 views.
|
|
114
|
-
|
|
115
115
|
```javascript
|
|
116
|
-
window.CI360.add(
|
|
116
|
+
window.CI360.add(idOftheView: string);
|
|
117
117
|
```
|
|
118
|
+
lazy init cloudimage-360 view by id.
|
|
119
|
+
### Properties
|
|
120
|
+
#### `idOftheView`: string
|
|
121
|
+
The id of the new view
|
|
118
122
|
|
|
119
123
|
### update
|
|
120
124
|
|
|
121
125
|
###### Type: **Function**
|
|
122
126
|
```javascript
|
|
123
|
-
window.CI360.update(
|
|
127
|
+
window.CI360.update(idOftheView, forceUpdate);
|
|
124
128
|
```
|
|
125
129
|
Update cloudimage 360 viewer instance.<br/>
|
|
126
130
|
For any update in source attributes after plugin initialization (e.g. `data-folder`, `data-filename-x`, `data-amount-y`),
|
|
127
131
|
the plugin will re-init.
|
|
128
132
|
### Properties
|
|
129
|
-
#### `
|
|
130
|
-
The id of the
|
|
133
|
+
#### `idOftheView`: string
|
|
134
|
+
The id of the new view
|
|
135
|
+
#### `forceUpdate`: bool
|
|
136
|
+
Force the view to reinitialize.
|
|
131
137
|
|
|
132
138
|
```html
|
|
133
139
|
<div
|
|
134
|
-
id="cloudimage-360-car"
|
|
135
140
|
class="cloudimage-360"
|
|
136
|
-
|
|
137
|
-
data-
|
|
138
|
-
data-
|
|
141
|
+
id="gurkha-suv"
|
|
142
|
+
data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
|
|
143
|
+
data-filename-x="orange-{index}.jpg"
|
|
144
|
+
data-amount-x="73"
|
|
139
145
|
></div>
|
|
140
146
|
```
|
|
141
147
|
```javascript
|
|
142
|
-
window.CI360.update('
|
|
148
|
+
window.CI360.update('gurkha-suv');
|
|
143
149
|
```
|
|
144
|
-
|
|
145
|
-
Force the plugin to re-init.
|
|
150
|
+
|
|
146
151
|
```javascript
|
|
147
152
|
window.CI360.update(null, true);
|
|
148
153
|
```
|
|
@@ -242,7 +247,6 @@ data-api-version="v7"
|
|
|
242
247
|
data-api-version="null"
|
|
243
248
|
```
|
|
244
249
|
### data-filename-x (or filename-x)
|
|
245
|
-
### ~~data-filename (or filename)~~ [deprecated]
|
|
246
250
|
|
|
247
251
|
###### Type: **String** | Default: **image-{index}.jpg** | _optional_
|
|
248
252
|
|
|
@@ -251,15 +255,12 @@ The filename pattern for your 360 image. Must include {index}, which the library
|
|
|
251
255
|
### data-filename-y (or filename-y)
|
|
252
256
|
|
|
253
257
|
###### Type: **String** | Default: **image-y-{index}.jpg** | _optional_
|
|
254
|
-
|
|
255
|
-
The filename pattern for y-oriantation images. Must include {index}, which the library will replace with a number between 1 and [data-amount-y](#data-amount-y).
|
|
256
|
-
|
|
258
|
+
The same for [data-amount-x](#data-amount-x) but for images set in Y-axis.
|
|
257
259
|
|
|
258
260
|
### <a name="data-amount-x"></a> data-amount-x (or amount-x)
|
|
259
|
-
### ~~data-amount (or amount-x)~~ [deprecated]
|
|
260
261
|
###### Type: **Number** | Default: **36** | _optional_
|
|
261
262
|
|
|
262
|
-
Amount of images to load for 360 view.
|
|
263
|
+
Amount of images to load in X-axis for 360 view .
|
|
263
264
|
|
|
264
265
|
### <a name="data-amount-y"></a> data-amount-y (or amount-y)
|
|
265
266
|
|
|
@@ -300,7 +301,6 @@ Changing autoplay behavior
|
|
|
300
301
|
Available behaviors (spin-x, spin-y, spin-xy, spin-yx)
|
|
301
302
|
|
|
302
303
|
### data-fullscreen (or fullscreen)
|
|
303
|
-
### ~~data-full-screen (or full-screen)~~ [deprecated]
|
|
304
304
|
###### Type: **Bool** | Default: **false** | _optional_
|
|
305
305
|
|
|
306
306
|
Open 360 spin view in full screen modal.
|
|
@@ -312,22 +312,19 @@ Open 360 spin view in full screen modal.
|
|
|
312
312
|
Magnifier to zoom image.
|
|
313
313
|
|
|
314
314
|
### data-ratio (or ratio)
|
|
315
|
-
|
|
316
|
-
|
|
317
315
|
###### Type: **Number** (width / height) or JSON object | Default: **none** | _optional_
|
|
318
316
|
#### `ratio`: string
|
|
319
317
|
|
|
320
318
|
Setting the height relative to the container width according to the provided ratio</br>
|
|
321
|
-
In the following example, the height should be 0.3 the container width
|
|
322
319
|
|
|
323
320
|
```html
|
|
324
321
|
<div
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
322
|
+
class="cloudimage-360"
|
|
323
|
+
id="gurkha-suv"
|
|
324
|
+
data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
|
|
325
|
+
data-filename-x="orange-{index}.jpg"
|
|
326
|
+
data-amount-x="73"
|
|
327
|
+
data-ratio="2"
|
|
331
328
|
></div>
|
|
332
329
|
```
|
|
333
330
|
<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>
|
|
@@ -339,21 +336,22 @@ and 2.22 at window size less than or equal to 768px.
|
|
|
339
336
|
|
|
340
337
|
```html
|
|
341
338
|
<div
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
339
|
+
class="cloudimage-360"
|
|
340
|
+
id="gurkha-suv"
|
|
341
|
+
data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
|
|
342
|
+
data-filename-x="orange-{index}.jpg"
|
|
343
|
+
data-amount-x="73"
|
|
344
|
+
data-ratio='{
|
|
345
|
+
"576": "1.3",
|
|
346
|
+
"768": "2.22",
|
|
347
|
+
"992": "2.23",
|
|
348
|
+
"1200": "3",
|
|
349
|
+
"2400": "3.2"
|
|
350
|
+
}'
|
|
354
351
|
></div>
|
|
355
352
|
```
|
|
356
353
|
<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>
|
|
354
|
+
|
|
357
355
|
### data-autoplay-reverse (or autoplay-reverse)
|
|
358
356
|
|
|
359
357
|
###### Type: **Bool** | Default: **false** | _optional_
|
|
@@ -402,13 +400,6 @@ Display 360 view line at the bottom of container.
|
|
|
402
400
|
|
|
403
401
|
Hide 360 view icon.
|
|
404
402
|
|
|
405
|
-
### ~~data-logo-src (or logo-src)~~ [deprecated]
|
|
406
|
-
|
|
407
|
-
###### ~~Type: **String** | Default: **https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg** | _optional_~~
|
|
408
|
-
|
|
409
|
-
~~URL of asset to use as the 360 view icon.~~
|
|
410
|
-
|
|
411
|
-
kindly read [Customize elements](#customize-elements)
|
|
412
403
|
### data-control-reverse (or control-reverse)
|
|
413
404
|
|
|
414
405
|
###### Type: **Bool** | Default: **false** | _optional_
|
|
@@ -434,8 +425,6 @@ Bottom offset for 360 view line.
|
|
|
434
425
|
Left zero padding on filename. For example: index-zero-base="4" => image index will be "0004"
|
|
435
426
|
|
|
436
427
|
### data-image-list-x (or data-image-list-x)
|
|
437
|
-
### ~~data-image-list (or image-list)~~ [deprecated]
|
|
438
|
-
|
|
439
428
|
###### Type: **Array** | _optional_
|
|
440
429
|
|
|
441
430
|
Option to add list of images in x-oriantation instead of `folder` , `filename-x` & `amount-x`.
|
|
@@ -451,6 +440,7 @@ data-image-list-x='[
|
|
|
451
440
|
"https://scaleflex.airstore.io/demo/360-car/iris-15.jpeg"
|
|
452
441
|
]’
|
|
453
442
|
```
|
|
443
|
+
|
|
454
444
|
### data-image-list-y (or data-image-list-y)
|
|
455
445
|
|
|
456
446
|
###### Type: **Array** | _optional_
|
|
@@ -472,14 +462,13 @@ data-image-list-y='[
|
|
|
472
462
|
|
|
473
463
|
###### Type: **Number** | Default: **none** | _optional_
|
|
474
464
|
|
|
475
|
-
|
|
465
|
+
Option to scale images on click on it to provided value.
|
|
476
466
|
|
|
477
467
|
example:
|
|
478
468
|
|
|
479
469
|
```javascript
|
|
480
470
|
data-pointer-zoom="3"
|
|
481
471
|
```
|
|
482
|
-
when mouse clicked the image scale will be multiplied by 3.
|
|
483
472
|
|
|
484
473
|
### data-lazyload (or lazyload)
|
|
485
474
|
|
|
@@ -495,7 +484,7 @@ Helper class to apply lazy-loading depending on library you choose, see [Lazy lo
|
|
|
495
484
|
|
|
496
485
|
## <a name="controls"></a> Controls
|
|
497
486
|
|
|
498
|
-
You can add controls by adding elements with the following classes: **cloudimage-360-left**, **cloudimage-360-right**, **cloudimage-360-top**, **cloudimage-360-bottom
|
|
487
|
+
You can add controls by adding elements with the following classes: **cloudimage-360-left**, **cloudimage-360-right**, **cloudimage-360-top**, **cloudimage-360-bottom
|
|
499
488
|
|
|
500
489
|
### Example CSS
|
|
501
490
|
```css
|
|
@@ -555,6 +544,157 @@ You can add controls by adding elements with the following classes: **cloudimage
|
|
|
555
544
|
```
|
|
556
545
|
|
|
557
546
|
<a href="https://codesandbox.io/s/js-cloudimage-360-view-361eb?fontsize=14"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
|
|
547
|
+
## <a name="hotspots"/> Hotspots or Markers
|
|
548
|
+
Display information about the product on specific areas. Once a hotspot is created it can be used on more than one image.
|
|
549
|
+
### Requirements
|
|
550
|
+
First, we need to set `data-hotspots` attribute to the view we want to add hotspots or markers on it, to prevent the plugin to init the view without hotspots config.
|
|
551
|
+
Also we need to set an `id` attribute, we will need it to link the view with the hotspots config.
|
|
552
|
+
|
|
553
|
+
### Create hotspots configuration
|
|
554
|
+
The hotspots config should be an array of objects, each object in the array indicates a single hotspot config.
|
|
555
|
+
For each item in the array, we need to set the positions (X-coord and Y-coord) of the hotspot at every image index we need to show the hotspot on it. <br>hint: To know the current image index we will need to set `data-info="white || black"` attribute.
|
|
556
|
+
|
|
557
|
+
example:
|
|
558
|
+
|
|
559
|
+
```js
|
|
560
|
+
const HOTSPOTS_CONFIG = [
|
|
561
|
+
{
|
|
562
|
+
positions: [
|
|
563
|
+
{ imageIndex: 0, xCoord: 527, yCoord: 319 },
|
|
564
|
+
{ imageIndex: 1, xCoord: 524 },
|
|
565
|
+
{ imageIndex: 2, xCoord: 520 },
|
|
566
|
+
{ imageIndex: 3, xCoord: 498 },
|
|
567
|
+
{ imageIndex: 4, xCoord: 470 },
|
|
568
|
+
{ imageIndex: 5, xCoord: 441 },
|
|
569
|
+
]
|
|
570
|
+
}
|
|
571
|
+
]
|
|
572
|
+
```
|
|
573
|
+
In the previous example, we have only set the Ycoord a single time at the image index 0.
|
|
574
|
+
So if the coord didn't change there's no need to reset it, it will already take the previous value.
|
|
575
|
+
|
|
576
|
+
Now we need to set the hotspot variant, we have three types of hotspots (link, popup, and custom), as it will be explained below.
|
|
577
|
+
## Variant
|
|
578
|
+
### Link
|
|
579
|
+
we need to provide the URL of the link and the link title.
|
|
580
|
+
|
|
581
|
+
example:
|
|
582
|
+
|
|
583
|
+
```js
|
|
584
|
+
const HOTSPOTS_CONFIG = [
|
|
585
|
+
{
|
|
586
|
+
positions,
|
|
587
|
+
variant: {
|
|
588
|
+
title: 'New Gurkha Technical Specifications',
|
|
589
|
+
url: 'https://www.forcegurkha.co.in/specifications/',
|
|
590
|
+
newTab: true
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
]
|
|
594
|
+
```
|
|
595
|
+
---
|
|
596
|
+
### Popup
|
|
597
|
+
Only the property inserted will displayed.
|
|
598
|
+
| Property |Type | Default | Description |
|
|
599
|
+
| ------------- | ------------- | ------------- |------------- |
|
|
600
|
+
| images | Array| [] | To display a carousel of images we need an array of objects, each object should include the src and the alt of each image |
|
|
601
|
+
| title |String| null | Display title underneath the images |
|
|
602
|
+
| description| String | null | Display description underneath the title |
|
|
603
|
+
| moreDetailsUrl | String | null | Display a button underneath the description to navigate to a provided URL |
|
|
604
|
+
| moreDetailsTitle | String | null| Set the title of the more details button |
|
|
605
|
+
|
|
606
|
+
example:
|
|
607
|
+
```js
|
|
608
|
+
const HOTSPOTS_CONFIG = [
|
|
609
|
+
{
|
|
610
|
+
positions,
|
|
611
|
+
variant: {
|
|
612
|
+
images: [
|
|
613
|
+
{ src: 'https://scaleflex.cloudimg.io/v7/demo/360-assets/AIR_SNORKEL_FINAL_JPG.png?vh=88bccb', alt: 'air snorkel' }
|
|
614
|
+
], // optional
|
|
615
|
+
title: 'Air Intake Snorkel', // optional
|
|
616
|
+
description: 'The snorkel gives the Gurkha an unmatched water-wading ability and ensures ample supply of fresh air for combustion.', // optional
|
|
617
|
+
moreDetailsUrl: 'https://forcegurkha.co.in', // optional
|
|
618
|
+
moreDetailsTitle: 'Read more' // optional
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
]
|
|
622
|
+
```
|
|
623
|
+
---
|
|
624
|
+
### Custom
|
|
625
|
+
Display any element in the DOM in a popup and link it with the hotspot.</br>
|
|
626
|
+
We will need to set the variant property value to the id of the element.
|
|
627
|
+
|
|
628
|
+
example:
|
|
629
|
+
```js
|
|
630
|
+
const HOTSPOTS_CONFIG = [
|
|
631
|
+
{
|
|
632
|
+
positions,
|
|
633
|
+
variant: 'gurkha-suv'
|
|
634
|
+
}
|
|
635
|
+
]
|
|
636
|
+
```
|
|
637
|
+
## PopupProps
|
|
638
|
+
Options to customize the hotspot popup.
|
|
639
|
+
### Properties
|
|
640
|
+
| Property | Type | Defaullt |Description |
|
|
641
|
+
| ------------- | ------------- | ------------- | ------------- |
|
|
642
|
+
| popupSelector |String| null |Set className to the popup wrapper |
|
|
643
|
+
| open |Boolean | false |Open the popup |
|
|
644
|
+
| arrow |Boolean| true |Dipslay an arrow that points toward the hotspot element|
|
|
645
|
+
| offset|Array | [0, 0] |Set a distance between the hotspot element and the popup |
|
|
646
|
+
| placement|String| Auto|- we can adjust the position of the hotspot popup relative to the hotspot element. (top - bottom - left - right)|
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
example:
|
|
650
|
+
```js
|
|
651
|
+
const HOTSPOTS_CONFIG = [
|
|
652
|
+
{
|
|
653
|
+
positions,
|
|
654
|
+
variant,
|
|
655
|
+
popupProps: {
|
|
656
|
+
popupSelector: 'air-intake-popup', // optional
|
|
657
|
+
offset: [20, 5], // optional
|
|
658
|
+
arrow: false, // optional
|
|
659
|
+
placement: 'bottom' // optional
|
|
660
|
+
},
|
|
661
|
+
indicatorSelector: 'first-hotspot-icon' // optional
|
|
662
|
+
}
|
|
663
|
+
]
|
|
664
|
+
```
|
|
665
|
+
## Responsive hotspots
|
|
666
|
+
Now we need to make our hotspots responsive to have an accurate positioning in different screens.
|
|
667
|
+
we have to set `initialDimensions` property to every hotspot config. which indicates the dimension of the cloudimage-360 view.<br/>
|
|
668
|
+
hint: `data-info` can be used to get view size.
|
|
669
|
+
|
|
670
|
+
example:
|
|
671
|
+
```js
|
|
672
|
+
const HOTSPOTS_CONFIG = [
|
|
673
|
+
{
|
|
674
|
+
positions,
|
|
675
|
+
variant,
|
|
676
|
+
popupProps,
|
|
677
|
+
indicatorSelector,
|
|
678
|
+
initialDimensions: [ 1170, 662 ]
|
|
679
|
+
}
|
|
680
|
+
]
|
|
681
|
+
```
|
|
682
|
+
## Add Hotspots
|
|
683
|
+
we need this function to link the created config with the 360-view.
|
|
684
|
+
```js
|
|
685
|
+
window.CI360.addHotspots(idOftheView, hotspotsConfig);
|
|
686
|
+
```
|
|
687
|
+
example:
|
|
688
|
+
```js
|
|
689
|
+
window.CI360.addHotspots("gurkha-suv", HOTSPOTS_CONFIG);
|
|
690
|
+
```
|
|
691
|
+
<a href="https://codesandbox.io/s/competent-bogdan-49b0u6?file=/index.html"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
|
|
692
|
+
|
|
693
|
+
### data-responsive (or responsive)
|
|
694
|
+
|
|
695
|
+
###### Type: **String** (Cloudimage token) | Default: **none** | _required for cloudimage responsive plugin_
|
|
696
|
+
|
|
697
|
+
Enables cloudimage responsive plugin for 360 view.
|
|
558
698
|
|
|
559
699
|
## <a name="cloudimage-responsive-integration"/> Cloudimage Responsive Integration
|
|
560
700
|
|
|
@@ -613,27 +753,6 @@ Lazy loading is not included into js-cloudimage-360-view by default. There are w
|
|
|
613
753
|
|
|
614
754
|
[Implementation example with lozad.js](https://codesandbox.io/s/0185934m8p?fontsize=14)
|
|
615
755
|
|
|
616
|
-
to save API calls you man want to use one of our cdn bundles:
|
|
617
|
-
|
|
618
|
-
CDN link to js-cloudimage-360-view 1.1.0 + lazysizes 4.1.7
|
|
619
|
-
|
|
620
|
-
```javascript
|
|
621
|
-
<script src="https://cdn.scaleflex.it/filerobot/js-cloudimage-360-view/v2.0.0.lazysizes.min.js"></script>
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
CDN link to js-cloudimage-360-view 1.1.0 + yall.js 3.1.1
|
|
625
|
-
|
|
626
|
-
```javascript
|
|
627
|
-
<script src="https://cdn.scaleflex.it/filerobot/js-cloudimage-360-view/v2.0.0.yall.min.js"></script>
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
CDN link to js-cloudimage-360-view 1.1.0 + lozad.js 1.9.0
|
|
631
|
-
|
|
632
|
-
```javascript
|
|
633
|
-
<script src="https://cdn.scaleflex.it/filerobot/js-cloudimage-360-view/v2.0.0.lozad.min.js"></script>
|
|
634
|
-
```
|
|
635
|
-
|
|
636
|
-
|
|
637
756
|
## <a name="best-practices"/> Best practices
|
|
638
757
|
|
|
639
758
|
* In order to use cloudimage responsive with 360 view, your original (master) images should be stored on a server
|
|
@@ -659,5 +778,4 @@ Tested in all modern browsers and IE 11, 10, 9.
|
|
|
659
778
|
All contributions are super welcome!
|
|
660
779
|
|
|
661
780
|
## <a name="license"></a>License
|
|
662
|
-
JS Cloudimage 360 View is provided under the [MIT License](https://opensource.org/licenses/MIT)
|
|
663
|
-
|
|
781
|
+
JS Cloudimage 360 View is provided under the [MIT License](https://opensource.org/licenses/MIT)
|
package/dist/ci360.service.js
CHANGED
|
@@ -760,6 +760,7 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
760
760
|
image = this.imagesY[this.activeImageY - 1];
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
+
if (!image) return;
|
|
763
764
|
var ctx = this.canvas.getContext("2d");
|
|
764
765
|
ctx.scale(this.devicePixelRatio, this.devicePixelRatio);
|
|
765
766
|
this.updateContainerAndCanvasSize(image);
|
|
@@ -965,11 +966,18 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
965
966
|
|
|
966
967
|
if (_this4.playOnce && isPlayedOnce) {
|
|
967
968
|
window.clearTimeout(_this4.loopTimeoutId);
|
|
969
|
+
_this4.autoplay = false;
|
|
968
970
|
|
|
969
|
-
_this4.
|
|
971
|
+
if (!_this4.hide360Logo) {
|
|
972
|
+
_this4.add360ViewIcon();
|
|
970
973
|
|
|
971
|
-
|
|
972
|
-
|
|
974
|
+
_this4.view360Icon.innerText = '';
|
|
975
|
+
(0, _ci.setView360Icon)(_this4.view360Icon, _this4.logoSrc);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
if (_this4.hotspotsConfigs) {
|
|
979
|
+
(0, _utils.updateHotspots)(_this4.container, _this4.hotspotsConfigs, _this4.activeImageX, _this4.activeImageY, _this4.movingDirection, _this4.isClicked);
|
|
980
|
+
}
|
|
973
981
|
}
|
|
974
982
|
}, this.autoplaySpeed);
|
|
975
983
|
}
|
|
@@ -1123,8 +1131,11 @@ var CI360Viewer = /*#__PURE__*/function () {
|
|
|
1123
1131
|
key: "remove360ViewIcon",
|
|
1124
1132
|
value: function remove360ViewIcon() {
|
|
1125
1133
|
if (!this.view360Icon) return;
|
|
1126
|
-
|
|
1127
|
-
|
|
1134
|
+
|
|
1135
|
+
try {
|
|
1136
|
+
this.innerBox.removeChild(this.view360Icon);
|
|
1137
|
+
this.view360Icon = null;
|
|
1138
|
+
} catch (_unused) {}
|
|
1128
1139
|
}
|
|
1129
1140
|
}, {
|
|
1130
1141
|
key: "initControls",
|
|
@@ -61,12 +61,11 @@
|
|
|
61
61
|
.cloudimage-360-hotspot-custom-icon::after {
|
|
62
62
|
content: '+';
|
|
63
63
|
position: absolute;
|
|
64
|
-
line-height: 20px;
|
|
65
64
|
left: 50%;
|
|
66
|
-
top:
|
|
65
|
+
top: 50%;
|
|
67
66
|
color: #FFF;
|
|
68
67
|
font-weight: 400;
|
|
69
|
-
transform: translate(-50%, -
|
|
68
|
+
transform: translate(-50%, -50%);
|
|
70
69
|
cursor: auto;
|
|
71
70
|
}
|
|
72
71
|
|
|
@@ -128,8 +127,14 @@
|
|
|
128
127
|
margin: 0 auto;
|
|
129
128
|
}
|
|
130
129
|
|
|
130
|
+
.cloudimage-360-images-carousel {
|
|
131
|
+
background-color: #f5f4f4;
|
|
132
|
+
border-radius: 2px;
|
|
133
|
+
}
|
|
134
|
+
|
|
131
135
|
.cloudimage-360-images-carousel .cloudimage-360-carousel-image {
|
|
132
136
|
display: none;
|
|
137
|
+
object-fit: contain;
|
|
133
138
|
min-height: 187px;
|
|
134
139
|
max-width: 100%;
|
|
135
140
|
max-height: 100%;
|
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createCarouselImage = void 0;
|
|
7
7
|
|
|
8
|
-
var createCarouselImage = function createCarouselImage(
|
|
8
|
+
var createCarouselImage = function createCarouselImage(image, imageIndex) {
|
|
9
9
|
var carouselImage = document.createElement('img');
|
|
10
10
|
carouselImage.className = 'cloudimage-360-carousel-image';
|
|
11
|
-
carouselImage.setAttribute('src',
|
|
11
|
+
carouselImage.setAttribute('src', image.src || '');
|
|
12
|
+
carouselImage.setAttribute('alt', image.alt || 'more-info');
|
|
12
13
|
|
|
13
14
|
if (!imageIndex) {
|
|
14
15
|
carouselImage.setAttribute('data-active-image', '');
|
|
@@ -9,14 +9,14 @@ var _createCarouselDot = require("./create-carousel-dot");
|
|
|
9
9
|
|
|
10
10
|
var _createCarouselImage = require("./create-carousel-image");
|
|
11
11
|
|
|
12
|
-
var createImagesCarousel = function createImagesCarousel(
|
|
12
|
+
var createImagesCarousel = function createImagesCarousel(images, popup, container) {
|
|
13
13
|
var imagesCarousel = document.createElement('div');
|
|
14
14
|
var carouselDots = document.createElement('div');
|
|
15
15
|
imagesCarousel.className = 'cloudimage-360-images-carousel';
|
|
16
16
|
imagesCarousel.style.maxWidth = "".concat(container.offsetWidth, "px");
|
|
17
17
|
carouselDots.className = 'cloudimage-360-carousel-dots';
|
|
18
|
-
|
|
19
|
-
var carouselImage = (0, _createCarouselImage.createCarouselImage)(
|
|
18
|
+
images.forEach(function (image, imageIndex) {
|
|
19
|
+
var carouselImage = (0, _createCarouselImage.createCarouselImage)(image, imageIndex);
|
|
20
20
|
var carouselDot = (0, _createCarouselDot.createCarouselDot)(carouselImage, imageIndex, popup);
|
|
21
21
|
carouselDots.appendChild(carouselDot);
|
|
22
22
|
imagesCarousel.appendChild(carouselImage);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createPopup = void 0;
|
|
7
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
8
12
|
var _createHotspotPopupLink = require("./create-hotspot-popup-link");
|
|
9
13
|
|
|
10
14
|
var _getPopupNode = require("../get-popup-node");
|
|
@@ -35,14 +39,14 @@ var createPopup = function createPopup(container, hotspotConfig, popupProps) {
|
|
|
35
39
|
return e.stopPropagation();
|
|
36
40
|
};
|
|
37
41
|
|
|
38
|
-
if (images || description || moreDetailsUrl || title && !url) {
|
|
42
|
+
if ((0, _typeof2.default)(variant) === 'object' && images || description || moreDetailsUrl || title && !url) {
|
|
39
43
|
(0, _createModelElements.createModalElements)(variant, container, popup);
|
|
40
44
|
} else if (url) {
|
|
41
45
|
var hotspotPopupLink = (0, _createHotspotPopupLink.createHotspotPopupLink)(variant);
|
|
42
46
|
popup.appendChild(hotspotPopupLink);
|
|
43
|
-
} else {
|
|
47
|
+
} else if (typeof variant === 'string') {
|
|
44
48
|
try {
|
|
45
|
-
var popupNode = (0, _getPopupNode.getPopupNode)(
|
|
49
|
+
var popupNode = (0, _getPopupNode.getPopupNode)(variant);
|
|
46
50
|
var userPopup = popupNode.cloneNode(true);
|
|
47
51
|
popup.appendChild(userPopup);
|
|
48
52
|
popupNode.parentNode.removeChild(popupNode);
|
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.fillEmptyCoordWithPrevious = void 0;
|
|
7
7
|
|
|
8
8
|
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
|
9
|
-
var fillEmptyCoordWithPrevious = function fillEmptyCoordWithPrevious(
|
|
9
|
+
var fillEmptyCoordWithPrevious = function fillEmptyCoordWithPrevious(positions, hotspotIndex, coord) {
|
|
10
10
|
var coordIndexes = new Array(hotspotIndex);
|
|
11
11
|
var intialValue = '0%';
|
|
12
12
|
|
|
13
13
|
for (var i = coordIndexes.length - 1; i > -1; i--) {
|
|
14
|
-
var
|
|
14
|
+
var _positions$i;
|
|
15
15
|
|
|
16
|
-
var previousXCoord = (
|
|
16
|
+
var previousXCoord = (_positions$i = positions[i]) === null || _positions$i === void 0 ? void 0 : _positions$i[coord];
|
|
17
17
|
|
|
18
18
|
if (previousXCoord) {
|
|
19
19
|
return previousXCoord;
|
|
@@ -21,8 +21,8 @@ var generateHotspotsConfigs = function generateHotspotsConfigs(hotspotsProps) {
|
|
|
21
21
|
var hotspotsConfigs = hotspotsProps.map(function (hotspotProps) {
|
|
22
22
|
var _hotspotProps$variant = hotspotProps.variant,
|
|
23
23
|
variant = _hotspotProps$variant === void 0 ? {} : _hotspotProps$variant,
|
|
24
|
-
_hotspotProps$
|
|
25
|
-
|
|
24
|
+
_hotspotProps$positio = hotspotProps.positions,
|
|
25
|
+
positions = _hotspotProps$positio === void 0 ? [] : _hotspotProps$positio,
|
|
26
26
|
_hotspotProps$indicat = hotspotProps.indicatorSelector,
|
|
27
27
|
indicatorSelector = _hotspotProps$indicat === void 0 ? '' : _hotspotProps$indicat,
|
|
28
28
|
_hotspotProps$popupPr = hotspotProps.popupProps,
|
|
@@ -45,7 +45,7 @@ var generateHotspotsConfigs = function generateHotspotsConfigs(hotspotsProps) {
|
|
|
45
45
|
anchorId: anchorId
|
|
46
46
|
}),
|
|
47
47
|
popupProps: popupConfig,
|
|
48
|
-
|
|
48
|
+
positions: positions,
|
|
49
49
|
indicatorSelector: indicatorSelector,
|
|
50
50
|
initialDimensions: initialDimensions,
|
|
51
51
|
orientation: orientation.toLowerCase()
|
|
@@ -9,7 +9,7 @@ var generatePopupConfig = function generatePopupConfig(popupProps) {
|
|
|
9
9
|
var _popupProps$popupSele = popupProps.popupSelector,
|
|
10
10
|
popupSelector = _popupProps$popupSele === void 0 ? '' : _popupProps$popupSele,
|
|
11
11
|
_popupProps$arrow = popupProps.arrow,
|
|
12
|
-
arrow = _popupProps$arrow === void 0 ?
|
|
12
|
+
arrow = _popupProps$arrow === void 0 ? true : _popupProps$arrow,
|
|
13
13
|
_popupProps$offset = popupProps.offset,
|
|
14
14
|
offset = _popupProps$offset === void 0 ? [0, 10] : _popupProps$offset,
|
|
15
15
|
_popupProps$placement = popupProps.placement,
|
|
@@ -7,17 +7,17 @@ exports.prepareHotspotsPositions = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _fillEmptyCoordWithPrevious = require("./fill-empty-coord-with-previous");
|
|
9
9
|
|
|
10
|
-
var prepareHotspotsPositions = function prepareHotspotsPositions(
|
|
11
|
-
return
|
|
10
|
+
var prepareHotspotsPositions = function prepareHotspotsPositions(positions) {
|
|
11
|
+
return positions.reduce(function (accumulate, current, currentIndex) {
|
|
12
12
|
var isIncludesXcoord = !!(current !== null && current !== void 0 && current.xCoord);
|
|
13
13
|
var isIncludesYcoord = !!(current !== null && current !== void 0 && current.yCoord);
|
|
14
14
|
|
|
15
15
|
if (!isIncludesXcoord) {
|
|
16
|
-
current.xCoord = (0, _fillEmptyCoordWithPrevious.fillEmptyCoordWithPrevious)(
|
|
16
|
+
current.xCoord = (0, _fillEmptyCoordWithPrevious.fillEmptyCoordWithPrevious)(positions, currentIndex, 'xCoord');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (!isIncludesYcoord) {
|
|
20
|
-
current.yCoord = (0, _fillEmptyCoordWithPrevious.fillEmptyCoordWithPrevious)(
|
|
20
|
+
current.yCoord = (0, _fillEmptyCoordWithPrevious.fillEmptyCoordWithPrevious)(positions, currentIndex, 'yCoord');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
accumulate.push(current);
|
|
@@ -20,14 +20,14 @@ var updateHotspots = function updateHotspots(container, hotspotsProps) {
|
|
|
20
20
|
var activeImageY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
21
21
|
var movingDirection = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'x-axis';
|
|
22
22
|
hotspotsProps.forEach(function (hotspotProps) {
|
|
23
|
-
var
|
|
23
|
+
var positions = hotspotProps.positions,
|
|
24
24
|
initialDimensions = hotspotProps.initialDimensions,
|
|
25
25
|
orientation = hotspotProps.orientation,
|
|
26
26
|
variant = hotspotProps.variant;
|
|
27
27
|
var anchorId = variant.anchorId;
|
|
28
28
|
var hotspotOriantaion = (0, _getHotspotOrientation.getHotspotOriantaion)(movingDirection);
|
|
29
29
|
var currentImageIndex = orientation === 'x' ? activeImageX : activeImageY;
|
|
30
|
-
var hotspotsPositions = (0, _prepareHotspotsPositions.prepareHotspotsPositions)(
|
|
30
|
+
var hotspotsPositions = (0, _prepareHotspotsPositions.prepareHotspotsPositions)(positions);
|
|
31
31
|
var currentPosition = hotspotsPositions.find(function (hotspotPosition) {
|
|
32
32
|
return hotspotPosition.imageIndex === currentImageIndex;
|
|
33
33
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-cloudimage-360-view",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "scaleflex",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"gh-pages": "^2.0.1",
|
|
53
53
|
"highlight.js": "^10.4.1",
|
|
54
54
|
"html-webpack-plugin": "^3.2.0",
|
|
55
|
+
"mini-css-extract-plugin": "^0.9.0",
|
|
55
56
|
"mobile-detect": "^1.4.3",
|
|
56
57
|
"style-loader": "^0.23.1",
|
|
57
58
|
"webpack": "^4.46.0",
|