Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

js-cloudimage-360-view

Package Overview
Dependencies
Maintainers
0
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-cloudimage-360-view

<h1 a

  • 4.0.0-beta.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
731
decreased by-18.78%
Maintainers
0
Weekly downloads
Β 
Created
Source

cloudimage logo

JS Cloudimage 360 View

360 Views, Infinite Possibilities: Unleash the Power of js-cloudimage-360-view!

Release Size Download Contributions welcome License Scaleflex team Cloudimage


πŸ”— Table of Contents


πŸ“ Overview

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.


πŸ‘Ύ Features

FeatureSummary
βš™οΈImage Viewing
  • Enables interactive 360-degree image viewing with smooth transitions
  • Supports high-resolution images for detailed visualization
  • Touch and drag navigation for user-friendly experiences
πŸ”©Customization
  • Offers customizable settings for rotation speed, direction, and initial angle
  • Supports multiple display modes and responsive adjustments
  • Adaptable to various website designs for seamless integration
πŸ“„Documentation
  • Comprehensive guides on installation and usage
  • Step-by-step instructions for integration and configuration
  • Provides examples to help users implement the plugin quickly
πŸ”ŒFramework Support
  • Easily integrates with popular JavaScript frameworks
  • Includes clear instructions for setup in React, Vue, Angular, and vanilla JavaScript
  • Adjustable settings to adapt to project requirements
⚑️Performance
  • Optimized for fast loading and minimal resource consumption
  • Utilizes lazy loading and caching to improve load times
  • Lightweight script ensures minimal impact on page performance
πŸ“¦Dependencies
  • Minimal dependencies for essential functionality only

πŸš€ Getting Started

βš™οΈ Installation

You can install js-cloudimage-360-view using one of the following methods:

Option 1: Add via CDN

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:

<link rel="stylesheet" href="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/latest/js-cloudimage-360-view.min.css">
<script src="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/latest/js-cloudimage-360-view.min.js?func=proxy"></script>

Note:

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.

This is the quickest way to get started without additional setup.

Option 2: Install with Package Manager

You can add js-cloudimage-360-view to your project using either npm or Yarn:

For npm:

npm install js-cloudimage-360-view

For Yarn:

yarn add js-cloudimage-360-view

Then, import it in your JavaScript file:

import CloudImage360 from 'js-cloudimage-360-view';

OR

window.CI360

Choose the method that best suits your project setup, and refer to the documentation for configuration options and usage examples.

πŸ› οΈ Usage

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.

Initialize a Single View

To initialize a single 360-degree view, use the following code:

const cloudimage360 = new CloudImage360();

const suvCarContainer = document.getElementById('gurkha-suv');

const config = {
  folder: 'https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/',
  filenameX: 'orange-{index}.jpg',
  amountX: 73,
  responsive: 'scaleflex',
};

instance.init(suvCarContainer, config);
Initialize All Instances

To initialize all instances with a common selector, use the following code:

instance.initAll('.cloudimage-360');

This will apply the 360-degree viewer to all elements matching the specified selector.

βš™οΈ Configuration Options

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.

Method 1: Initialization via JavaScript Code

To initialize a view programmatically, use the following configuration options:

Method 2: Initialization via Data Attributes

You can also initialize the view using HTML data attributes, which correspond to the configuration options listed below.

For example:

<div id="gurkha-suv"
     data-folder="/path/to/images/"
     data-api-version="v7"
     data-amount-x="73"
     data-speed="80"
     data-draggable="true">
</div>
OptionData AttributeRequiredDefault ValueDescription
folderdata-folderYes'/'The path to the folder containing the images.
apiVersiondata-api-versionNo'v7'The API version to use.
filenameXdata-filename-xYes'image-{index}.jpg'The filename pattern for the X-axis images.
filenameYdata-filename-yNonullThe filename pattern for the Y-axis images (optional).
imageListXdata-image-list-xNonullAn array of images for the X-axis (optional).
imageListYdata-image-list-yNonullAn array of images for the Y-axis (optional).
indexZeroBasedata-index-zero-baseNo0Whether the index starts from 0.
amountXdata-amount-xYes0Total number of X-axis images.
amountYdata-amount-yNo0Total number of Y-axis images (optional).
speeddata-speedNo80The speed of the rotation in milliseconds.
dragSpeeddata-drag-speedNo150The speed when dragging the image.
draggabledata-draggableNotrueEnables dragging functionality.
swipeabledata-swipeableNotrueEnables swipe functionality on touch devices.
keysdata-keysNofalseEnables keyboard navigation.
keysReversedata-keys-reverseNofalseReverses keyboard navigation controls.
autoplaydata-autoplayNofalseAutomatically plays the rotation.
autoplayBehaviordata-autoplay-behaviorNoAUTOPLAY_BEHAVIOR.SPIN_XDefines how autoplay behaves.
playOncedata-play-onceNofalsePlays the animation only once.
autoplayReversedata-autoplay-reverseNofalsePlays the autoplay in reverse.
pointerZoomdata-pointer-zoomNo0Defines the zoom level on pointer hover.
fullscreendata-fullscreenNofalseEnables fullscreen mode.
magnifierdata-magnifierNonullDefines the magnification level (optional).
bottomCircledata-bottom-circleNotrueDisplays the bottom circle navigation.
bottomCircleOffsetdata-bottom-circle-offsetNo5The offset of the bottom circle from the container.
ciTokendata-responsiveNonullToken for Cloudimage API authentication (optional). πŸ—ΊοΈ Cloudimage responsive integration
ciFiltersdata-filtersNonullFilters applied to Cloudimage images (optional).
ciTransformationdata-transformationNonullTransformations for Cloudimage images (optional).
lazyloaddata-lazyloadNotrueEnables lazy loading of images.
dragReversedata-drag-reverseNofalseReverses drag direction.
stopAtEdgesdata-stop-at-edgesNofalseStops the rotation at the edges.
imageInfodata-infoNofalseDisplays image information.
initialIconShowndata-initial-iconNotrueShows the initial icon on load.

