js-cloudimage-360-view 3.0.0-beta.2 → 3.0.2

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