js-cloudimage-360-view 3.0.0-beta.0 → 3.0.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.
Files changed (95) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/LICENSE +13 -1
  3. package/README.md +360 -131
  4. package/dist/ci360.service.js +924 -1116
  5. package/dist/ci360.utils.js +36 -196
  6. package/dist/constants/auto-play-behavior.js +13 -0
  7. package/dist/constants/falsy-values.js +8 -0
  8. package/dist/constants/index.js +43 -0
  9. package/dist/constants/orientations.js +12 -0
  10. package/dist/constants/props-require-reload.js +21 -0
  11. package/dist/constants/regex.js +10 -0
  12. package/dist/index.js +73 -12
  13. package/dist/static/css/hotspots.css +222 -0
  14. package/dist/static/css/style.css +113 -4
  15. package/dist/utils/auto-play/get-speed-factor.js +14 -0
  16. package/dist/utils/auto-play/is-completed-one-cycle.js +32 -0
  17. package/dist/utils/auto-play/loop.js +67 -0
  18. package/dist/utils/class-names/add-class.js +18 -0
  19. package/dist/utils/class-names/remove-class.js +16 -0
  20. package/dist/utils/container-elements/apply-styles-to-container.js +16 -0
  21. package/dist/utils/container-elements/create-360-view-circle-icon.js +16 -0
  22. package/dist/utils/container-elements/create-360-view-icon.js +15 -0
  23. package/dist/utils/container-elements/create-box-shadow.js +16 -0
  24. package/dist/utils/container-elements/create-canvas.js +16 -0
  25. package/dist/utils/container-elements/create-close-fullscreen-icon.js +14 -0
  26. package/dist/utils/container-elements/create-fullscreen-icon.js +14 -0
  27. package/dist/utils/container-elements/create-fullscreen-modal.js +20 -0
  28. package/dist/utils/container-elements/create-icons-container.js +15 -0
  29. package/dist/utils/container-elements/create-inner-box.js +15 -0
  30. package/dist/utils/container-elements/create-loader.js +15 -0
  31. package/dist/utils/container-elements/create-magnifier-icon.js +14 -0
  32. package/dist/utils/container-elements/index.js +109 -0
  33. package/dist/utils/container-elements/remove-child-from-parent.js +16 -0
  34. package/dist/utils/controls/get-item-skipped.js +13 -0
  35. package/dist/utils/controls/init-controls.js +77 -0
  36. package/dist/utils/hotspots/attach-events/hide-popup.js +15 -0
  37. package/dist/utils/hotspots/attach-events/show-popup.js +14 -0
  38. package/dist/utils/hotspots/configs-error-handler.js +27 -0
  39. package/dist/utils/hotspots/create-popper-instace.js +32 -0
  40. package/dist/utils/hotspots/elements/create-carousel-dot.js +26 -0
  41. package/dist/utils/hotspots/elements/create-carousel-image.js +22 -0
  42. package/dist/utils/hotspots/elements/create-hotspot-icon.js +66 -0
  43. package/dist/utils/hotspots/elements/create-hotspot-popup-link.js +23 -0
  44. package/dist/utils/hotspots/elements/create-hotspots.js +25 -0
  45. package/dist/utils/hotspots/elements/create-images-carousel.js +27 -0
  46. package/dist/utils/hotspots/elements/create-modal-description.js +15 -0
  47. package/dist/utils/hotspots/elements/create-modal-title.js +15 -0
  48. package/dist/utils/hotspots/elements/create-model-elements.js +66 -0
  49. package/dist/utils/hotspots/elements/create-popup-arrow.js +16 -0
  50. package/dist/utils/hotspots/elements/create-popup.js +67 -0
  51. package/dist/utils/hotspots/elements/create-read-more-btn.js +17 -0
  52. package/dist/utils/hotspots/fill-empty-coord-with-previous.js +26 -0
  53. package/dist/utils/hotspots/generate-hotspots-configs.js +58 -0
  54. package/dist/utils/hotspots/generate-popup-config.js +29 -0
  55. package/dist/utils/hotspots/get-hotspot-icon.js +14 -0
  56. package/dist/utils/hotspots/get-hotspot-orientation.js +21 -0
  57. package/dist/utils/hotspots/get-hotspot-popup-node.js +14 -0
  58. package/dist/utils/hotspots/get-popup-node.js +14 -0
  59. package/dist/utils/hotspots/hide-hotspot-icon.js +13 -0
  60. package/dist/utils/hotspots/hide-hotspots-icons.js +18 -0
  61. package/dist/utils/hotspots/is-mouse-on-hotspot.js +14 -0
  62. package/dist/utils/hotspots/prepare-hotspots-positions.js +28 -0
  63. package/dist/utils/hotspots/set-current-slide.js +23 -0
  64. package/dist/utils/hotspots/toggle-popup-events.js +23 -0
  65. package/dist/utils/hotspots/update-hotspot-icon-position.js +21 -0
  66. package/dist/utils/hotspots/update-hotspots.js +48 -0
  67. package/dist/utils/image-src/generate-images-path.js +42 -0
  68. package/dist/utils/image-src/is-props-change-require-reload.js +23 -0
  69. package/dist/utils/index.js +237 -0
  70. package/dist/utils/load-images/images-from-folder/prepare-images-from-folder.js +34 -0
  71. package/dist/utils/load-images/images-from-list/prepare-images-from-list.js +35 -0
  72. package/dist/utils/load-images/lazyload/init-lazyload.js +49 -0
  73. package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-folder.js +18 -0
  74. package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-list.js +29 -0
  75. package/dist/utils/load-images/load-image-as-promise.js +54 -0
  76. package/dist/utils/load-images/load-images-relative-to-container-size.js +58 -0
  77. package/dist/utils/load-images/load-original-images.js +58 -0
  78. package/dist/utils/load-images/pad.js +14 -0
  79. package/dist/utils/load-images/preload-images.js +35 -0
  80. package/dist/utils/load-images/preload-original-images.js +35 -0
  81. package/dist/utils/magnify/get-current-original-image.js +29 -0
  82. package/dist/utils/magnify/get-cursor-position.js +24 -0
  83. package/dist/utils/magnify/magnify.js +54 -0
  84. package/dist/utils/magnify/move-magnifier.js +47 -0
  85. package/dist/utils/responsive/contain.js +11 -0
  86. package/dist/utils/responsive/fit.js +33 -0
  87. package/dist/utils/responsive/get-image-aspect-ratio.js +39 -0
  88. package/dist/utils/responsive/get-responsive-width-of-container.js +14 -0
  89. package/dist/utils/responsive/get-size-according-to-pixel-ratio.js +17 -0
  90. package/dist/utils/responsive/get-size-limit.js +14 -0
  91. package/dist/utils/spin-y/get-moving-direction.js +21 -0
  92. package/dist/utils/zoom/generate-zoom-in-steps.js +20 -0
  93. package/dist/utils/zoom/generate-zoom-out-steps.js +20 -0
  94. package/package.json +13 -10
  95. package/dist/ci360.constants.js +0 -31
