Gathering detailed insights and metrics for js-cloudimage-360-view
Gathering detailed insights and metrics for js-cloudimage-360-view
Gathering detailed insights and metrics for js-cloudimage-360-view
Gathering detailed insights and metrics for js-cloudimage-360-view
@aneeven/js-cloudimage-360-view
[![Release](https://img.shields.io/github/v/release/scaleflex/js-cloudimage-360-view)](https://github.com/scaleflex/js-cloudimage-360-view/releases) [![Size](https://img.shields.io/bundlephobia/min/js-cloudimage-360-view)](https://img.shields.io/bundlepho
execa
Process execution for humans
@hauvo/react-native-360-image-viewer
The 360 image viewer for react native
mmc-js-cloudimage-360-view
[![Release](https://img.shields.io/badge/release-v2.7.1-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases) [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)](#contributing) [![License](https://i
Engage your customers with a stunning 360 view of your products. Any questions or issues, please report to https://github.com/scaleflex/js-cloudimage-360-view/issues
npm install js-cloudimage-360-view
Typescript
Module System
Node Version
NPM Version
75.4
Supply Chain
99.4
Quality
90.3
Maintenance
100
Vulnerability
99.3
License
Updated on 03 Dec 2024
Minified
Minified + Gzipped
JavaScript (90.52%)
CSS (9.48%)
Cumulative downloads
Total Downloads
Last day
13.2%
Compared to previous day
Last week
-8.9%
Compared to previous week
Last month
2.3%
Compared to previous month
Last year
24.9%
Compared to previous year
3
28
Docs • Demo • Code Sandbox • Video Tutorial • Why
A simple, interactive resource that can be used to provide a virtual tour of your product.
To see the Cloudimage 360 view plugin in action, please check out the Demo page.
Add script tag with CDN link to js-cloudimage-360-view lib after all content in body tag
1<script src="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/latest/js-cloudimage-360-view.min.js?func=proxy"></script>
After adding the js-cloudimage-360-view lib, simply initialize it with class name "cloudimage-360", server folder path, file name and amount of images:
1<div 2 class="cloudimage-360" 3 id="gurkha-suv" 4 data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/" 5 data-filename-x="orange-{index}.jpg" 6 data-amount-x="73" 7></div>
Initialization of js cloudimage 360 view plugin.
1window.CI360.init();
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
1<script>window.CI360 = { notInitOnLoad: true }</script> 2<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/3.0./js-cloudimage-360-view.min.js"></script> 3<script>window.CI360.init(); // initialize the plugin when you need</script>
1window.CI360.add(idOftheView: string);
lazy init cloudimage-360 view by id.
idOftheView
: string
The id of the new view
1window.CI360.update(idOftheView, forceUpdate);
Update cloudimage 360 viewer instance.
For any update in source attributes after plugin initialization (e.g. data-folder
, data-filename-x
, data-amount-y
),
the plugin will re-init.
idOftheView
: string
The id of the new view
forceUpdate
: bool
Force the view to reinitialize.
1<div 2 class="cloudimage-360" 3 id="gurkha-suv" 4 data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/" 5 data-filename-x="orange-{index}.jpg" 6 data-amount-x="73" 7></div>
1window.CI360.update('gurkha-suv');
1window.CI360.update(null, true);
Destroying a cloudimage 360 viewer instance will reset the HTML to its original state.
1window.CI360.destroy();
Get the {index} of the image that is being viewed.
1window.CI360.getActiveIndexByID(idOfInstance: string, oriantation: string);
idOfInstance
: string
The id of the instance
oriantation
: string
The oriantation of the active index
You can customize elements by adding the following classes:
1.cloudimage-360-icons-container { 2 top: 5px; 3 right: 5px; 4} 5.cloudimage-360-fullscreen-modal { 6 top: 0; 7 bottom: 0; 8} 9.cloudimage-360-magnifier-icon { 10 background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/loupe.svg) 50% 50% / cover no-repeat; 11} 12.cloudimage-360-close-fullscreen-icon { 13 background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/cross.svg) 50% 50% / cover no-repeat; 14} 15.cloudimage-360-view-360-circle { 16 margin: auto; 17} 18.cloudimage-360-loader { 19 margin: auto; 20} 21.cloudimage-360-view-360-icon { 22 background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/360_view.svg) 50% 50% / cover no-repeat; 23} 24.cloudimage-360-box-shadow { 25 top: 0; 26 left: 0; 27} 28.cloudimage-360-img-magnifier-glass { 29 border: 3px solid #000; 30 border-radius: 50%; 31}
The selector for js-cloudimage-360-view lib.
Your images folder on server.
Allow to use a specific version of API.
1data-api-version="v7"
1data-api-version="null"
The filename pattern for your 360 image. Must include {index}, which the library will replace with a number between 1 and data-amount-x.
The same for data-amount-x but for images set in Y-axis.
Amount of images to load in X-axis for 360 view .
Amount of images to load in Y-axis for 360 view.
Support for 360 spin by pressing arrow keys on keyboard.
invert arrow keys on keyboard.
Autoplay 360 spin view on load.
stops the autoplay after one complete cycle.
Changing autoplay behavior
Available behaviors (spin-x, spin-y, spin-xy, spin-yx)
Open 360 spin view in full screen modal.
Magnifier to zoom image.
ratio
: stringSetting the height relative to the container width according to the provided ratio
1<div 2 class="cloudimage-360" 3 id="gurkha-suv" 4 data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/" 5 data-filename-x="orange-{index}.jpg" 6 data-amount-x="73" 7 data-ratio="2" 8></div>
ratio
: JSONSetting the height relative to the container width at any window size.
In the following example, the height should be 1.3 the container width at window size less than or equal to 567px and 2.22 at window size less than or equal to 768px.
1<div 2 class="cloudimage-360" 3 id="gurkha-suv" 4 data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/" 5 data-filename-x="orange-{index}.jpg" 6 data-amount-x="73" 7 data-ratio='{ 8 "576": "1.3", 9 "768": "2.22", 10 "992": "2.23", 11 "1200": "3", 12 "2400": "3.2" 13 }' 14></div>
Autoplay 360 spin view on load.
disable mouse drag.
Speed of changing frames for autoplay in milliseconds.
Speed Factor of changing frames on drag event.
Spin direction, by default it uses counterclockwise (image indexes from 1 to data-amount-x).
Apply box shadow for container.
Display 360 view line at the bottom of container.
Hide 360 view icon.
Spin direction using controls, by default it uses counterclockwise (image indexes from 1 to data-amount-x).
Blocks repeating images after reaching last image (or first image in opposite direction)
Bottom offset for 360 view line.
Left zero padding on filename. For example: index-zero-base="4" => image index will be "0004"
Option to add list of images in x-oriantation instead of folder
, filename-x
& amount-x
.
example:
1data-folder="https://scaleflex.cloudimg.io/v7/demo/360-car/" 2data-image-list-x='[ 3 "iris-1.jpeg", 4 "iris-4.jpeg", 5 "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-12.jpeg", 6 "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-15.jpeg" 7 ]’
Option to add list of images in y-oriantation instead of folder
, filename-y
& amount-y
.
example:
1data-folder="https://scaleflex.cloudimg.io/v7/demo/360-car/" 2data-image-list-y='[ 3 "iris-2-y.jpeg", 4 "iris-6-y.jpeg", 5 "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-8-y.jpeg", 6 "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-30-y.jpeg" 7 ]’
Option to scale images on click on it to provided value.
example:
1data-pointer-zoom="3"
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
Helper class to apply lazy-loading depending on library you choose, see Lazy loading
You can add controls by adding elements with the following classes: cloudimage-360-left, cloudimage-360-right, cloudimage-360-top, **cloudimage-360-bottom
1.cloudimage-360 .cloudimage-360-left, .cloudimage-360 .cloudimage-360-right { 2 padding: 8px; 3 background: rgba(255, 255, 255, 0.5); 4 border: none; 5 border-radius: 4px; 6} 7.cloudimage-360 .cloudimage-360-left:focus, .cloudimage-360 .cloudimage-360-right:focus { 8 outline: none; 9} 10.cloudimage-360 .cloudimage-360-left { 11 display: none; 12 position: absolute; 13 z-index: 100; 14 top: calc(50% - 15px); 15 left: 20px; 16} 17.cloudimage-360 .cloudimage-360-right { 18 display: none; 19 position: absolute; 20 z-index: 100; 21 top: calc(50% - 15px); 22 right: 20px; 23} 24.cloudimage-360 .cloudimage-360-left:before, .cloudimage-360 .cloudimage-360-right:before { 25 content: ''; 26 display: block; 27 width: 30px; 28 height: 30px; 29 background: 50% 50% / cover no-repeat; 30} 31.cloudimage-360 .cloudimage-360-left:before { 32 background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-left.svg'); 33} 34.cloudimage-360 .cloudimage-360-right:before { 35 background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-right.svg'); 36} 37.cloudimage-360 .cloudimage-360-left.not-active, .cloudimage-360 .cloudimage-360-right.not-active { 38 opacity: 0.4; 39 cursor: default; 40}
1<div 2 class="cloudimage-360" 3 data-folder="https://scaleflex.cloudimg.io/v7/demo/360-car/" 4 data-filename-x="{index}.jpeg" 5> 6 <button class="cloudimage-360-left"></button> 7 <button class="cloudimage-360-right"></button> 8 <button class="cloudimage-360-top"></button> 9 <button class="cloudimage-360-bottom"></button> 10</div>
Allow the view to spin in both X, Y axes
We need to provide the file-name
of the y-axis images using data-filename-y
Also as we did for the x-axis if we are intializing the view using data-folder and data-filename-y so we need to provide data-amount-y which indicates the number of images on the y-axis. example:
1<div 2 class="cloudimage-360" 3 data-folder="https://scaleflex.cloudimg.io/v7/demo/360-nike/" 4 data-filename-x="nike-{index}.jpg" 5 data-filename-y="nike-y-{index}.jpg" 6 data-amount-x="35" 7 data-amount-y="36" 8> 9</div>
Note: We can initilize the view in x, y axes without providing add
data-folder
,data-amount-y
,data-amount-y
.
Just we need to provide the data-amount-y
Display information about the product on specific areas. Once a hotspot is created it can be used on more than one image.
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.
Also we need to set an id
attribute, we will need it to link the view with the hotspots config.
The hotspots config should be an array of objects, each object in the array indicates a single hotspot config.
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.
hint: To know the current image index we will need to set data-info="white || black"
attribute.
example:
1const HOTSPOTS_CONFIG = [ 2 { 3 positions: [ 4 { imageIndex: 0, xCoord: 527, yCoord: 319 }, 5 { imageIndex: 1, xCoord: 524 }, 6 { imageIndex: 2, xCoord: 520 }, 7 { imageIndex: 3, xCoord: 498 }, 8 { imageIndex: 4, xCoord: 470 }, 9 { imageIndex: 5, xCoord: 441 }, 10 ] 11 } 12]
In the previous example, we have only set the Ycoord a single time at the image index 0. So if the coord didn't change there's no need to reset it, it will already take the previous value.
Now we need to set the hotspot variant, we have three types of hotspots (link, popup, and custom), as it will be explained below.
we need to provide the URL of the link and the link title.
example:
1const HOTSPOTS_CONFIG = [ 2 { 3 positions, 4 variant: { 5 title: 'New Gurkha Technical Specifications', 6 url: 'https://www.forcegurkha.co.in/specifications/', 7 newTab: true 8 } 9 } 10]
Only the property inserted will displayed.
Property | Type | Default | Description |
---|---|---|---|
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 |
title | String | null | Display title underneath the images |
description | String | null | Display description underneath the title |
moreDetailsUrl | String | null | Display a button underneath the description to navigate to a provided URL |
moreDetailsTitle | String | null | Set the title of the more details button |
example:
1const HOTSPOTS_CONFIG = [ 2 { 3 positions, 4 variant: { 5 images: [ 6 { src: 'https://scaleflex.cloudimg.io/v7/demo/360-assets/AIR_SNORKEL_FINAL_JPG.png?vh=88bccb', alt: 'air snorkel' } 7 ], // optional 8 title: 'Air Intake Snorkel', // optional 9 description: 'The snorkel gives the Gurkha an unmatched water-wading ability and ensures ample supply of fresh air for combustion.', // optional 10 moreDetailsUrl: 'https://forcegurkha.co.in', // optional 11 moreDetailsTitle: 'Read more' // optional 12 } 13 } 14]
Display any element in the DOM in a popup and link it with the hotspot.
We will need to set the variant property value to the id of the element.
example:
1const HOTSPOTS_CONFIG = [ 2 { 3 positions, 4 variant: 'gurkha-suv' 5 } 6]
Options to customize the hotspot popup.
Property | Type | Defaullt | Description |
---|---|---|---|
popupSelector | String | null | Set className to the popup wrapper |
open | Boolean | false | Open the popup |
arrow | Boolean | true | Dipslay an arrow that points toward the hotspot element |
offset | Array | [0, 0] | Set a distance between the hotspot element and the popup |
placement | String | Auto | - we can adjust the position of the hotspot popup relative to the hotspot element. (top - bottom - left - right) |
example:
1const HOTSPOTS_CONFIG = [ 2 { 3 positions, 4 variant, 5 popupProps: { 6 popupSelector: 'air-intake-popup', // optional 7 offset: [20, 5], // optional 8 arrow: false, // optional 9 placement: 'bottom' // optional 10 }, 11 indicatorSelector: 'first-hotspot-icon' // optional 12 } 13]
Now we need to make our hotspots responsive to have an accurate positioning in different screens.
we have to set initialDimensions
property to every hotspot config. which indicates the dimension of the cloudimage-360 view.
hint: data-info
can be used to get view size.
example:
1const HOTSPOTS_CONFIG = [ 2 { 3 positions, 4 variant, 5 popupProps, 6 indicatorSelector, 7 initialDimensions: [ 1170, 662 ] 8 } 9]
we need this function to link the created config with the 360-view.
1window.CI360.addHotspots(idOftheView, hotspotsConfig);
example:
1window.CI360.addHotspots("gurkha-suv", HOTSPOTS_CONFIG);
Enables cloudimage responsive plugin for 360 view.
See how it works (article on Medium)
To use the Cloudimage Responsive plugin, you will need a Cloudimage token to deliver your images over CDN. Don't worry, it only takes seconds to get one by registering here. Once your token is created, you can configure it as described below. This token allows you to use 25GB of image cache and 25GB of worldwide CDN traffic per month for free.
Enables cloudimage responsive plugin for 360 view.
Request new images on resize, based on the container width.
Applies Cloudimage resize operations to your image, e.g. width, height, crop, face crop, rotate, prevent enlargement...
Multiple transformation operations can be applied to your image, separated by "&
" (Ampersand).
example:
1data-transformation="w=400&h=200&func=fit"
Applies Cloudimage filters to your image, e.g. brightness, contrast, greyscale, blur, Sharpen...
Multiple filters can be applied, separated by ",
" (comma).
example:
1data-filters="bright:15,contrast:30"
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, yall.js (Yet Another Lazy Loader), lozad.js to handle it.
Implementation example with lazysizes
Implementation example with yall.js
Implementation example with lozad.js
Tested in all modern browsers and IE 11, 10, 9.
All contributions are super welcome!
JS Cloudimage 360 View is provided under the MIT License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More