The library will automatically read these attributes to configure the instance.

πŸ—ΊοΈ Hotspots or Markers Configuration

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.

Hotspot Configuration Structure

Each hotspot configuration consists of the following properties:

PropertyRequiredDescription
idYesA unique identifier for the hotspot.
orientationYesThe orientation of the hotspot (e.g., 'x' for X-axis).
containerSizeYesAn 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.
positionsYesAn object where keys are indices (image indexes) representing the position of the hotspot for specific images.
contentYesHTML content to display in the tooltip when the hotspot is hovered or clicked.
onClickNoA function that defines the behavior when the hotspot is clicked (optional).
Positions

The positions property is an object where:

  • The key is the index of the image in the 360 view (e.g., 6, 7, 8, ...).
  • The value is an object with x and y properties, representing the coordinates of the hotspot on the image.

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.

For example:

positions: {
  6: { x: 607, y: 246 },
  7: { x: 619, y: null }, // y is null, so it takes the previous y (246)
  8: { x: 630, y: null }, // y is null, so it takes the previous y (246)
  9: { x: 637, y: null }, // y is null, so it takes the previous y (246)
  10: { x: 642, y: null }, // y is null, so it takes the previous y (246)
},
Example Hotspot Configuration

Here's an example configuration for multiple hotspots:

const GURKHA_SUV_HOTSPOTS_CONFIG = [
  {
    id: 'hotspot-1',
    orientation: 'x',
    containerSize: [1170, 663],
    positions: {
      0: { x: 527, y: 319 },
      1: { x: 527, y: 319 },
      2: { x: 527, y: null }, // Takes the previous position
      3: { x: 498, y: null }, // Takes the previous y (319)
      4: { x: 470, y: null }, // Takes the previous y (319)
      // Additional positions...
    },
    content: '<div class="tooltip">Info about Hotspot 1</div>',
  },
  // Additional hotspots...
];

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.

🎨 Styling

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.

Class NameDescription
cloudimage-360-transition-overlayApplies styling for the overlay that appears during transitions.
cloudimage-360-buttonStyles the main button for interacting with the 360 view.
cloudimage-360-magnifier-buttonStyles the button that activates the magnifier feature within the 360 view.
cloudimage-loading-spinnerStyles the loading spinner displayed while the images are being loaded.
cloudimage-initial-iconStyles the initial icon displayed before the 360 view is fully loaded.
cloudimage-360-icons-containerStyles the container for all icons associated with the 360 view (e.g., buttons, overlays).
cloudimage-360-hotspot-containerStyles the container that holds the hotspots or markers in the 360 view.
cloudimage-360-fullscreen-modalStyles the modal that appears when the 360 view is in fullscreen mode.
cloudimage-360-fullscreen-buttonStyles the button that toggles the fullscreen mode of the 360 view.
cloudimage-360-close-iconStyles the close icon used to exit the fullscreen view.
cloudimage-360-view-360-circleStyles the circular view area of the 360 images.
cloudimage-360-popperStyles the popper element for displaying tooltips or additional information on hover or click.
cloudimage-360-hotspotStyles individual hotspots within the 360 view, allowing for customizable appearance and behavior.

Customize these class names in your CSS files to match your application's design requirements.

Methods

getViewById(id)

Returns the view object associated with the specified ID.

getViewById(id)

getViews()

Returns an array of all the view objects currently available.

getViews()

updateView(id, config)

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.

updateView(id, config)

View Methods

onMoveHandler(movingDirection, itemsSkippedX = 1, itemsSkippedY = 1)

Handles the movement of items in the view. It takes a direction and the number of items to skip horizontally and vertically.

onMoveHandler(movingDirection, itemsSkippedX = 1, itemsSkippedY = 1)

Parameters:

  • movingDirection: A string indicating the direction of movement ('right', 'left', 'top', or 'bottom').
  • itemsSkippedX: The number of items to skip in the horizontal direction (default is 1).
  • itemsSkippedY: The number of items to skip in the vertical direction (default is 1).

Cloudimage Responsive Integration

Overview

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.

How It Works

To see how Cloudimage transforms image delivery for responsive design, check out the full article on Medium. The article details the importance of responsive images in modern web development and how Cloudimage simplifies the process.

Requirements

Before you start using the Cloudimage Responsive plugin, make sure you have the following:

  • Cloudimage Token: You'll need a unique Cloudimage token to deliver your images over their CDN.

    Getting Your Token:

    • Register at the Cloudimage website.
    • After registration, you'll receive a token that allows you to access their services.

    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.

πŸ”° Contributing

  • πŸ’¬ Join the Discussions: Share your insights, provide feedback, or ask questions.
  • πŸ› Report Issues: Submit bugs found or log feature requests for the js-cloudimage-360-view project.
  • πŸ’‘ Submit Pull Requests: Review open PRs, and submit your own PRs.
Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/Scaleflex/js-cloudimage-360-view
    
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
    
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
    
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
    
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


πŸŽ— License

JS Cloudimage 360 View is provided under the MIT License

Keywords

FAQs

Package last updated on 30 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc