js-cloudimage-360-view 3.2.1 → 4.0.0-beta.10
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/.prettierrc +9 -0
- package/README.md +318 -721
- package/dist/js-cloudimage-360-view.min.css +1 -0
- package/dist/js-cloudimage-360-view.min.js +2111 -0
- package/package.json +30 -17
- package/.env +0 -3
- package/CHANGELOG.md +0 -175
- package/bin/deploy-bundle.js +0 -63
- package/dist/ci360.service.js +0 -1270
- package/dist/ci360.utils.js +0 -78
- package/dist/constants/auto-play-behavior.js +0 -13
- package/dist/constants/falsy-values.js +0 -8
- package/dist/constants/index.js +0 -39
- package/dist/constants/orientations.js +0 -12
- package/dist/constants/props-require-reload.js +0 -33
- package/dist/constants/regex.js +0 -10
- package/dist/index.js +0 -102
- package/dist/static/css/hotspots.css +0 -222
- package/dist/static/css/style.css +0 -230
- package/dist/utils/auto-play/get-speed-factor.js +0 -12
- package/dist/utils/auto-play/is-completed-one-cycle.js +0 -27
- package/dist/utils/auto-play/loop.js +0 -56
- package/dist/utils/class-names/add-class.js +0 -15
- package/dist/utils/class-names/remove-class.js +0 -14
- package/dist/utils/container-elements/apply-styles-to-container.js +0 -14
- package/dist/utils/container-elements/create-360-view-circle-icon.js +0 -14
- package/dist/utils/container-elements/create-360-view-icon.js +0 -13
- package/dist/utils/container-elements/create-box-shadow.js +0 -14
- package/dist/utils/container-elements/create-canvas.js +0 -14
- package/dist/utils/container-elements/create-close-fullscreen-icon.js +0 -12
- package/dist/utils/container-elements/create-fullscreen-icon.js +0 -12
- package/dist/utils/container-elements/create-fullscreen-modal.js +0 -18
- package/dist/utils/container-elements/create-icons-container.js +0 -13
- package/dist/utils/container-elements/create-inner-box.js +0 -13
- package/dist/utils/container-elements/create-loader.js +0 -13
- package/dist/utils/container-elements/create-magnifier-icon.js +0 -12
- package/dist/utils/container-elements/index.js +0 -96
- package/dist/utils/container-elements/remove-child-from-parent.js +0 -14
- package/dist/utils/controls/get-item-skipped.js +0 -11
- package/dist/utils/controls/init-controls.js +0 -68
- package/dist/utils/hotspots/attach-events/hide-popup.js +0 -13
- package/dist/utils/hotspots/attach-events/show-popup.js +0 -12
- package/dist/utils/hotspots/configs-error-handler.js +0 -23
- package/dist/utils/hotspots/create-popper-instace.js +0 -29
- package/dist/utils/hotspots/elements/create-carousel-dot.js +0 -20
- package/dist/utils/hotspots/elements/create-carousel-image.js +0 -18
- package/dist/utils/hotspots/elements/create-hotspot-icon.js +0 -55
- package/dist/utils/hotspots/elements/create-hotspot-popup-link.js +0 -19
- package/dist/utils/hotspots/elements/create-hotspots.js +0 -20
- package/dist/utils/hotspots/elements/create-images-carousel.js +0 -23
- package/dist/utils/hotspots/elements/create-modal-description.js +0 -13
- package/dist/utils/hotspots/elements/create-modal-title.js +0 -13
- package/dist/utils/hotspots/elements/create-model-elements.js +0 -49
- package/dist/utils/hotspots/elements/create-popup-arrow.js +0 -14
- package/dist/utils/hotspots/elements/create-popup.js +0 -55
- package/dist/utils/hotspots/elements/create-read-more-btn.js +0 -15
- package/dist/utils/hotspots/fill-empty-coord-with-previous.js +0 -21
- package/dist/utils/hotspots/generate-hotspots-configs.js +0 -48
- package/dist/utils/hotspots/generate-popup-config.js +0 -27
- package/dist/utils/hotspots/get-hotspot-icon.js +0 -12
- package/dist/utils/hotspots/get-hotspot-orientation.js +0 -17
- package/dist/utils/hotspots/get-hotspot-popup-node.js +0 -12
- package/dist/utils/hotspots/get-popup-node.js +0 -12
- package/dist/utils/hotspots/hide-hotspot-icon.js +0 -11
- package/dist/utils/hotspots/hide-hotspots-icons.js +0 -15
- package/dist/utils/hotspots/is-mouse-on-hotspot.js +0 -12
- package/dist/utils/hotspots/prepare-hotspots-positions.js +0 -22
- package/dist/utils/hotspots/set-current-slide.js +0 -21
- package/dist/utils/hotspots/toggle-popup-events.js +0 -19
- package/dist/utils/hotspots/update-hotspot-icon-position.js +0 -19
- package/dist/utils/hotspots/update-hotspots.js +0 -40
- package/dist/utils/image-src/generate-images-path.js +0 -33
- package/dist/utils/image-src/is-props-change-require-reload.js +0 -18
- package/dist/utils/index.js +0 -211
- package/dist/utils/load-images/images-from-folder/prepare-images-from-folder.js +0 -25
- package/dist/utils/load-images/images-from-list/prepare-images-from-list.js +0 -21
- package/dist/utils/load-images/lazyload/init-lazyload.js +0 -41
- package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-folder.js +0 -14
- package/dist/utils/load-images/lazyload/prepare-first-image/prepare-first-image-from-list.js +0 -20
- package/dist/utils/load-images/load-image-as-promise.js +0 -16
- package/dist/utils/load-images/load-images-relative-to-container-size.js +0 -19
- package/dist/utils/load-images/load-original-images.js +0 -44
- package/dist/utils/load-images/pad.js +0 -12
- package/dist/utils/load-images/preload-images.js +0 -28
- package/dist/utils/load-images/preload-original-images.js +0 -28
- package/dist/utils/magnify/get-current-original-image.js +0 -23
- package/dist/utils/magnify/get-cursor-position.js +0 -22
- package/dist/utils/magnify/magnify.js +0 -47
- package/dist/utils/magnify/move-magnifier.js +0 -39
- package/dist/utils/responsive/contain.js +0 -9
- package/dist/utils/responsive/fit.js +0 -29
- package/dist/utils/responsive/get-image-aspect-ratio.js +0 -31
- package/dist/utils/responsive/get-responsive-width-of-container.js +0 -11
- package/dist/utils/responsive/get-size-according-to-pixel-ratio.js +0 -15
- package/dist/utils/responsive/get-size-limit.js +0 -12
- package/dist/utils/spin-y/get-moving-direction.js +0 -18
- package/dist/utils/zoom/generate-zoom-in-steps.js +0 -18
- package/dist/utils/zoom/generate-zoom-out-steps.js +0 -18
- package/yarn-error.log +0 -101
package/README.md
CHANGED
|
@@ -1,815 +1,412 @@
|
|
|
1
|
-
[](https://github.com/scaleflex/js-cloudimage-360-view/releases)
|
|
2
|
-
[](https://img.shields.io/bundlephobia/min/js-cloudimage-360-view)
|
|
3
|
-
[](https://img.shields.io/npm/dt/js-cloudimage-360-view?logoColor=orange)
|
|
4
|
-
[](#contributing)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://www.scaleflex.com/en/home)
|
|
7
|
-
[](https://www.cloudimage.io/en/home)
|
|
8
|
-
|
|
9
1
|
<p align="center">
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
<a href="https://www.cloudimage.io/#gh-light-mode-only">
|
|
3
|
+
<img
|
|
4
|
+
alt="cloudimage logo"
|
|
5
|
+
src="https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d&w=350">
|
|
6
|
+
</a>
|
|
15
7
|
</p>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
JS Cloudimage 360 View
|
|
19
|
-
</h1>
|
|
20
|
-
|
|
8
|
+
<p align="center"><h1 align="center">JS Cloudimage 360 View
|
|
9
|
+
</h1></p>
|
|
21
10
|
<p align="center">
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
<em>360 Views, Infinite Possibilities: Unleash the Power of js-cloudimage-360-view!</em>
|
|
12
|
+
</p>
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://github.com/scaleflex/js-cloudimage-360-view/releases">
|
|
15
|
+
<img src="https://img.shields.io/github/v/release/scaleflex/js-cloudimage-360-view" alt="Release">
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://img.shields.io/bundlephobia/min/js-cloudimage-360-view">
|
|
18
|
+
<img src="https://img.shields.io/bundlephobia/min/js-cloudimage-360-view" alt="Size">
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://img.shields.io/npm/dt/js-cloudimage-360-view?logoColor=orange">
|
|
21
|
+
<img src="https://img.shields.io/npm/dt/js-cloudimage-360-view?logoColor=orange" alt="Download">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="#contributing">
|
|
24
|
+
<img src="https://img.shields.io/badge/contributions-welcome-orange.svg" alt="Contributions welcome">
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://opensource.org/licenses/MIT">
|
|
27
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
|
|
28
|
+
</a>
|
|
29
|
+
<a href="https://www.scaleflex.com/en/home">
|
|
30
|
+
<img src="https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20-Scaleflex%20team-6986fa.svg" alt="Scaleflex team">
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://www.cloudimage.io/en/home">
|
|
33
|
+
<img src="https://img.shields.io/badge/Powered%20by-cloudimage-blue" alt="Cloudimage">
|
|
34
|
+
</a>
|
|
35
|
+
</p>
|
|
36
|
+
<p align="center"><!-- default option, no dependency badges. -->
|
|
33
37
|
</p>
|
|
34
|
-
<p align="center">A simple, interactive resource that can be used to provide a virtual tour of your product.</p>
|
|
35
38
|
<p align="center">
|
|
36
|
-
|
|
37
|
-
alt="The Lounge"
|
|
38
|
-
src="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/demos/assets/a2.gif">
|
|
39
|
+
<!-- default option, no dependency badges. -->
|
|
39
40
|
</p>
|
|
41
|
+
<br>
|
|
42
|
+
|
|
43
|
+
## 🔗 Table of Contents
|
|
44
|
+
|
|
45
|
+
- [📍 Overview](#-overview)
|
|
46
|
+
- [👾 Features](#-features)
|
|
47
|
+
- [🚀 Getting Started](#-getting-started)
|
|
48
|
+
- [⚙️ Installation](#installation)
|
|
49
|
+
- [Option 1: Add via CDN](#option-1-add-via-cdn)
|
|
50
|
+
- [Option 2: Install with Package Manager](#option-2-install-with-package-manager)
|
|
51
|
+
- [🛠️ Usage](#-usage)
|
|
52
|
+
- [⚙️ Configuration Options](#configuration-options)
|
|
53
|
+
- [Method 1: Initialization via JavaScript Code](#method-1-initialization-via-javascript-code)
|
|
54
|
+
- [Method 2: Initialization via Data Attributes](#method-2-initialization-via-data-attributes)
|
|
55
|
+
- [🗺️ Hotspots or Markers Configuration](#-hotspots-or-markers-configuration)
|
|
56
|
+
- [🗺️ Cloudimage responsive integration](#-cloudimage-responsive-integration)
|
|
57
|
+
- [🔧 Methods](#-methods)
|
|
58
|
+
- [getViewById](#getviewbyidid)
|
|
59
|
+
- [getViews](#getviews)
|
|
60
|
+
- [updateView](#updateviewid-config)
|
|
61
|
+
- [onMoveHandler](#onmovehandlermovingdirection-itemsSkippedX-itemsSkippedY)
|
|
62
|
+
- [🔰 Contributing](#-contributing)
|
|
63
|
+
- [🎗 License](#-license)
|
|
40
64
|
|
|
41
|
-
|
|
65
|
+
---
|
|
42
66
|
|
|
43
|
-
|
|
44
|
-
* [Step 1: Installation](#installation)
|
|
45
|
-
* [Step 2: Initialize](#initialize)
|
|
46
|
-
* [Methods](#methods)
|
|
47
|
-
* [Customize elements](#customize-elements)
|
|
48
|
-
* [Configuration](#configuration)
|
|
49
|
-
* [Controls](#controls)
|
|
50
|
-
* [Spin in X and Y axis](#spin_x_y)
|
|
51
|
-
* [Hotspots or Markers](#hotspots)
|
|
52
|
-
* [Cloudimage responsive integration](#cloudimage-responsive-integration)
|
|
53
|
-
* [Lazy loading integration](#lazy-loading)
|
|
54
|
-
* [Best practices](#best-practices)
|
|
55
|
-
* [Browser support](#browser_support)
|
|
56
|
-
* [Filerobot UI Family](#ui_family)
|
|
57
|
-
* [Contributing](#contributing)
|
|
58
|
-
* [License](#license)
|
|
67
|
+
## 📍 Overview
|
|
59
68
|
|
|
69
|
+
The js-cloudimage-360-view project revolutionizes interactive 360-degree image viewing experiences. With robust build and deployment scripts, it simplifies development processes. Key features include viewer initialization, hotspot functionality, and dynamic configuration utilities. Ideal for e-commerce platforms and virtual tours, it offers immersive and engaging user experiences.
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
---
|
|
72
|
+
## 👾 Features
|
|
62
73
|
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
| | Feature | Summary |
|
|
75
|
+
| :--- | :---: | :--- |
|
|
76
|
+
| ⚙️ | **Image Viewing** | <ul><li>Enables interactive 360-degree image viewing with smooth transitions</li><li>Supports high-resolution images for detailed visualization</li><li>Touch and drag navigation for user-friendly experiences</li></ul> |
|
|
77
|
+
| 🔩 | **Customization** | <ul><li>Offers customizable settings for rotation speed, direction, and initial angle</li><li>Supports multiple display modes and responsive adjustments</li><li>Adaptable to various website designs for seamless integration</li></ul> |
|
|
78
|
+
| 📄 | **Documentation** | <ul><li>Comprehensive guides on installation and usage</li><li>Step-by-step instructions for integration and configuration</li><li>Provides examples to help users implement the plugin quickly</li></ul> |
|
|
79
|
+
| 🔌 | **Framework Support** | <ul><li>Easily integrates with popular JavaScript frameworks</li><li>Includes clear instructions for setup in React, Vue, Angular, and vanilla JavaScript</li><li>Adjustable settings to adapt to project requirements</li></ul> |
|
|
80
|
+
| ⚡️ | **Performance** | <ul><li>Optimized for fast loading and minimal resource consumption</li><li>Utilizes lazy loading and caching to improve load times</li><li>Lightweight script ensures minimal impact on page performance</li></ul> |
|
|
81
|
+
| 📦 | **Dependencies** | <ul><li>Minimal dependencies for essential functionality only</li></ul> |
|
|
65
82
|
|
|
66
|
-
|
|
83
|
+
---
|
|
67
84
|
|
|
68
|
-
|
|
85
|
+
## 🚀 Getting Started
|
|
69
86
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
## ⚙️ Installation
|
|
88
|
+
|
|
89
|
+
You can install `js-cloudimage-360-view` using one of the following methods:
|
|
73
90
|
|
|
74
|
-
|
|
91
|
+
### Option 1: Add via CDN
|
|
75
92
|
|
|
76
|
-
|
|
77
|
-
**server folder path**, **file name** and amount of images:
|
|
93
|
+
Include the CDN link to the `js-cloudimage-360-view` library at the end of your `<body>` tag. Additionally, make sure to include the corresponding CSS file for proper styling:
|
|
78
94
|
|
|
79
95
|
```html
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
id="gurkha-suv"
|
|
83
|
-
data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
|
|
84
|
-
data-filename-x="orange-{index}.jpg"
|
|
85
|
-
data-amount-x="73"
|
|
86
|
-
></div>
|
|
96
|
+
<link rel="stylesheet" href="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/latest/js-cloudimage-360-view.min.css">
|
|
97
|
+
<script src="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/latest/js-cloudimage-360-view.min.js?func=proxy"></script>
|
|
87
98
|
```
|
|
88
99
|
|
|
89
|
-
|
|
100
|
+
### Note:
|
|
101
|
+
To ensure the `js-cloudimage-360-view` functionality works correctly, **you must also include the CSS file**. This is crucial for proper styling and display of the plugin.
|
|
90
102
|
|
|
91
|
-
|
|
103
|
+
This is the quickest way to get started without additional setup.
|
|
104
|
+
#### Option 2: Install with Package Manager
|
|
92
105
|
|
|
93
|
-
|
|
106
|
+
You can add `js-cloudimage-360-view` to your project using either npm or Yarn:
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
For npm:
|
|
96
109
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```javascript
|
|
100
|
-
window.CI360.init();
|
|
110
|
+
```sh
|
|
111
|
+
npm install js-cloudimage-360-view
|
|
101
112
|
```
|
|
102
113
|
|
|
103
|
-
|
|
104
|
-
> ```javascript
|
|
105
|
-
> <script>window.CI360 = { notInitOnLoad: true }</script>
|
|
106
|
-
> <script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/3.0./js-cloudimage-360-view.min.js"></script>
|
|
107
|
-
> <script>window.CI360.init(); // initialize the plugin when you need</script>
|
|
108
|
-
> ```
|
|
114
|
+
For Yarn:
|
|
109
115
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
###### Type: **Function**
|
|
113
|
-
|
|
114
|
-
```javascript
|
|
115
|
-
window.CI360.add(idOftheView: string);
|
|
116
|
+
```sh
|
|
117
|
+
yarn add js-cloudimage-360-view
|
|
116
118
|
```
|
|
117
|
-
lazy init cloudimage-360 view by id.
|
|
118
|
-
###### arguments
|
|
119
|
-
`idOftheView`: string
|
|
120
|
-
The id of the new view
|
|
121
119
|
|
|
122
|
-
|
|
120
|
+
Then, import it in your JavaScript file:
|
|
123
121
|
|
|
124
|
-
### update
|
|
125
|
-
|
|
126
|
-
###### Type: **Function**
|
|
127
122
|
```javascript
|
|
128
|
-
|
|
123
|
+
import CloudImage360 from 'js-cloudimage-360-view';
|
|
129
124
|
```
|
|
130
|
-
Update cloudimage 360 viewer instance.<br/>
|
|
131
|
-
For any update in source attributes after plugin initialization (e.g. `data-folder`, `data-filename-x`, `data-amount-y`),
|
|
132
|
-
the plugin will re-init.
|
|
133
|
-
###### arguments
|
|
134
|
-
`idOftheView`: string
|
|
135
|
-
The id of the new view
|
|
136
|
-
|
|
137
|
-
`forceUpdate`: bool
|
|
138
|
-
Force the view to reinitialize.
|
|
139
125
|
|
|
140
|
-
|
|
141
|
-
<div
|
|
142
|
-
class="cloudimage-360"
|
|
143
|
-
id="gurkha-suv"
|
|
144
|
-
data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
|
|
145
|
-
data-filename-x="orange-{index}.jpg"
|
|
146
|
-
data-amount-x="73"
|
|
147
|
-
></div>
|
|
148
|
-
```
|
|
149
|
-
```javascript
|
|
150
|
-
window.CI360.update('gurkha-suv');
|
|
151
|
-
```
|
|
126
|
+
OR
|
|
152
127
|
|
|
153
128
|
```javascript
|
|
154
|
-
window.CI360
|
|
129
|
+
window.CI360
|
|
155
130
|
```
|
|
156
131
|
|
|
157
|
-
<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>
|
|
158
132
|
|
|
159
|
-
|
|
133
|
+
Choose the method that best suits your project setup, and refer to the documentation for configuration options and usage examples.
|
|
160
134
|
|
|
161
|
-
|
|
135
|
+
### 🛠️ Usage
|
|
162
136
|
|
|
163
|
-
|
|
137
|
+
To use `js-cloudimage-360-view`, you need to initialize an instance of the viewer. You can either initialize a specific view or initialize all instances with a common selector.
|
|
164
138
|
|
|
165
|
-
|
|
166
|
-
window.CI360.destroy();
|
|
167
|
-
```
|
|
168
|
-
<a href="https://codesandbox.io/s/js-cloudimage-360-view-examples-03pb2t">
|
|
169
|
-
<img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
|
|
139
|
+
#### Initialize a Single View
|
|
170
140
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
###### Type: **Function**
|
|
174
|
-
|
|
175
|
-
Get the {index} of the image that is being viewed.
|
|
141
|
+
To initialize a single 360-degree view, use the following code:
|
|
176
142
|
|
|
177
143
|
```javascript
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
###### arguments
|
|
181
|
-
`idOfInstance`: string
|
|
182
|
-
The id of the instance
|
|
183
|
-
|
|
184
|
-
`oriantation`: string
|
|
185
|
-
The oriantation of the active index
|
|
186
|
-
|
|
187
|
-
## <a name="customize-elements"></a> Customize elements
|
|
188
|
-
|
|
189
|
-
You can customize elements by adding the following classes:
|
|
190
|
-
|
|
191
|
-
### Example CSS
|
|
192
|
-
```css
|
|
193
|
-
.cloudimage-360-icons-container {
|
|
194
|
-
top: 5px;
|
|
195
|
-
right: 5px;
|
|
196
|
-
}
|
|
197
|
-
.cloudimage-360-fullscreen-modal {
|
|
198
|
-
top: 0;
|
|
199
|
-
bottom: 0;
|
|
200
|
-
}
|
|
201
|
-
.cloudimage-360-magnifier-icon {
|
|
202
|
-
background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/loupe.svg) 50% 50% / cover no-repeat;
|
|
203
|
-
}
|
|
204
|
-
.cloudimage-360-close-fullscreen-icon {
|
|
205
|
-
background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/cross.svg) 50% 50% / cover no-repeat;
|
|
206
|
-
}
|
|
207
|
-
.cloudimage-360-view-360-circle {
|
|
208
|
-
margin: auto;
|
|
209
|
-
}
|
|
210
|
-
.cloudimage-360-loader {
|
|
211
|
-
margin: auto;
|
|
212
|
-
}
|
|
213
|
-
.cloudimage-360-view-360-icon {
|
|
214
|
-
background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/360_view.svg) 50% 50% / cover no-repeat;
|
|
215
|
-
}
|
|
216
|
-
.cloudimage-360-box-shadow {
|
|
217
|
-
top: 0;
|
|
218
|
-
left: 0;
|
|
219
|
-
}
|
|
220
|
-
.cloudimage-360-img-magnifier-glass {
|
|
221
|
-
border: 3px solid #000;
|
|
222
|
-
border-radius: 50%;
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
## <a name="configuration"></a> Config
|
|
144
|
+
const cloudimage360 = new CloudImage360();
|
|
227
145
|
|
|
228
|
-
|
|
146
|
+
const suvCarContainer = document.getElementById('gurkha-suv');
|
|
229
147
|
|
|
230
|
-
|
|
148
|
+
const config = {
|
|
149
|
+
folder: 'https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/',
|
|
150
|
+
filenameX: 'orange-{index}.jpg',
|
|
151
|
+
amountX: 73,
|
|
152
|
+
responsive: 'scaleflex',
|
|
153
|
+
};
|
|
231
154
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
### data-folder (or folder)
|
|
235
|
-
|
|
236
|
-
###### Type: **String(url)** | _required_
|
|
237
|
-
|
|
238
|
-
Your images folder on server.
|
|
239
|
-
### data-api-version (or api-version)
|
|
155
|
+
instance.init(suvCarContainer, config);
|
|
156
|
+
```
|
|
240
157
|
|
|
241
|
-
|
|
158
|
+
#### Initialize All Instances
|
|
242
159
|
|
|
243
|
-
|
|
160
|
+
To initialize all instances with a common selector, use the following code:
|
|
244
161
|
|
|
245
|
-
- set a specific version of API
|
|
246
|
-
```javascript
|
|
247
|
-
data-api-version="v7"
|
|
248
|
-
```
|
|
249
|
-
- disable API version
|
|
250
162
|
```javascript
|
|
251
|
-
|
|
163
|
+
instance.initAll('.cloudimage-360');
|
|
252
164
|
```
|
|
253
|
-
### data-filename-x (or filename-x)
|
|
254
|
-
|
|
255
|
-
###### Type: **String** | Default: **image-{index}.jpg** | _optional_
|
|
256
|
-
|
|
257
|
-
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).
|
|
258
|
-
|
|
259
|
-
### data-filename-y (or filename-y)
|
|
260
|
-
|
|
261
|
-
###### Type: **String** | Default: **image-y-{index}.jpg** | _optional_
|
|
262
|
-
The same for [data-amount-x](#data-amount-x) but for images set in Y-axis.
|
|
263
165
|
|
|
264
|
-
|
|
265
|
-
###### Type: **Number** | Default: **36** | _optional_
|
|
166
|
+
This will apply the 360-degree viewer to all elements matching the specified selector.
|
|
266
167
|
|
|
267
|
-
Amount of images to load in X-axis for 360 view .
|
|
268
168
|
|
|
269
|
-
###
|
|
169
|
+
### ⚙️ Configuration Options
|
|
270
170
|
|
|
271
|
-
|
|
171
|
+
When initializing the `js-cloudimage-360-view`, you can customize various configuration options. Below is a list of available options, their required status, default values, and the corresponding data attributes you can use in HTML.
|
|
272
172
|
|
|
273
|
-
|
|
173
|
+
#### Method 1: Initialization via JavaScript Code
|
|
174
|
+
To initialize a view programmatically, use the following configuration options:
|
|
274
175
|
|
|
275
|
-
### data-keys (or keys)
|
|
276
176
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
Support for 360 spin by pressing arrow keys on keyboard.
|
|
280
|
-
|
|
281
|
-
### data-keys-reverse (or keys-reverse)
|
|
282
|
-
|
|
283
|
-
###### Type: **Bool** | Default: **false** | _optional_
|
|
284
|
-
|
|
285
|
-
invert arrow keys on keyboard.
|
|
286
|
-
|
|
287
|
-
### data-autoplay (or autoplay)
|
|
288
|
-
|
|
289
|
-
###### Type: **Bool** | Default: **false** | _optional_
|
|
290
|
-
|
|
291
|
-
Autoplay 360 spin view on load.
|
|
292
|
-
|
|
293
|
-
### data-play-once (or autoplay)
|
|
294
|
-
|
|
295
|
-
###### Type: **Bool** | Default: **false** | _optional_
|
|
296
|
-
|
|
297
|
-
stops the autoplay after one complete cycle.
|
|
298
|
-
|
|
299
|
-
### data-autoplay-behavior (or autoplay-behavior)
|
|
300
|
-
|
|
301
|
-
###### Type: **String** | Default: **spin-x** | _optional_
|
|
302
|
-
|
|
303
|
-
Changing autoplay behavior
|
|
304
|
-
|
|
305
|
-
Available behaviors (spin-x, spin-y, spin-xy, spin-yx)
|
|
306
|
-
|
|
307
|
-
### data-fullscreen (or fullscreen)
|
|
308
|
-
###### Type: **Bool** | Default: **false** | _optional_
|
|
309
|
-
|
|
310
|
-
Open 360 spin view in full screen modal.
|
|
311
|
-
|
|
312
|
-
### data-magnifier (or magnifier)
|
|
313
|
-
|
|
314
|
-
###### Type: **Number** | Default: **none** | _optional_
|
|
315
|
-
|
|
316
|
-
Magnifier to zoom image.
|
|
317
|
-
|
|
318
|
-
### data-ratio (or ratio)
|
|
319
|
-
###### Type: **Number** (width / height) or JSON object | Default: **none** | _optional_
|
|
320
|
-
#### `ratio`: string
|
|
321
|
-
|
|
322
|
-
Setting the height relative to the container width according to the provided ratio</br>
|
|
177
|
+
#### Method 2: Initialization via Data Attributes
|
|
178
|
+
You can also initialize the view using HTML data attributes, which correspond to the configuration options listed below.
|
|
323
179
|
|
|
180
|
+
For example:
|
|
324
181
|
```html
|
|
325
|
-
<div
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
></div>
|
|
333
|
-
```
|
|
334
|
-
<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>
|
|
335
|
-
#### `ratio`: JSON
|
|
336
|
-
Setting the height relative to the container width at any window size.
|
|
337
|
-
|
|
338
|
-
In the following example, the height should be 1.3 the container width at window size less than or equal to 567px
|
|
339
|
-
and 2.22 at window size less than or equal to 768px.
|
|
340
|
-
|
|
341
|
-
```html
|
|
342
|
-
<div
|
|
343
|
-
class="cloudimage-360"
|
|
344
|
-
id="gurkha-suv"
|
|
345
|
-
data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
|
|
346
|
-
data-filename-x="orange-{index}.jpg"
|
|
347
|
-
data-amount-x="73"
|
|
348
|
-
data-ratio='{
|
|
349
|
-
"576": "1.3",
|
|
350
|
-
"768": "2.22",
|
|
351
|
-
"992": "2.23",
|
|
352
|
-
"1200": "3",
|
|
353
|
-
"2400": "3.2"
|
|
354
|
-
}'
|
|
355
|
-
></div>
|
|
182
|
+
<div id="gurkha-suv"
|
|
183
|
+
data-folder="/path/to/images/"
|
|
184
|
+
data-api-version="v7"
|
|
185
|
+
data-amount-x="73"
|
|
186
|
+
data-speed="80"
|
|
187
|
+
data-draggable="true">
|
|
188
|
+
</div>
|
|
356
189
|
```
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
###
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
### data-bottom-circle-offset (or bottom-circle-offset)
|
|
420
|
-
|
|
421
|
-
###### Type: **Number** | Default: **5** | _optional_
|
|
422
|
-
|
|
423
|
-
Bottom offset for 360 view line.
|
|
424
|
-
|
|
425
|
-
### data-index-zero-base (or index-zero-base)
|
|
426
|
-
|
|
427
|
-
###### Type: **Number** | _optional_
|
|
428
|
-
|
|
429
|
-
Left zero padding on filename. For example: index-zero-base="4" => image index will be "0004"
|
|
430
|
-
|
|
431
|
-
### data-image-list-x (or data-image-list-x)
|
|
432
|
-
###### Type: **Array** | _optional_
|
|
433
|
-
|
|
434
|
-
Option to add list of images in x-oriantation instead of `folder` , `filename-x` & `amount-x`.
|
|
435
|
-
|
|
436
|
-
example:
|
|
437
|
-
|
|
190
|
+
| Option | Data Attribute | Required | Default Value | Description |
|
|
191
|
+
| ---------------------| --------------------------| -------- | ----------------------------------------------- | ------------------------------------------------- |
|
|
192
|
+
| `folder` | `data-folder` | Yes | `'/'` | The path to the folder containing the images. |
|
|
193
|
+
| `apiVersion` | `data-api-version` | No | `'v7'` | The API version to use. |
|
|
194
|
+
| `filenameX` | `data-filename-x` | Yes | `'image-{index}.jpg'` | The filename pattern for the X-axis images. |
|
|
195
|
+
| `filenameY` | `data-filename-y` | No | `null` | The filename pattern for the Y-axis images (optional). |
|
|
196
|
+
| `imageListX` | `data-image-list-x` | No | `null` | An array of images for the X-axis (optional). |
|
|
197
|
+
| `imageListY` | `data-image-list-y` | No | `null` | An array of images for the Y-axis (optional). |
|
|
198
|
+
| `indexZeroBase` | `data-index-zero-base` | No | `0` | Whether the index starts from 0. |
|
|
199
|
+
| `amountX` | `data-amount-x` | Yes | `0` | Total number of X-axis images. |
|
|
200
|
+
| `amountY` | `data-amount-y` | No | `0` | Total number of Y-axis images (optional). |
|
|
201
|
+
| `speed` | `data-speed` | No | `80` | The speed of the rotation in milliseconds. |
|
|
202
|
+
| `dragSpeed` | `data-drag-speed` | No | `150` | The speed when dragging the image. |
|
|
203
|
+
| `draggable` | `data-draggable` | No | `true` | Enables dragging functionality. |
|
|
204
|
+
| `swipeable` | `data-swipeable` | No | `true` | Enables swipe functionality on touch devices. |
|
|
205
|
+
| `keys` | `data-keys` | No | `false` | Enables keyboard navigation. |
|
|
206
|
+
| `keysReverse` | `data-keys-reverse` | No | `false` | Reverses keyboard navigation controls. |
|
|
207
|
+
| `autoplay` | `data-autoplay` | No | `false` | Automatically plays the rotation. |
|
|
208
|
+
| `autoplayBehavior` | `data-autoplay-behavior` | No | `AUTOPLAY_BEHAVIOR.SPIN_X` | Defines how autoplay behaves. |
|
|
209
|
+
| `playOnce` | `data-play-once` | No | `false` | Plays the animation only once. |
|
|
210
|
+
| `autoplayReverse` | `data-autoplay-reverse` | No | `false` | Plays the autoplay in reverse. |
|
|
211
|
+
| `pointerZoom` | `data-pointer-zoom` | No | `0` | Defines the zoom level on pointer hover. |
|
|
212
|
+
| `fullscreen` | `data-fullscreen` | No | `false` | Enables fullscreen mode. |
|
|
213
|
+
| `magnifier` | `data-magnifier` | No | `null` | Defines the magnification level (optional). |
|
|
214
|
+
| `bottomCircle` | `data-bottom-circle` | No | `true` | Displays the bottom circle navigation. |
|
|
215
|
+
| `bottomCircleOffset` | `data-bottom-circle-offset`| No | `5` | The offset of the bottom circle from the container.|
|
|
216
|
+
| `ciToken` | `data-responsive` | No | `null` | Token for Cloudimage API authentication (optional). [🗺️ Cloudimage responsive integration](#-cloudimage-responsive-integration) |
|
|
217
|
+
| `ciFilters` | `data-filters` | No | `null` | Filters applied to Cloudimage images (optional). |
|
|
218
|
+
| `ciTransformation` | `data-transformation` | No | `null` | Transformations for Cloudimage images (optional). |
|
|
219
|
+
| `lazyload` | `data-lazyload` | No | `true` | Enables lazy loading of images. |
|
|
220
|
+
| `dragReverse` | `data-drag-reverse` | No | `false` | Reverses drag direction. |
|
|
221
|
+
| `stopAtEdges` | `data-stop-at-edges` | No | `false` | Stops the rotation at the edges. |
|
|
222
|
+
| `imageInfo` | `data-info` | No | `false` | Displays image information. |
|
|
223
|
+
| `initialIconShown` | `data-initial-icon` | No | `true` | Shows the initial icon on load. |
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
The library will automatically read these attributes to configure the instance.
|
|
227
|
+
|
|
228
|
+
### 🗺️ Hotspots or Markers Configuration
|
|
229
|
+
|
|
230
|
+
An array defines the configuration for hotspots or markers that can be displayed on the 360 view. Each hotspot can provide additional information or interactivity.
|
|
231
|
+
#### Hotspot Configuration Structure
|
|
232
|
+
Each hotspot configuration consists of the following properties:
|
|
233
|
+
|
|
234
|
+
| Property | Required | Description |
|
|
235
|
+
| --------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
|
|
236
|
+
| `id` | Yes | A unique identifier for the hotspot. |
|
|
237
|
+
| `orientation` | Yes | The orientation of the hotspot (e.g., `'x'` for X-axis). |
|
|
238
|
+
| `containerSize` | Yes | An array defining the width and height of the container in pixels (e.g., `[width, height]`). This size represents the dimensions of the container when you first start setting the hotspots. |
|
|
239
|
+
| `positions` | Yes | An object where keys are indices (image indexes) representing the position of the hotspot for specific images. |
|
|
240
|
+
| `content` | Yes | HTML content to display in the tooltip when the hotspot is hovered or clicked. |
|
|
241
|
+
| `onClick` | No | A function that defines the behavior when the hotspot is clicked (optional). |
|
|
242
|
+
|
|
243
|
+
#### Positions
|
|
244
|
+
The `positions` property is an object where:
|
|
245
|
+
- The key is the index of the image in the 360 view (e.g., 6, 7, 8, ...).
|
|
246
|
+
- The value is an object with `x` and `y` properties, representing the coordinates of the hotspot on the image.
|
|
247
|
+
|
|
248
|
+
If either the `x` or `y` value is `null`, it means that the hotspot will take the coordinates from the previous defined position for that index.
|
|
249
|
+
|
|
250
|
+
For example:
|
|
438
251
|
```javascript
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
252
|
+
positions: {
|
|
253
|
+
6: { x: 607, y: 246 },
|
|
254
|
+
7: { x: 619, y: null }, // y is null, so it takes the previous y (246)
|
|
255
|
+
8: { x: 630, y: null }, // y is null, so it takes the previous y (246)
|
|
256
|
+
9: { x: 637, y: null }, // y is null, so it takes the previous y (246)
|
|
257
|
+
10: { x: 642, y: null }, // y is null, so it takes the previous y (246)
|
|
258
|
+
},
|
|
446
259
|
```
|
|
447
260
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
###### Type: **Array** | _optional_
|
|
451
|
-
|
|
452
|
-
Option to add list of images in y-oriantation instead of `folder` , `filename-y` & `amount-y`.
|
|
453
|
-
|
|
454
|
-
example:
|
|
455
|
-
|
|
261
|
+
#### Example Hotspot Configuration
|
|
262
|
+
Here's an example configuration for multiple hotspots:
|
|
456
263
|
```javascript
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
264
|
+
const GURKHA_SUV_HOTSPOTS_CONFIG = [
|
|
265
|
+
{
|
|
266
|
+
id: 'hotspot-1',
|
|
267
|
+
orientation: 'x',
|
|
268
|
+
containerSize: [1170, 663],
|
|
269
|
+
positions: {
|
|
270
|
+
0: { x: 527, y: 319 },
|
|
271
|
+
1: { x: 527, y: 319 },
|
|
272
|
+
2: { x: 527, y: null }, // Takes the previous position
|
|
273
|
+
3: { x: 498, y: null }, // Takes the previous y (319)
|
|
274
|
+
4: { x: 470, y: null }, // Takes the previous y (319)
|
|
275
|
+
// Additional positions...
|
|
276
|
+
},
|
|
277
|
+
content: '<div class="tooltip">Info about Hotspot 1</div>',
|
|
278
|
+
},
|
|
279
|
+
// Additional hotspots...
|
|
280
|
+
];
|
|
464
281
|
```
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
282
|
+
In the example above, the keys (0, 1, 2, 3, 4, ...) represent image indexes. If the `y` value is `null`, it inherits the `y` coordinate from the previous defined position. This allows for easier configuration and reduces redundancy.
|
|
283
|
+
|
|
284
|
+
### 🎨 Styling
|
|
285
|
+
The following class names are used for styling various elements within the 360-degree viewer and hotspot functionality. Each class serves a specific purpose in controlling the appearance and behavior of the component.
|
|
286
|
+
| Class Name | Description |
|
|
287
|
+
| -------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
288
|
+
| `cloudimage-360-transition-overlay` | Applies styling for the overlay that appears during transitions. |
|
|
289
|
+
| `cloudimage-360-button` | Styles the main button for interacting with the 360 view. |
|
|
290
|
+
| `cloudimage-360-magnifier-button` | Styles the button that activates the magnifier feature within the 360 view. |
|
|
291
|
+
| `cloudimage-loading-spinner` | Styles the loading spinner displayed while the images are being loaded. |
|
|
292
|
+
| `cloudimage-initial-icon` | Styles the initial icon displayed before the 360 view is fully loaded. |
|
|
293
|
+
| `cloudimage-360-icons-container` | Styles the container for all icons associated with the 360 view (e.g., buttons, overlays). |
|
|
294
|
+
| `cloudimage-360-hotspot-container` | Styles the container that holds the hotspots or markers in the 360 view. |
|
|
295
|
+
| `cloudimage-360-fullscreen-modal` | Styles the modal that appears when the 360 view is in fullscreen mode. |
|
|
296
|
+
| `cloudimage-360-fullscreen-button` | Styles the button that toggles the fullscreen mode of the 360 view. |
|
|
297
|
+
| `cloudimage-360-close-icon` | Styles the close icon used to exit the fullscreen view. |
|
|
298
|
+
| `cloudimage-360-view-360-circle` | Styles the circular view area of the 360 images. |
|
|
299
|
+
| `cloudimage-360-popper` | Styles the popper element for displaying tooltips or additional information on hover or click. |
|
|
300
|
+
| `cloudimage-360-hotspot` | Styles individual hotspots within the 360 view, allowing for customizable appearance and behavior. |
|
|
301
|
+
|
|
302
|
+
Customize these class names in your CSS files to match your application's design requirements.
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
## Methods
|
|
306
|
+
|
|
307
|
+
### `getViewById(id)`
|
|
308
|
+
Returns the view object associated with the specified ID.
|
|
472
309
|
|
|
473
310
|
```javascript
|
|
474
|
-
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
### data-lazyload (or lazyload)
|
|
478
|
-
|
|
479
|
-
###### Type: **Bool** | Default: **false** | _optional_
|
|
480
|
-
|
|
481
|
-
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)
|
|
482
|
-
### data-lazyload-selector (or lazyload-selector)
|
|
483
|
-
|
|
484
|
-
###### Type: **String** | Default: **lazyload** | _optional_
|
|
485
|
-
|
|
486
|
-
Helper class to apply lazy-loading depending on library you choose, see [Lazy loading](#lazy-loading)
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
## <a name="controls"></a> Controls
|
|
490
|
-
|
|
491
|
-
You can add controls by adding elements with the following classes: **cloudimage-360-left**, **cloudimage-360-right**, **cloudimage-360-top**, **cloudimage-360-bottom
|
|
492
|
-
|
|
493
|
-
### Example CSS
|
|
494
|
-
```css
|
|
495
|
-
.cloudimage-360 .cloudimage-360-left, .cloudimage-360 .cloudimage-360-right {
|
|
496
|
-
padding: 8px;
|
|
497
|
-
background: rgba(255, 255, 255, 0.5);
|
|
498
|
-
border: none;
|
|
499
|
-
border-radius: 4px;
|
|
500
|
-
}
|
|
501
|
-
.cloudimage-360 .cloudimage-360-left:focus, .cloudimage-360 .cloudimage-360-right:focus {
|
|
502
|
-
outline: none;
|
|
503
|
-
}
|
|
504
|
-
.cloudimage-360 .cloudimage-360-left {
|
|
505
|
-
display: none;
|
|
506
|
-
position: absolute;
|
|
507
|
-
z-index: 100;
|
|
508
|
-
top: calc(50% - 15px);
|
|
509
|
-
left: 20px;
|
|
510
|
-
}
|
|
511
|
-
.cloudimage-360 .cloudimage-360-right {
|
|
512
|
-
display: none;
|
|
513
|
-
position: absolute;
|
|
514
|
-
z-index: 100;
|
|
515
|
-
top: calc(50% - 15px);
|
|
516
|
-
right: 20px;
|
|
517
|
-
}
|
|
518
|
-
.cloudimage-360 .cloudimage-360-left:before, .cloudimage-360 .cloudimage-360-right:before {
|
|
519
|
-
content: '';
|
|
520
|
-
display: block;
|
|
521
|
-
width: 30px;
|
|
522
|
-
height: 30px;
|
|
523
|
-
background: 50% 50% / cover no-repeat;
|
|
524
|
-
}
|
|
525
|
-
.cloudimage-360 .cloudimage-360-left:before {
|
|
526
|
-
background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-left.svg');
|
|
527
|
-
}
|
|
528
|
-
.cloudimage-360 .cloudimage-360-right:before {
|
|
529
|
-
background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-right.svg');
|
|
530
|
-
}
|
|
531
|
-
.cloudimage-360 .cloudimage-360-left.not-active, .cloudimage-360 .cloudimage-360-right.not-active {
|
|
532
|
-
opacity: 0.4;
|
|
533
|
-
cursor: default;
|
|
534
|
-
}
|
|
535
|
-
```
|
|
536
|
-
### Example HTML
|
|
537
|
-
```html
|
|
538
|
-
<div
|
|
539
|
-
class="cloudimage-360"
|
|
540
|
-
data-folder="https://scaleflex.cloudimg.io/v7/demo/360-car/"
|
|
541
|
-
data-filename-x="{index}.jpeg"
|
|
542
|
-
>
|
|
543
|
-
<button class="cloudimage-360-left"></button>
|
|
544
|
-
<button class="cloudimage-360-right"></button>
|
|
545
|
-
<button class="cloudimage-360-top"></button>
|
|
546
|
-
<button class="cloudimage-360-bottom"></button>
|
|
547
|
-
</div>
|
|
311
|
+
getViewById(id)
|
|
548
312
|
```
|
|
549
313
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
## <a name="spin_x_y"/> Spin in X and Y axes
|
|
553
|
-
Allow the view to spin in both X, Y axes
|
|
554
|
-
### Requirements
|
|
555
|
-
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>
|
|
556
|
-
|
|
557
|
-
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>
|
|
558
|
-
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.
|
|
559
|
-
example:
|
|
314
|
+
### `getViews()`
|
|
315
|
+
Returns an array of all the view objects currently available.
|
|
560
316
|
|
|
561
317
|
```javascript
|
|
562
|
-
|
|
563
|
-
class="cloudimage-360"
|
|
564
|
-
data-folder="https://scaleflex.cloudimg.io/v7/demo/360-nike/"
|
|
565
|
-
data-filename-x="nike-{index}.jpg"
|
|
566
|
-
data-filename-y="nike-y-{index}.jpg"
|
|
567
|
-
data-amount-x="35"
|
|
568
|
-
data-amount-y="36"
|
|
569
|
-
>
|
|
570
|
-
</div>
|
|
318
|
+
getViews()
|
|
571
319
|
```
|
|
572
|
-
<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>
|
|
573
|
-
> Note: We can initilize the view in x, y axes without providing add `data-folder`, `data-amount-y`, `data-amount-y`.</br>
|
|
574
|
-
Just we need to provide the <a href="#data-amount-y-or-amount-y">data-amount-y</a>
|
|
575
|
-
## <a name="hotspots"/> Hotspots or Markers
|
|
576
|
-
Display information about the product on specific areas. Once a hotspot is created it can be used on more than one image.
|
|
577
|
-
### Requirements
|
|
578
|
-
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.
|
|
579
|
-
Also we need to set an `id` attribute, we will need it to link the view with the hotspots config.
|
|
580
|
-
|
|
581
|
-
### Create hotspots configuration
|
|
582
|
-
The hotspots config should be an array of objects, each object in the array indicates a single hotspot config.
|
|
583
|
-
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.
|
|
584
|
-
|
|
585
|
-
example:
|
|
586
|
-
|
|
587
|
-
```js
|
|
588
|
-
const HOTSPOTS_CONFIG = [
|
|
589
|
-
{
|
|
590
|
-
positions: [
|
|
591
|
-
{ imageIndex: 0, xCoord: 527, yCoord: 319 },
|
|
592
|
-
{ imageIndex: 1, xCoord: 524 },
|
|
593
|
-
{ imageIndex: 2, xCoord: 520 },
|
|
594
|
-
{ imageIndex: 3, xCoord: 498 },
|
|
595
|
-
{ imageIndex: 4, xCoord: 470 },
|
|
596
|
-
{ imageIndex: 5, xCoord: 441 },
|
|
597
|
-
]
|
|
598
|
-
}
|
|
599
|
-
]
|
|
600
|
-
```
|
|
601
|
-
In the previous example, we have only set the Ycoord a single time at the image index 0.
|
|
602
|
-
So if the coord didn't change there's no need to reset it, it will already take the previous value.
|
|
603
|
-
|
|
604
|
-
Now we need to set the hotspot variant, we have three types of hotspots (link, popup, and custom), as it will be explained below.
|
|
605
|
-
## Variant
|
|
606
|
-
### Link
|
|
607
|
-
we need to provide the URL of the link and the link title.
|
|
608
|
-
|
|
609
|
-
example:
|
|
610
|
-
|
|
611
|
-
```js
|
|
612
|
-
const HOTSPOTS_CONFIG = [
|
|
613
|
-
{
|
|
614
|
-
positions,
|
|
615
|
-
variant: {
|
|
616
|
-
title: 'New Gurkha Technical Specifications',
|
|
617
|
-
url: 'https://www.forcegurkha.co.in/specifications/',
|
|
618
|
-
newTab: true
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
]
|
|
622
|
-
```
|
|
623
|
-
---
|
|
624
|
-
### Popup
|
|
625
|
-
Only the property inserted will displayed.
|
|
626
|
-
| Property |Type | Default | Description |
|
|
627
|
-
| ------------- | ------------- | ------------- |------------- |
|
|
628
|
-
| 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 |
|
|
629
|
-
| title |String| null | Display title underneath the images |
|
|
630
|
-
| description| String | null | Display description underneath the title |
|
|
631
|
-
| moreDetailsUrl | String | null | Display a button underneath the description to navigate to a provided URL |
|
|
632
|
-
| moreDetailsTitle | String | null| Set the title of the more details button |
|
|
633
|
-
|
|
634
|
-
example:
|
|
635
|
-
```js
|
|
636
|
-
const HOTSPOTS_CONFIG = [
|
|
637
|
-
{
|
|
638
|
-
positions,
|
|
639
|
-
variant: {
|
|
640
|
-
images: [
|
|
641
|
-
{ src: 'https://scaleflex.cloudimg.io/v7/demo/360-assets/AIR_SNORKEL_FINAL_JPG.png?vh=88bccb', alt: 'air snorkel' }
|
|
642
|
-
], // optional
|
|
643
|
-
title: 'Air Intake Snorkel', // optional
|
|
644
|
-
description: 'The snorkel gives the Gurkha an unmatched water-wading ability and ensures ample supply of fresh air for combustion.', // optional
|
|
645
|
-
moreDetailsUrl: 'https://forcegurkha.co.in', // optional
|
|
646
|
-
moreDetailsTitle: 'Read more' // optional
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
]
|
|
650
|
-
```
|
|
651
|
-
---
|
|
652
|
-
### Custom
|
|
653
|
-
Display any element in the DOM in a popup and link it with the hotspot.</br>
|
|
654
|
-
We will need to set the variant property value to the id of the element.
|
|
655
|
-
|
|
656
|
-
example:
|
|
657
|
-
```js
|
|
658
|
-
const HOTSPOTS_CONFIG = [
|
|
659
|
-
{
|
|
660
|
-
positions,
|
|
661
|
-
variant: 'gurkha-suv'
|
|
662
|
-
}
|
|
663
|
-
]
|
|
664
|
-
```
|
|
665
|
-
## PopupProps
|
|
666
|
-
Options to customize the hotspot popup.
|
|
667
|
-
### Properties
|
|
668
|
-
| Property | Type | Defaullt |Description |
|
|
669
|
-
| ------------- | ------------- | ------------- | ------------- |
|
|
670
|
-
| popupSelector |String| null |Set className to the popup wrapper |
|
|
671
|
-
| open |Boolean | false |Open the popup |
|
|
672
|
-
| arrow |Boolean| true |Dipslay an arrow that points toward the hotspot element|
|
|
673
|
-
| offset|Array | [0, 0] |Set a distance between the hotspot element and the popup |
|
|
674
|
-
| placement|String| Auto|- we can adjust the position of the hotspot popup relative to the hotspot element. (top - bottom - left - right)|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
example:
|
|
678
|
-
```js
|
|
679
|
-
const HOTSPOTS_CONFIG = [
|
|
680
|
-
{
|
|
681
|
-
positions,
|
|
682
|
-
variant,
|
|
683
|
-
popupProps: {
|
|
684
|
-
popupSelector: 'air-intake-popup', // optional
|
|
685
|
-
offset: [20, 5], // optional
|
|
686
|
-
arrow: false, // optional
|
|
687
|
-
placement: 'bottom' // optional
|
|
688
|
-
},
|
|
689
|
-
indicatorSelector: 'first-hotspot-icon' // optional
|
|
690
|
-
}
|
|
691
|
-
]
|
|
692
|
-
```
|
|
693
|
-
## Responsive hotspots
|
|
694
|
-
Now we need to make our hotspots responsive to have an accurate positioning in different screens.
|
|
695
|
-
we have to set `initialDimensions` property to every hotspot config. which indicates the dimension of the cloudimage-360 view.<br/>
|
|
696
|
-
hint: `data-info` can be used to get view size.
|
|
697
|
-
|
|
698
|
-
example:
|
|
699
|
-
```js
|
|
700
|
-
const HOTSPOTS_CONFIG = [
|
|
701
|
-
{
|
|
702
|
-
positions,
|
|
703
|
-
variant,
|
|
704
|
-
popupProps,
|
|
705
|
-
indicatorSelector,
|
|
706
|
-
initialDimensions: [ 1170, 662 ]
|
|
707
|
-
}
|
|
708
|
-
]
|
|
709
|
-
```
|
|
710
|
-
## Add Hotspots
|
|
711
|
-
we need this function to link the created config with the 360-view.
|
|
712
|
-
```js
|
|
713
|
-
window.CI360.addHotspots(idOftheView, hotspotsConfig);
|
|
714
|
-
```
|
|
715
|
-
example:
|
|
716
|
-
```js
|
|
717
|
-
window.CI360.addHotspots("gurkha-suv", HOTSPOTS_CONFIG);
|
|
718
|
-
```
|
|
719
|
-
<a href="https://codesandbox.io/s/competent-bogdan-49b0u6"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="edit in codesandbox"/></a>
|
|
720
|
-
|
|
721
|
-
### data-responsive (or responsive)
|
|
722
|
-
|
|
723
|
-
###### Type: **String** (Cloudimage token) | Default: **none** | _required for cloudimage responsive plugin_
|
|
724
|
-
|
|
725
|
-
Enables cloudimage responsive plugin for 360 view.
|
|
726
|
-
|
|
727
|
-
## <a name="cloudimage-responsive-integration"/> Cloudimage Responsive Integration
|
|
728
|
-
|
|
729
|
-
[See how it works (article on Medium)](https://medium.com/cloudimage/responsive-images-in-2019-now-easier-than-ever-b76e5a43c074)
|
|
730
|
-
|
|
731
|
-
### Requirements
|
|
732
|
-
|
|
733
|
-
To use the Cloudimage Responsive plugin, you will need a
|
|
734
|
-
Cloudimage token to deliver your images over CDN. Don't worry, it only takes seconds to get one by
|
|
735
|
-
registering [here](https://www.cloudimage.io/en/register_page).
|
|
736
|
-
Once your token is created, you can configure it as described below.
|
|
737
|
-
This token allows you to use 25GB of image cache and 25GB of worldwide
|
|
738
|
-
CDN traffic per month for free.
|
|
739
|
-
|
|
740
|
-
### data-responsive (or responsive)
|
|
741
320
|
|
|
742
|
-
|
|
321
|
+
### `updateView(id, config)`
|
|
322
|
+
Updates the configuration of an existing view identified by its ID. If the configuration has changed significantly, the view will be destroyed and reinitialized; otherwise, it will simply be updated.
|
|
743
323
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
### data-request-responsive-images (or request-responsive-images)
|
|
747
|
-
|
|
748
|
-
###### Type: **Bool** | Default: **false**
|
|
749
|
-
|
|
750
|
-
Request new images on resize, based on the container width.
|
|
751
|
-
|
|
752
|
-
### data-transformation (or transformation)
|
|
753
|
-
|
|
754
|
-
###### Type: **String** | Default: **none** | _optional_
|
|
755
|
-
|
|
756
|
-
Applies Cloudimage resize operations to your image, e.g. width, height, crop, face crop, rotate, prevent enlargement...
|
|
757
|
-
Multiple transformation operations can be applied to your image, separated by "```&```" (Ampersand).
|
|
758
|
-
example:
|
|
759
|
-
|
|
760
|
-
```html
|
|
761
|
-
data-transformation="w=400&h=200&func=fit"
|
|
324
|
+
```javascript
|
|
325
|
+
updateView(id, config)
|
|
762
326
|
```
|
|
763
327
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
### data-filters (or filters)
|
|
328
|
+
### View Methods
|
|
767
329
|
|
|
768
|
-
|
|
330
|
+
#### `onMoveHandler(movingDirection, itemsSkippedX = 1, itemsSkippedY = 1)`
|
|
331
|
+
Handles the movement of items in the view. It takes a direction and the number of items to skip horizontally and vertically.
|
|
769
332
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
example:
|
|
773
|
-
|
|
774
|
-
```html
|
|
775
|
-
data-filters="bright:15,contrast:30"
|
|
333
|
+
```javascript
|
|
334
|
+
onMoveHandler(movingDirection, itemsSkippedX = 1, itemsSkippedY = 1)
|
|
776
335
|
```
|
|
777
336
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
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.
|
|
337
|
+
**Parameters:**
|
|
338
|
+
- `movingDirection`: A string indicating the direction of movement (`'right'`, `'left'`, `'top'`, or `'bottom'`).
|
|
339
|
+
- `itemsSkippedX`: The number of items to skip in the horizontal direction (default is 1).
|
|
340
|
+
- `itemsSkippedY`: The number of items to skip in the vertical direction (default is 1).
|
|
783
341
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
[Implementation example with yall.js](https://codesandbox.io/s/js-cloudimage-360-view-xjpdg1)
|
|
342
|
+
---
|
|
787
343
|
|
|
788
|
-
|
|
344
|
+
## Cloudimage Responsive Integration
|
|
789
345
|
|
|
790
|
-
|
|
346
|
+
### Overview
|
|
791
347
|
|
|
792
|
-
|
|
793
|
-
or storage bucket (S3, Google Cloud, Azure Blob...) reachable over
|
|
794
|
-
HTTP or HTTPS by Cloudimage. If you want to upload your master images to
|
|
795
|
-
Cloudimage, contact us at
|
|
796
|
-
[hello@cloudimage.io](mailto:hello@cloudimage.io).
|
|
348
|
+
Integrating Cloudimage for responsive images enhances the loading speed and performance of your website. This service delivers optimized images over a Content Delivery Network (CDN), ensuring that your images are served quickly and efficiently, regardless of the user's location.
|
|
797
349
|
|
|
798
|
-
|
|
350
|
+
### How It Works
|
|
799
351
|
|
|
800
|
-
|
|
352
|
+
To see how Cloudimage transforms image delivery for responsive design, check out the [full article on Medium](https://medium.com/cloudimage/responsive-images-in-2019-now-easier-than-ever-b76e5a43c074). The article details the importance of responsive images in modern web development and how Cloudimage simplifies the process.
|
|
801
353
|
|
|
802
|
-
|
|
354
|
+
### Requirements
|
|
803
355
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
356
|
+
Before you start using the Cloudimage Responsive plugin, make sure you have the following:
|
|
357
|
+
|
|
358
|
+
- **Cloudimage Token**: You'll need a unique Cloudimage token to deliver your images over their CDN.
|
|
359
|
+
|
|
360
|
+
**Getting Your Token**:
|
|
361
|
+
- Register at the [Cloudimage website](https://cloudimage.io).
|
|
362
|
+
- After registration, you'll receive a token that allows you to access their services.
|
|
363
|
+
|
|
364
|
+
The token grants you **25GB of image cache** and **25GB of worldwide CDN traffic per month** for free. This is perfect for startups and small projects looking to enhance their website's performance without incurring costs.
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
## 🔰 Contributing
|
|
368
|
+
|
|
369
|
+
- **💬 [Join the Discussions](https://github.com/Scaleflex/js-cloudimage-360-view/discussions)**: Share your insights, provide feedback, or ask questions.
|
|
370
|
+
- **🐛 [Report Issues](https://github.com/Scaleflex/js-cloudimage-360-view/issues)**: Submit bugs found or log feature requests for the `js-cloudimage-360-view` project.
|
|
371
|
+
- **💡 [Submit Pull Requests](https://github.com/Scaleflex/js-cloudimage-360-view/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs.
|
|
372
|
+
|
|
373
|
+
<details closed>
|
|
374
|
+
<summary>Contributing Guidelines</summary>
|
|
375
|
+
|
|
376
|
+
1. **Fork the Repository**: Start by forking the project repository to your github account.
|
|
377
|
+
2. **Clone Locally**: Clone the forked repository to your local machine using a git client.
|
|
378
|
+
```sh
|
|
379
|
+
git clone https://github.com/Scaleflex/js-cloudimage-360-view
|
|
380
|
+
```
|
|
381
|
+
3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name.
|
|
382
|
+
```sh
|
|
383
|
+
git checkout -b new-feature-x
|
|
384
|
+
```
|
|
385
|
+
4. **Make Your Changes**: Develop and test your changes locally.
|
|
386
|
+
5. **Commit Your Changes**: Commit with a clear message describing your updates.
|
|
387
|
+
```sh
|
|
388
|
+
git commit -m 'Implemented new feature x.'
|
|
389
|
+
```
|
|
390
|
+
6. **Push to github**: Push the changes to your forked repository.
|
|
391
|
+
```sh
|
|
392
|
+
git push origin new-feature-x
|
|
393
|
+
```
|
|
394
|
+
7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations.
|
|
395
|
+
8. **Review**: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
|
|
396
|
+
</details>
|
|
397
|
+
|
|
398
|
+
<details closed>
|
|
399
|
+
<summary>Contributor Graph</summary>
|
|
400
|
+
<br>
|
|
401
|
+
<p align="left">
|
|
402
|
+
<a href="https://github.com{/Scaleflex/js-cloudimage-360-view/}graphs/contributors">
|
|
403
|
+
<img src="https://contrib.rocks/image?repo=Scaleflex/js-cloudimage-360-view">
|
|
404
|
+
</a>
|
|
405
|
+
</p>
|
|
406
|
+
</details>
|
|
809
407
|
|
|
810
|
-
|
|
408
|
+
---
|
|
811
409
|
|
|
812
|
-
|
|
410
|
+
## 🎗 License
|
|
813
411
|
|
|
814
|
-
## <a name="license"></a>License
|
|
815
412
|
JS Cloudimage 360 View is provided under the [MIT License](https://opensource.org/licenses/MIT)
|