package/README.md CHANGED
@@ -1,15 +1,14 @@
1
- [![Release](https://img.shields.io/badge/release-v2.6.0-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
1
+
2
+ [![Release](https://img.shields.io/badge/release-v3.0.1-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
2
3
  [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)](#contributing)
3
4
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
- [![Scaleflex team](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg)](https://www.scaleflex.it/en/home)
5
-
6
- [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](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)
5
+ [![Scaleflex team](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20-Scaleflex%20team-6986fa.svg)](https://www.scaleflex.com/en/home)
6
+ [![Cloudimage](https://img.shields.io/badge/Powered%20by-cloudimage-blue)](https://www.cloudimage.io/en/home)
7
7
 
8
8
  <p align="center">
9
- <img
10
- height="175"
11
- alt="The Lounge"
12
- src="https://demo.cloudimg.io/v7/https://scaleflex.airstore.io/filerobot/filerobot-cloudimage.png?sanitize=true">
9
+ <img
10
+ alt="cloudimage logo"
11
+ src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
13
12
  </p>
14
13
 
15
14
  <h1 align="center">
@@ -29,27 +28,23 @@
29
28
  <a href="https://medium.com/cloudimage/e-merchandising-how-can-a-360-view-of-your-products-boost-your-revenue-24b16eb9cd62" target="_blank">Why</a>
30
29
  </strong>
31
30
  </p>
32
-
33
- A simple, interactive resource that can be used to provide a virtual tour of your product.
34
-
31
+ <p align="center">A simple, interactive resource that can be used to provide a virtual tour of your product.</p>
35
32
  <p align="center">
36
33
  <img
37
34
  alt="The Lounge"
38
- src="https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/demo-chair-500.gif?sanitize=true">
35
+ src="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/demos/assets/a2.gif">
39
36
  </p>
40
37
 
41
- powered by [Cloudimage](https://www.cloudimage.io/)
42
- ([Watch the video here](https://www.youtube.com/watch?time_continue=2&v=JFZSE1vYb0k))
43
-
44
38
  ## <a name="table_of_contents"></a>Table of contents
45
39
 
46
40
  * [Demo](#demo)
47
41
  * [Step 1: Installation](#installation)
48
42
  * [Step 2: Initialize](#initialize)
49
43
  * [Methods](#methods)
50
- * [Customize Icons](#customize-icons)
44
+ * [Customize elements](#customize-elements)
51
45
  * [Configuration](#configuration)
52
46
  * [Controls](#controls)
47
+ * [Hotspots](#hotspots)
53
48
  * [Cloudimage responsive integration](#cloudimage-responsive-integration)
54
49
  * [Lazy loading integration](#lazy-loading)
55
50
  * [Best practices](#best-practices)
@@ -69,7 +64,7 @@ To see the Cloudimage 360 view plugin in action, please check out the
69
64
  Add script tag with CDN link to js-cloudimage-360-view lib after all content in body tag
70
65
 
71
66
  ```javascript
72
- <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2.6.0/js-cloudimage-360-view.min.js"></script>
67
+ <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/3.0.1/js-cloudimage-360-view.min.js"></script>
73
68
  ```
74
69
 
75
70
  ## <a name="initialize"></a>Step 2: Initialize
@@ -80,9 +75,10 @@ After adding the js-cloudimage-360-view lib, simply initialize it with **class n
80
75
  ```html
81
76
  <div
82
77
  class="cloudimage-360"
83
- data-folder="https://scaleflex.airstore.io/demo/360-car/"
84
- data-filename="iris-{index}.jpeg"
85
- data-amount="36"
78
+ id="gurkha-suv"
79
+ data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
80
+ data-filename-x="orange-{index}.jpg"
81
+ data-amount-x="73"
86
82
  ></div>
87
83
  ```
88
84
 
@@ -103,10 +99,54 @@ window.CI360.init();
103
99
  > 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
104
100
  > ```javascript
105
101
  > <script>window.CI360 = { notInitOnLoad: true }</script>
106
- > <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/2/js-cloudimage-360-view.min.js"></script>
102
+ > <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/3.0./js-cloudimage-360-view.min.js"></script>
107
103
  > <script>window.CI360.init(); // initialize the plugin when you need</script>
108
104
  > ```
109
105
 
106
+ ### add
107
+
108
+ ###### Type: **Function**
109
+
110
+ ```javascript
111
+ window.CI360.add(idOftheView: string);
112
+ ```
113
+ lazy init cloudimage-360 view by id.
114
+ ### Properties
115
+ #### `idOftheView`: string
116
+ The id of the new view
117
+
118
+ ### update
119
+
120
+ ###### Type: **Function**
121
+ ```javascript
122
+ window.CI360.update(idOftheView, forceUpdate);
123
+ ```
124
+ Update cloudimage 360 viewer instance.<br/>
125
+ For any update in source attributes after plugin initialization (e.g. `data-folder`, `data-filename-x`, `data-amount-y`),
126
+ the plugin will re-init.
127
+ ### Properties
128
+ #### `idOftheView`: string
129
+ The id of the new view
130
+ #### `forceUpdate`: bool
131
+ Force the view to reinitialize.
132
+
133
+ ```html
134
+ <div
135
+ class="cloudimage-360"
136
+ id="gurkha-suv"
137
+ data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
138
+ data-filename-x="orange-{index}.jpg"
139
+ data-amount-x="73"
140
+ ></div>
141
+ ```
142
+ ```javascript
143
+ window.CI360.update('gurkha-suv');
144
+ ```
145
+
146
+ ```javascript
147
+ window.CI360.update(null, true);
148
+ ```
149
+
110
150
  ### destroy
111
151
 
112
152
  ###### Type: **Function**
@@ -126,25 +166,51 @@ window.CI360.destroy();
126
166
  Get the {index} of the image that is being viewed.
127
167
 
128
168
  ```javascript
129
- window.CI360.getActiveIndexByID('id_of_product');
169
+ window.CI360.getActiveIndexByID(idOfInstance: string, oriantation: string);
130
170
  ```
131
- ## <a name="customize-icons"></a> Customize icons
171
+ ### Properties
172
+ #### `idOfInstance`: string
173
+ The id of the instance
132
174
 
133
- You can customize the icons by adding the following classes:
175
+ #### `oriantation`: string
176
+ The oriantation of the active index
177
+
178
+ ## <a name="customize-elements"></a> Customize elements
179
+
180
+ You can customize elements by adding the following classes:
134
181
 
135
182
  ### Example CSS
136
183
  ```css
137
- .cloudimage-360 .fullscreen-icon {
138
- background: url(https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/full_screen.svg) 50% 50% / cover no-repeat;
184
+ .cloudimage-360-icons-container {
185
+ top: 5px;
186
+ right: 5px;
187
+ }
188
+ .cloudimage-360-fullscreen-modal {
189
+ top: 0;
190
+ bottom: 0;
139
191
  }
140
- .cloudimage-360 .magnify-icon {
192
+ .cloudimage-360-magnifier-icon {
141
193
  background: url(https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/loupe.svg) 50% 50% / cover no-repeat;
142
194
  }
143
- .cloudimage-360 .close-fullscreen-icon {
195
+ .cloudimage-360-close-fullscreen-icon {
144
196
  background: url(https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/cross.svg) 50% 50% / cover no-repeat;
145
197
  }
146
- .cloudimage-360 .reset-zoom-icon {
147
- background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/ic-resize.svg?vh=248986) 50% 50% / cover no-repeat;
198
+ .cloudimage-360-view-360-circle {
199
+ margin: auto;
200
+ }
201
+ .cloudimage-360-loader {
202
+ margin: auto;
203
+ }
204
+ .cloudimage-360-view-360-icon {
205
+ background: url(hhttps://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg) 50% 50% / cover no-repeat;
206
+ }
207
+ .cloudimage-360-box-shadow {
208
+ top: 0;
209
+ left: 0;
210
+ }
211
+ .cloudimage-360-img-magnifier-glass {
212
+ border: 3px solid #000;
213
+ border-radius: 50%;
148
214
  }
149
215
  ```
150
216
 
@@ -161,24 +227,35 @@ The selector for js-cloudimage-360-view lib.
161
227
  ###### Type: **String(url)** | _required_
162
228
 
163
229
  Your images folder on server.
230
+ ### data-api-version (or api-version)
231
+
232
+ ###### Type: **String** |Default: **'v7'** | _optional_
233
+
234
+ Allow to use a specific version of API.
164
235
 
165
- ### data-filename (or filename)
236
+ - set a specific version of API
237
+ ```javascript
238
+ data-api-version="v7"
239
+ ```
240
+ - disable API version
241
+ ```javascript
242
+ data-api-version="null"
243
+ ```
244
+ ### data-filename-x (or filename-x)
166
245
 
167
246
  ###### Type: **String** | Default: **image-{index}.jpg** | _optional_
168
247
 
169
- The filename pattern for your 360 image. Must include {index}, which the library will replace with a number between 1 and [data-amount](#data-amount).
248
+ The filename pattern for your 360 image. Must include {index}, which the library will replace with a number between 1 and [data-amount-x](#data-amount-x).
170
249
 
171
250
  ### data-filename-y (or filename-y)
172
251
 
173
252
  ###### Type: **String** | Default: **image-y-{index}.jpg** | _optional_
253
+ The same for [data-amount-x](#data-amount-x) but for images set in Y-axis.
174
254
 
175
- The filename pattern for Y-axis images. Must include {index}, which the library will replace with a number between 1 and [data-amount-y](#data-amount-y).
176
-
177
- ### <a name="data-amount"></a> data-amount (or amount)
178
-
255
+ ### <a name="data-amount-x"></a> data-amount-x (or amount-x)
179
256
  ###### Type: **Number** | Default: **36** | _optional_
180
257
 
181
- Amount of images to load for 360 view.
258
+ Amount of images to load in X-axis for 360 view .
182
259
 
183
260
  ### <a name="data-amount-y"></a> data-amount-y (or amount-y)
184
261
 
@@ -192,12 +269,24 @@ Amount of images to load in Y-axis for 360 view.
192
269
 
193
270
  Support for 360 spin by pressing arrow keys on keyboard.
194
271
 
272
+ ### data-keys-reverse (or keys-reverse)
273
+
274
+ ###### Type: **Bool** | Default: **false** | _optional_
275
+
276
+ invert arrow keys on keyboard.
277
+
195
278
  ### data-autoplay (or autoplay)
196
279
 
197
280
  ###### Type: **Bool** | Default: **false** | _optional_
198
281
 
199
282
  Autoplay 360 spin view on load.
200
283
 
284
+ ### data-play-once (or autoplay)
285
+
286
+ ###### Type: **Bool** | Default: **false** | _optional_
287
+
288
+ stops the autoplay after one complete cycle.
289
+
201
290
  ### data-autoplay-behavior (or autoplay-behavior)
202
291
 
203
292
  ###### Type: **String** | Default: **spin-x** | _optional_
@@ -206,8 +295,7 @@ Changing autoplay behavior
206
295
 
207
296
  Available behaviors (spin-x, spin-y, spin-xy, spin-yx)
208
297
 
209
- ### data-full-screen (or full-screen)
210
-
298
+ ### data-fullscreen (or fullscreen)
211
299
  ###### Type: **Bool** | Default: **false** | _optional_
212
300
 
213
301
  Open 360 spin view in full screen modal.
@@ -218,17 +306,46 @@ Open 360 spin view in full screen modal.
218
306
 
219
307
  Magnifier to zoom image.
220
308
 
221
- ### data-magnifier-in-fullscreen (or magnifier-in-fullscreen)
222
-
223
- ###### Type: **bool** | Default: **false** | _optional_
309
+ ### data-ratio (or ratio)
310
+ ###### Type: **Number** (width / height) or JSON object | Default: **none** | _optional_
311
+ #### `ratio`: string
224
312
 
225
- enable magnifier in fullscreen modal.
313
+ Setting the height relative to the container width according to the provided ratio</br>
226
314
 
227
- ### data-ratio (or ratio)
315
+ ```html
316
+ <div
317
+ class="cloudimage-360"
318
+ id="gurkha-suv"
319
+ data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
320
+ data-filename-x="orange-{index}.jpg"
321
+ data-amount-x="73"
322
+ data-ratio="2"
323
+ ></div>
324
+ ```
325
+ <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>
326
+ #### `ratio`: JSON
327
+ Setting the height relative to the container width at any window size.
228
328
 
229
- ###### Type: **Number** (height / width) | Default: **none** | _optional_
329
+ In the following example, the height should be 1.3 the container width at window size less than or equal to 567px
330
+ and 2.22 at window size less than or equal to 768px.
230
331
 
231
- Prevents page from jumping.
332
+ ```html
333
+ <div
334
+ class="cloudimage-360"
335
+ id="gurkha-suv"
336
+ data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
337
+ data-filename-x="orange-{index}.jpg"
338
+ data-amount-x="73"
339
+ data-ratio='{
340
+ "576": "1.3",
341
+ "768": "2.22",
342
+ "992": "2.23",
343
+ "1200": "3",
344
+ "2400": "3.2"
345
+ }'
346
+ ></div>
347
+ ```
348
+ <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>
232
349
 
233
350
  ### data-autoplay-reverse (or autoplay-reverse)
234
351
 
@@ -236,6 +353,12 @@ Prevents page from jumping.
236
353
 
237
354
  Autoplay 360 spin view on load.
238
355
 
356
+ ### data-disable-drag (or disable-drag)
357
+
358
+ ###### Type: **bool** | Default: **false** | _optional_
359
+
360
+ disable mouse drag.
361
+
239
362
  ### data-speed (or speed)
240
363
 
241
364
  ###### Type: **Number** | Default: **150** | _optional_
@@ -252,7 +375,7 @@ Speed Factor of changing frames on drag event.
252
375
 
253
376
  ###### Type: **Bool** | Default: **false** | _optional_
254
377
 
255
- Spin direction, by default it uses counterclockwise (image indexes from 1 to data-amount).
378
+ Spin direction, by default it uses counterclockwise (image indexes from 1 to data-amount-x).
256
379
 
257
380
  ### data-box-shadow (or box-shadow)
258
381
 
@@ -272,17 +395,11 @@ Display 360 view line at the bottom of container.
272
395
 
273
396
  Hide 360 view icon.
274
397
 
275
- ### data-logo-src (or logo-src)
276
-
277
- ###### Type: **String** | Default: **https://scaleflex.ultrafast.io/https://scaleflex.airstore.io/filerobot/js-cloudimage-360-view/360_view.svg** | _optional_
278
-
279
- URL of asset to use as the 360 view icon.
280
-
281
398
  ### data-control-reverse (or control-reverse)
282
399
 
283
400
  ###### Type: **Bool** | Default: **false** | _optional_
284
401
 
285
- Spin direction using controls, by default it uses counterclockwise (image indexes from 1 to data-amount).
402
+ Spin direction using controls, by default it uses counterclockwise (image indexes from 1 to data-amount-x).
286
403
 
287
404
  ### data-stop-at-edges (or stop-at-edges)
288
405
 
@@ -302,17 +419,16 @@ Bottom offset for 360 view line.
302
419
 
303
420
  Left zero padding on filename. For example: index-zero-base="4" => image index will be "0004"
304
421
 
305
- ### data-image-list (or image-list)
306
-
422
+ ### data-image-list-x (or data-image-list-x)
307
423
  ###### Type: **Array** | _optional_
308
424
 
309
- Option to add list of images instead of `folder` & `filename`.
425
+ Option to add list of images in x-oriantation instead of `folder` , `filename-x` & `amount-x`.
310
426
 
311
427
  example:
312
428
 
313
429
  ```javascript
314
430
  data-folder="https://scaleflex.airstore.io/demo/360-car/"
315
- data-image-list='[
431
+ data-image-list-x='[
316
432
  "iris-1.jpeg",
317
433
  "iris-4.jpeg",
318
434
  "https://scaleflex.airstore.io/demo/360-car/iris-12.jpeg",
@@ -320,56 +436,40 @@ data-image-list='[
320
436
  ]’
321
437
  ```
322
438
 
323
- ### data-lazyload (or lazyload)
324
-
325
- ###### Type: **Bool** | Default: **false** | _optional_
326
-
327
- Only 360 view images close to the client's viewport will be loaded, hence accelerating the page loading time. If set to true, an additional script must be included, see [Lazy loading](#lazy-loading)
328
- ### data-disable-pointer-zoom (or disable-pointer-zoom)
329
-
330
- ###### Type: **bool** | Default: **false** | _optional_
331
-
332
- Disable pointer zoom on desktop
333
-
334
- ### data-disable-pinch-zoom (or disable-pinch-zoom)
335
-
336
- ###### Type: **bool** | Default: **false** | _optional_
439
+ ### data-image-list-y (or data-image-list-y)
337
440
 
338
- Disable pinch zoom on mobile
339
- ### data-to-start-pointer-zoom (or to-start-pointer-zoom)
340
-
341
- ###### Type: **string** | Default: **scroll** | _optional_
342
-
343
- Events to start pointer zoom
344
-
345
- Available events (scroll, click)
346
-
347
- ### data-on-mouse-leave (or on-mouse-leave)
348
-
349
- ###### Type: **string** | Default: **none** | _optional_
350
-
351
- Functions called after mouse leave the container
441
+ ###### Type: **Array** | _optional_
352
442
 
353
- Available functions (resetZoom)
443
+ Option to add list of images in y-oriantation instead of `folder` , `filename-y` & `amount-y`.
354
444
 
355
- Multiple functions can be applied, separated by "," (comma)
445
+ example:
356
446
 
357
- ### data-pointer-zoom-factor (or pointer-zoom-factor)
447
+ ```javascript
448
+ data-folder="https://scaleflex.airstore.io/demo/360-car/"
449
+ data-image-list-y='[
450
+ "iris-2-y.jpeg",
451
+ "iris-6-y.jpeg",
452
+ "https://scaleflex.airstore.io/demo/360-car/iris-8-y.jpeg",
453
+ "https://scaleflex.airstore.io/demo/360-car/iris-30-y.jpeg"
454
+ ]’
455
+ ```
456
+ ### data-pointer-zoom (or pointer-zoom)
358
457
 
359
- ###### Type: **Number** | Default: **2** | _optional_
458
+ ###### Type: **Number** | Default: **none** | _optional_
360
459
 
361
- Pointer zoom scaling factor
362
- ### data-pinch-zoom-factor (or pinch-zoom-factor)
460
+ Option to scale images on click on it to provided value.
363
461
 
364
- ###### Type: **Number** | Default: **2** | _optional_
462
+ example:
365
463
 
366
- Pinch zoom scaling factor
464
+ ```javascript
465
+ data-pointer-zoom="3"
466
+ ```
367
467
 
368
- ### data-max-scale (or max-scale)
468
+ ### data-lazyload (or lazyload)
369
469
 
370
- ###### Type: **Number** | Default: **none** | _optional_
470
+ ###### Type: **Bool** | Default: **false** | _optional_
371
471
 
372
- Maximum scale that images can be resize to it with pointer or pinch zoom
472
+ Only 360 view images close to the client's viewport will be loaded, hence accelerating the page loading time. If set to true, an additional script must be included, see [Lazy loading](#lazy-loading)
373
473
  ### data-lazyload-selector (or lazyload-selector)
374
474
 
375
475
  ###### Type: **String** | Default: **lazyload** | _optional_
@@ -379,47 +479,47 @@ Helper class to apply lazy-loading depending on library you choose, see [Lazy lo
379
479
 
380
480
  ## <a name="controls"></a> Controls
381
481
 
382
- You can add controls by adding elements with the following classes: **cloudimage-360-prev**, **cloudimage-360-next**, **cloudimage-360-top**, **cloudimage-360-bottom**
482
+ You can add controls by adding elements with the following classes: **cloudimage-360-left**, **cloudimage-360-right**, **cloudimage-360-top**, **cloudimage-360-bottom
383
483
 
384
484
  ### Example CSS
385
485
  ```css
386
- .cloudimage-360 .cloudimage-360-prev, .cloudimage-360 .cloudimage-360-next {
486
+ .cloudimage-360 .cloudimage-360-left, .cloudimage-360 .cloudimage-360-right {
387
487
  padding: 8px;
388
488
  background: rgba(255, 255, 255, 0.5);
389
489
  border: none;
390
490
  border-radius: 4px;
391
491
  }
392
- .cloudimage-360 .cloudimage-360-prev:focus, .cloudimage-360 .cloudimage-360-next:focus {
492
+ .cloudimage-360 .cloudimage-360-left:focus, .cloudimage-360 .cloudimage-360-right:focus {
393
493
  outline: none;
394
494
  }
395
- .cloudimage-360 .cloudimage-360-prev {
495
+ .cloudimage-360 .cloudimage-360-left {
396
496
  display: none;
397
497
  position: absolute;
398
498
  z-index: 100;
399
499
  top: calc(50% - 15px);
400
500
  left: 20px;
401
501
  }
402
- .cloudimage-360 .cloudimage-360-next {
502
+ .cloudimage-360 .cloudimage-360-right {
403
503
  display: none;
404
504
  position: absolute;
405
505
  z-index: 100;
406
506
  top: calc(50% - 15px);
407
507
  right: 20px;
408
508
  }
409
- .cloudimage-360 .cloudimage-360-prev:before, .cloudimage-360 .cloudimage-360-next:before {
509
+ .cloudimage-360 .cloudimage-360-left:before, .cloudimage-360 .cloudimage-360-right:before {
410
510
  content: '';
411
511
  display: block;
412
512
  width: 30px;
413
513
  height: 30px;
414
514
  background: 50% 50% / cover no-repeat;
415
515
  }
416
- .cloudimage-360 .cloudimage-360-prev:before {
516
+ .cloudimage-360 .cloudimage-360-left:before {
417
517
  background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-left.svg');
418
518
  }
419
- .cloudimage-360 .cloudimage-360-next:before {
519
+ .cloudimage-360 .cloudimage-360-right:before {
420
520
  background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-right.svg');
421
521
  }
422
- .cloudimage-360 .cloudimage-360-prev.not-active, .cloudimage-360 .cloudimage-360-next.not-active {
522
+ .cloudimage-360 .cloudimage-360-left.not-active, .cloudimage-360 .cloudimage-360-right.not-active {
423
523
  opacity: 0.4;
424
524
  cursor: default;
425
525
  }
@@ -429,16 +529,167 @@ You can add controls by adding elements with the following classes: **cloudimage
429
529
  <div
430
530
  class="cloudimage-360"
431
531
  data-folder="https://scaleflex.airstore.io/demo/indoor/"
432
- data-filename="{index}.jpeg"
532
+ data-filename-x="{index}.jpeg"
433
533
  >
434
- <button class="cloudimage-360-prev"></button>
435
- <button class="cloudimage-360-next"></button>
534
+ <button class="cloudimage-360-left"></button>
535
+ <button class="cloudimage-360-right"></button>
436
536
  <button class="cloudimage-360-top"></button>
437
537
  <button class="cloudimage-360-bottom"></button>
438
538
  </div>
439
539
  ```
440
540
 
441
541
  <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>
542
+ ## <a name="hotspots"/> Hotspots or Markers
543
+ Display information about the product on specific areas. Once a hotspot is created it can be used on more than one image.
544
+ ### Requirements
545
+ 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.
546
+ Also we need to set an `id` attribute, we will need it to link the view with the hotspots config.
547
+
548
+ ### Create hotspots configuration
549
+ The hotspots config should be an array of objects, each object in the array indicates a single hotspot config.
550
+ 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.
551
+
552
+ example:
553
+
554
+ ```js
555
+ const HOTSPOTS_CONFIG = [
556
+ {
557
+ positions: [
558
+ { imageIndex: 0, xCoord: 527, yCoord: 319 },
559
+ { imageIndex: 1, xCoord: 524 },
560
+ { imageIndex: 2, xCoord: 520 },
561
+ { imageIndex: 3, xCoord: 498 },
562
+ { imageIndex: 4, xCoord: 470 },
563
+ { imageIndex: 5, xCoord: 441 },
564
+ ]
565
+ }
566
+ ]
567
+ ```
568
+ In the previous example, we have only set the Ycoord a single time at the image index 0.
569
+ So if the coord didn't change there's no need to reset it, it will already take the previous value.
570
+
571
+ Now we need to set the hotspot variant, we have three types of hotspots (link, popup, and custom), as it will be explained below.
572
+ ## Variant
573
+ ### Link
574
+ we need to provide the URL of the link and the link title.
575
+
576
+ example:
577
+
578
+ ```js
579
+ const HOTSPOTS_CONFIG = [
580
+ {
581
+ positions,
582
+ variant: {
583
+ title: 'New Gurkha Technical Specifications',
584
+ url: 'https://www.forcegurkha.co.in/specifications/',
585
+ newTab: true
586
+ }
587
+ }
588
+ ]
589
+ ```
590
+ ---
591
+ ### Popup
592
+ Only the property inserted will displayed.
593
+ | Property |Type | Default | Description |
594
+ | ------------- | ------------- | ------------- |------------- |
595
+ | 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 |
596
+ | title |String| null | Display title underneath the images |
597
+ | description| String | null | Display description underneath the title |
598
+ | moreDetailsUrl | String | null | Display a button underneath the description to navigate to a provided URL |
599
+ | moreDetailsTitle | String | null| Set the title of the more details button |
600
+
601
+ example:
602
+ ```js
603
+ const HOTSPOTS_CONFIG = [
604
+ {
605
+ positions,
606
+ variant: {
607
+ images: [
608
+ { src: 'https://scaleflex.cloudimg.io/v7/demo/360-assets/AIR_SNORKEL_FINAL_JPG.png?vh=88bccb', alt: 'air snorkel' }
609
+ ], // optional
610
+ title: 'Air Intake Snorkel', // optional
611
+ description: 'The snorkel gives the Gurkha an unmatched water-wading ability and ensures ample supply of fresh air for combustion.', // optional
612
+ moreDetailsUrl: 'https://forcegurkha.co.in', // optional
613
+ moreDetailsTitle: 'Read more' // optional
614
+ }
615
+ }
616
+ ]
617
+ ```
618
+ ---
619
+ ### Custom
620
+ Display any element in the DOM in a popup and link it with the hotspot.</br>
621
+ We will need to set the variant property value to the id of the element.
622
+
623
+ example:
624
+ ```js
625
+ const HOTSPOTS_CONFIG = [
626
+ {
627
+ positions,
628
+ variant: 'gurkha-suv'
629
+ }
630
+ ]
631
+ ```
632
+ ## PopupProps
633
+ Options to customize the hotspot popup.
634
+ ### Properties
635
+ | Property | Type | Defaullt |Description |
636
+ | ------------- | ------------- | ------------- | ------------- |
637
+ | popupSelector |String| null |Set className to the popup wrapper |
638
+ | open |Boolean | false |Open the popup |
639
+ | arrow |Boolean| true |Dipslay an arrow that points toward the hotspot element|
640
+ | offset|Array | [0, 0] |Set a distance between the hotspot element and the popup |
641
+ | placement|String| Auto|- we can adjust the position of the hotspot popup relative to the hotspot element. (top - bottom - left - right)|
642
+
643
+
644
+ example:
645
+ ```js
646
+ const HOTSPOTS_CONFIG = [
647
+ {
648
+ positions,
649
+ variant,
650
+ popupProps: {
651
+ popupSelector: 'air-intake-popup', // optional
652
+ offset: [20, 5], // optional
653
+ arrow: false, // optional
654
+ placement: 'bottom' // optional
655
+ },
656
+ indicatorSelector: 'first-hotspot-icon' // optional
657
+ }
658
+ ]
659
+ ```
660
+ ## Responsive hotspots
661
+ Now we need to make our hotspots responsive to have an accurate positioning in different screens.
662
+ we have to set `initialDimensions` property to every hotspot config. which indicates the dimension of the cloudimage-360 view.<br/>
663
+ hint: `data-info` can be used to get view size.
664
+
665
+ example:
666
+ ```js
667
+ const HOTSPOTS_CONFIG = [
668
+ {
669
+ positions,
670
+ variant,
671
+ popupProps,
672
+ indicatorSelector,
673
+ initialDimensions: [ 1170, 662 ]
674
+ }
675
+ ]
676
+ ```
677
+ ## Add Hotspots
678
+ we need this function to link the created config with the 360-view.
679
+ ```js
680
+ window.CI360.addHotspots(idOftheView, hotspotsConfig);
681
+ ```
682
+ example:
683
+ ```js
684
+ window.CI360.addHotspots("gurkha-suv", HOTSPOTS_CONFIG);
685
+ ```
686
+ <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>
687
+
688
+ ### data-responsive (or responsive)
689
+
690
+ ###### Type: **String** (Cloudimage token) | Default: **none** | _required for cloudimage responsive plugin_
691
+
692
+ Enables cloudimage responsive plugin for 360 view.
442
693
 
443
694
  ## <a name="cloudimage-responsive-integration"/> Cloudimage Responsive Integration
444
695
 
@@ -497,27 +748,6 @@ Lazy loading is not included into js-cloudimage-360-view by default. There are w
497
748
 
498
749
  [Implementation example with lozad.js](https://codesandbox.io/s/0185934m8p?fontsize=14)
499
750
 
500
- to save API calls you man want to use one of our cdn bundles:
501
-
502
- CDN link to js-cloudimage-360-view 1.1.0 + lazysizes 4.1.7
503
-
504
- ```javascript
505
- <script src="https://cdn.scaleflex.it/filerobot/js-cloudimage-360-view/v2.0.0.lazysizes.min.js"></script>
506
- ```
507
-
508
- CDN link to js-cloudimage-360-view 1.1.0 + yall.js 3.1.1
509
-
510
- ```javascript
511
- <script src="https://cdn.scaleflex.it/filerobot/js-cloudimage-360-view/v2.0.0.yall.min.js"></script>
512
- ```
513
-
514
- CDN link to js-cloudimage-360-view 1.1.0 + lozad.js 1.9.0
515
-
516
- ```javascript
517
- <script src="https://cdn.scaleflex.it/filerobot/js-cloudimage-360-view/v2.0.0.lozad.min.js"></script>
518
- ```
519
-
520
-
521
751
  ## <a name="best-practices"/> Best practices
522
752
 
523
753
  * In order to use cloudimage responsive with 360 view, your original (master) images should be stored on a server
@@ -544,4 +774,3 @@ All contributions are super welcome!
544
774
 
545
775
  ## <a name="license"></a>License
546
776
  JS Cloudimage 360 View is provided under the [MIT License](https://opensource.org/licenses/MIT)
547
-