GithubHelp home page GithubHelp logo

scaleflex / js-cloudimage-360-view Goto Github PK

View Code? Open in Web Editor NEW
2.0K 32.0 230.0 2.25 MB

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

License: Other

JavaScript 90.52% CSS 9.48%

js-cloudimage-360-view's Introduction

Release Size Download Contributions welcome License Scaleflex team Cloudimage

cloudimage logo cloudimage logo

JS Cloudimage 360 View

DocsDemoCode SandboxVideo TutorialWhy

A simple, interactive resource that can be used to provide a virtual tour of your product.

The Lounge

Table of contents

Demo

To see the Cloudimage 360 view plugin in action, please check out the Demo page.

Step 1: Installation

Add script tag with CDN link to js-cloudimage-360-view lib after all content in body tag

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

Step 2: Initialize

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:

<div
   class="cloudimage-360"
   id="gurkha-suv"
   data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
   data-filename-x="orange-{index}.jpg"
   data-amount-x="73"
></div>

edit in codesandbox

Methods

init

Type: Function

Initialization of js cloudimage 360 view plugin.

window.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

<script>window.CI360 = { notInitOnLoad: true }</script>
<script src="https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/3.0./js-cloudimage-360-view.min.js"></script>
<script>window.CI360.init(); // initialize the plugin when you need</script>

add

Type: Function
window.CI360.add(idOftheView: string);

lazy init cloudimage-360 view by id.

arguments

idOftheView: string The id of the new view

edit in codesandbox

update

Type: Function
window.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.

arguments

idOftheView: string The id of the new view

forceUpdate: bool Force the view to reinitialize.

<div
   class="cloudimage-360"
   id="gurkha-suv"
   data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
   data-filename-x="orange-{index}.jpg"
   data-amount-x="73"
></div>
window.CI360.update('gurkha-suv');
window.CI360.update(null, true);

edit in codesandbox

destroy

Type: Function

Destroying a cloudimage 360 viewer instance will reset the HTML to its original state.

window.CI360.destroy();
edit in codesandbox

getActiveIndexByID

Type: Function

Get the {index} of the image that is being viewed.

window.CI360.getActiveIndexByID(idOfInstance: string, oriantation: string);
arguments

idOfInstance: string The id of the instance

oriantation: string The oriantation of the active index

Customize elements

You can customize elements by adding the following classes:

Example CSS

.cloudimage-360-icons-container {
	top: 5px;
  	right: 5px;
}
.cloudimage-360-fullscreen-modal {
	top: 0;
  	bottom: 0;
}
.cloudimage-360-magnifier-icon {
	background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/loupe.svg) 50% 50% / cover no-repeat;
}
.cloudimage-360-close-fullscreen-icon {
	background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/cross.svg) 50% 50% / cover no-repeat;
}
.cloudimage-360-view-360-circle {
  	margin: auto;
}
.cloudimage-360-loader {
	margin: auto;
}
.cloudimage-360-view-360-icon {
	background: url(https://scaleflex.cloudimg.io/v7/filerobot/js-cloudimage-360-view/360_view.svg) 50% 50% / cover no-repeat;
}
.cloudimage-360-box-shadow {
	top: 0;
  	left: 0;
}
.cloudimage-360-img-magnifier-glass {
	border: 3px solid #000;
  	border-radius: 50%;
}

Config

class

Type: String | Value: "cloudimage-360" | required

The selector for js-cloudimage-360-view lib.

data-folder (or folder)

Type: String(url) | required

Your images folder on server.

data-api-version (or api-version)

Type: String |Default: 'v7' | optional

Allow to use a specific version of API.

  • set a specific version of API
data-api-version="v7"
  • disable API version
data-api-version="null"

data-filename-x (or filename-x)

Type: String | Default: image-{index}.jpg | optional

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-filename-y (or filename-y)

Type: String | Default: image-y-{index}.jpg | optional

The same for data-amount-x but for images set in Y-axis.

data-amount-x (or amount-x)

Type: Number | Default: 36 | optional

Amount of images to load in X-axis for 360 view .

data-amount-y (or amount-y)

Type: Number | Default: 0 | optional

Amount of images to load in Y-axis for 360 view.

data-keys (or keys)

Type: Bool | Default: false | optional

Support for 360 spin by pressing arrow keys on keyboard.

data-keys-reverse (or keys-reverse)

Type: Bool | Default: false | optional

invert arrow keys on keyboard.

data-autoplay (or autoplay)

Type: Bool | Default: false | optional

Autoplay 360 spin view on load.

data-play-once (or autoplay)

Type: Bool | Default: false | optional

stops the autoplay after one complete cycle.

data-autoplay-behavior (or autoplay-behavior)

Type: String | Default: spin-x | optional

Changing autoplay behavior

Available behaviors (spin-x, spin-y, spin-xy, spin-yx)

data-fullscreen (or fullscreen)

Type: Bool | Default: false | optional

Open 360 spin view in full screen modal.

data-magnifier (or magnifier)

Type: Number | Default: none | optional

Magnifier to zoom image.

data-ratio (or ratio)

Type: Number (width / height) or JSON object | Default: none | optional

ratio: string

Setting the height relative to the container width according to the provided ratio

<div
   class="cloudimage-360"
   id="gurkha-suv"
   data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
   data-filename-x="orange-{index}.jpg"
   data-amount-x="73"
   data-ratio="2"
></div>

edit in codesandbox

ratio: JSON

Setting 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.

<div
   class="cloudimage-360"
   id="gurkha-suv"
   data-folder="https://scaleflex.cloudimg.io/v7/demo/suv-orange-car-360/"
   data-filename-x="orange-{index}.jpg"
   data-amount-x="73"
   data-ratio='{
      "576": "1.3",
      "768": "2.22",
      "992": "2.23",
      "1200": "3",
      "2400": "3.2"
   }'
></div>

edit in codesandbox

data-autoplay-reverse (or autoplay-reverse)

Type: Bool | Default: false | optional

Autoplay 360 spin view on load.

data-disable-drag (or disable-drag)

Type: bool | Default: false | optional

disable mouse drag.

data-speed (or speed)

Type: Number | Default: 150 | optional

Speed of changing frames for autoplay in milliseconds.

data-drag-speed (or drag-speed)

Type: Number | Default: 150 | optional

Speed Factor of changing frames on drag event.

data-spin-reverse (or spin-reverse)

Type: Bool | Default: false | optional

Spin direction, by default it uses counterclockwise (image indexes from 1 to data-amount-x).

data-box-shadow (or box-shadow)

Type: String (e.g. data-box-shadow="inset 0 0 100px #222") | Default: none | optional

Apply box shadow for container.

data-bottom-circle (or bottom-circle)

Type: Bool | Default: false | optional

Display 360 view line at the bottom of container.

data-hide-360-logo (or hide-360-logo)

Type: Bool | Default: false | optional

Hide 360 view icon.

data-control-reverse (or control-reverse)

Type: Bool | Default: false | optional

Spin direction using controls, by default it uses counterclockwise (image indexes from 1 to data-amount-x).

data-stop-at-edges (or stop-at-edges)

Type: Bool | Default: false | optional

Blocks repeating images after reaching last image (or first image in opposite direction)

data-bottom-circle-offset (or bottom-circle-offset)

Type: Number | Default: 5 | optional

Bottom offset for 360 view line.

data-index-zero-base (or index-zero-base)

Type: Number | optional

Left zero padding on filename. For example: index-zero-base="4" => image index will be "0004"

data-image-list-x (or data-image-list-x)

Type: Array | optional

Option to add list of images in x-oriantation instead of folder , filename-x & amount-x.

example:

data-folder="https://scaleflex.cloudimg.io/v7/demo/360-car/"
data-image-list-x='[
   "iris-1.jpeg",
   "iris-4.jpeg",
   "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-12.jpeg",
   "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-15.jpeg"
   ]’

data-image-list-y (or data-image-list-y)

Type: Array | optional

Option to add list of images in y-oriantation instead of folder , filename-y & amount-y.

example:

data-folder="https://scaleflex.cloudimg.io/v7/demo/360-car/"
data-image-list-y='[
   "iris-2-y.jpeg",
   "iris-6-y.jpeg",
   "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-8-y.jpeg",
   "https://scaleflex.cloudimg.io/v7/demo/360-car/iris-30-y.jpeg"
   ]’

data-pointer-zoom (or pointer-zoom)

Type: Number | Default: none | optional

Option to scale images on click on it to provided value.

example:

data-pointer-zoom="3"

data-lazyload (or lazyload)

Type: Bool | Default: false | optional

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

data-lazyload-selector (or lazyload-selector)

Type: String | Default: lazyload | optional

Helper class to apply lazy-loading depending on library you choose, see Lazy loading

Controls

You can add controls by adding elements with the following classes: cloudimage-360-left, cloudimage-360-right, cloudimage-360-top, **cloudimage-360-bottom

Example CSS

.cloudimage-360 .cloudimage-360-left, .cloudimage-360 .cloudimage-360-right {
	padding: 8px;
	background: rgba(255, 255, 255, 0.5);
	border: none;
	border-radius: 4px;
}
.cloudimage-360 .cloudimage-360-left:focus, .cloudimage-360 .cloudimage-360-right:focus {
	outline: none;
}
.cloudimage-360 .cloudimage-360-left {
	display: none;
	position: absolute;
	z-index: 100;
	top: calc(50% - 15px);
	left: 20px;
}
.cloudimage-360 .cloudimage-360-right {
	display: none;
	position: absolute;
	z-index: 100;
	top: calc(50% - 15px);
	right: 20px;
}
.cloudimage-360 .cloudimage-360-left:before, .cloudimage-360 .cloudimage-360-right:before {
	content: '';
	display: block;
	width: 30px;
	height: 30px;
	background: 50% 50% / cover no-repeat;
}
.cloudimage-360 .cloudimage-360-left:before {
	background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-left.svg');
}
.cloudimage-360 .cloudimage-360-right:before {
	background-image: url('https://cdn.scaleflex.it/plugins/js-cloudimage-360-view/assets/img/arrow-right.svg');
}
.cloudimage-360 .cloudimage-360-left.not-active, .cloudimage-360 .cloudimage-360-right.not-active {
	opacity: 0.4;
	cursor: default;
}

Example HTML

<div
	class="cloudimage-360"
	data-folder="https://scaleflex.cloudimg.io/v7/demo/360-car/"
	data-filename-x="{index}.jpeg"
>
	<button class="cloudimage-360-left"></button>
	<button class="cloudimage-360-right"></button>
	<button class="cloudimage-360-top"></button>
	<button class="cloudimage-360-bottom"></button>
</div>

edit in codesandbox

Allow the view to spin in both X, Y axes

Requirements

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:

<div
   class="cloudimage-360"
   data-folder="https://scaleflex.cloudimg.io/v7/demo/360-nike/"
   data-filename-x="nike-{index}.jpg"
   data-filename-y="nike-y-{index}.jpg"
   data-amount-x="35"
   data-amount-y="36"
>
</div>

edit in codesandbox

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.

Requirements

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.

Create hotspots configuration

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:

const HOTSPOTS_CONFIG = [
 {
  positions: [
   { imageIndex: 0, xCoord: 527, yCoord: 319 },
   { imageIndex: 1, xCoord: 524 },
   { imageIndex: 2, xCoord: 520 },
   { imageIndex: 3, xCoord: 498 },
   { imageIndex: 4, xCoord: 470 },
   { imageIndex: 5, xCoord: 441 },
  ]
 }
]

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.

Variant

Link

we need to provide the URL of the link and the link title.

example:

const HOTSPOTS_CONFIG = [
 {
  positions,
  variant: {
  title: 'New Gurkha Technical Specifications',
  url: 'https://www.forcegurkha.co.in/specifications/',
  newTab: true
  }
 }
]

Popup

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:

const HOTSPOTS_CONFIG = [
 {
  positions,
  variant: {
   images: [
    { src: 'https://scaleflex.cloudimg.io/v7/demo/360-assets/AIR_SNORKEL_FINAL_JPG.png?vh=88bccb', alt: 'air snorkel' }
   ], // optional
   title: 'Air Intake Snorkel', // optional
   description: 'The snorkel gives the Gurkha an unmatched water-wading ability and ensures ample supply of fresh air for combustion.', // optional
   moreDetailsUrl: 'https://forcegurkha.co.in', // optional
   moreDetailsTitle: 'Read more' // optional
  }
 }
]

Custom

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:

const HOTSPOTS_CONFIG = [
 {
  positions,
  variant: 'gurkha-suv'
 }
]

PopupProps

Options to customize the hotspot popup.

Properties

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:

const HOTSPOTS_CONFIG = [
 {
  positions,
  variant,
  popupProps: {
   popupSelector: 'air-intake-popup', // optional
   offset: [20, 5], // optional
   arrow: false, // optional
   placement: 'bottom' // optional
  },
  indicatorSelector: 'first-hotspot-icon' // optional
 }
]

Responsive hotspots

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:

const HOTSPOTS_CONFIG = [
 {
   positions,
   variant,
   popupProps,
   indicatorSelector,
   initialDimensions: [ 1170, 662 ]
 }
]

Add Hotspots

we need this function to link the created config with the 360-view.

window.CI360.addHotspots(idOftheView, hotspotsConfig);

example:

window.CI360.addHotspots("gurkha-suv", HOTSPOTS_CONFIG);

edit in codesandbox

data-responsive (or responsive)

Type: String (Cloudimage token) | Default: none | required for cloudimage responsive plugin

Enables cloudimage responsive plugin for 360 view.

See how it works (article on Medium)

Requirements

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.

data-responsive (or responsive)

Type: String (Cloudimage token) | Default: none | required for cloudimage responsive plugin

Enables cloudimage responsive plugin for 360 view.

data-request-responsive-images (or request-responsive-images)

Type: Bool | Default: false

Request new images on resize, based on the container width.

data-transformation (or transformation)

Type: String | Default: none | optional

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:

data-transformation="w=400&h=200&func=fit"

Full documentation here.

data-filters (or filters)

Type: String | Default: none | optional

Applies Cloudimage filters to your image, e.g. brightness, contrast, greyscale, blur, Sharpen... Multiple filters can be applied, separated by "," (comma). example:

data-filters="bright:15,contrast:30"

Full documentation here.

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

  • In order to use cloudimage responsive with 360 view, your original (master) images should be stored on a server or storage bucket (S3, Google Cloud, Azure Blob...) reachable over HTTP or HTTPS by Cloudimage. If you want to upload your master images to Cloudimage, contact us at [email protected].

Browser support

Tested in all modern browsers and IE 11, 10, 9.

Filerobot UI Familiy

Contributing!

All contributions are super welcome!

License

JS Cloudimage 360 View is provided under the MIT License

js-cloudimage-360-view's People

Contributors

ahmeeedmostafa avatar amrelbialy avatar amrw-js avatar dzmitry-stramavus avatar justinfeakes avatar nqanhtu avatar sassninja avatar sfx-jfou avatar twilco avatar vitaly-shaposhnik avatar wagdy-git avatar zdavidsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-cloudimage-360-view's Issues

3D Support?

Great work!

We have images that are 3D instead of 360, so you can also move vertically, instead of only horizontally. Upon a brief look at the documentation, it doesn't seem to support this.

Is it possible? Or are there any other projects that support this?

Multiple instances of the plugin , doesn't show the same active image as 1

Hi,

First of all great plugin, kudos to you guys. We have been adapting to our application and recreating the same magic within our application. We came across a issue regarding the rendering the first active image. We followed the same implementation which was shown in
https://codesandbox.io/s/6479n17j73?fontsize=14&module=%2Findex.html , we have two instances just like in the example. Instead of 36 images, we have 100 images for both instances. Now when we reload the application the both instances active image are kept on changing instead of showing 1. When I checked your demo sandbox, it happens same on that as well.. Can we have all the multiple instances with active image as 1 instead of changing?

Do let me know if you need any inputs from my side

data-autoplay once

Hi,

is there a way, to data-autoplay once and than stop automaticly?

Thanks

The engine remember last turn of image

Hello. I am using your "plugin" in wordpress, it works fine, but when I left the turned product (for example: I close the website with image turned to image4), and reopen the site, the viewer is set to image4. I would like to set viewer to image1 every time I open the website. How can I do that? I have found no javascript cookies, or similar inside the code.

Thank you a lot. Have a nice day

Skipping last image

Good evening,

I've started using this script and at first thought the last image was skipping on autoplay. With autoplay off, it's still skipping the last image, however only when dragging the image counter clockwise. If I drag clockwise, the last image is present.

Version: 2.1.0
Browser: Firefox, Chrome.
16 images, speed 250.

drag-speed ?

Would it be possible to get an attribute to control the drag speed?
Our client find it to be a bit slow :)

Also "data-autoplay" / "autoplay" doesn't work because it's not cast as a bool, so it's always true :)

Cheers

How to change magnifier level after loading?

It seems that there is no interface to change magnifier level after loading.

I am using vuejs and i tried to change data-magnifier attribute on runtime but it fails.

Can you add the feature?? or
Can you give me any trick for handling them??

Thank you!!!

change width and height of canvas element

Tried to change the width and height of the canvas, because the images are too big.

But it did not work.

document.getElementsByTagName('canvas')[0].style = 'width: 600px';

  let canvas = document.getElementsByTagName('canvas')[0];
  canvas.width = 600;
  canvas.height = 600;

Any ideas ? Thanks before 😊

initial plugin with local images

Hey guys,
We want to use local images in this plugin, but not working with local path in data-folder attribute.
How can we fix that?

Magnifier doesn't work when you use a data-image-list

Hey, Love your plugin.

I'm using a data-image-list instead of a folder path like the below:
<div class="cloudimage-360" data-image-list='[ "https://mysite.com/assets/alt_11/SPD1R.jpg", "https://mysite.com/assets/alt_12/SPD1R.jpg", "https://mysite.com/assets/alt_13/SPD1R.jpg", "https://mysite.com/assets/alt_14/SPD1R.jpg", "https://mysite.com/assets/alt_15/SPD1R.jpg", "https://mysite.com/assets/alt_16/SPD1R.jpg", "https://mysite.com/assets/alt_17/SPD1R.jpg", "https://mysite.com/assets/alt_18/SPD1R.jpg"]' data-magnifier="2">

Everything is working fine except when I try and use the magnifier, you get an endless load icon and in the console.log it shows that its trying to load the current image from the root folder: GET https://mysite.com/image-8.jpg 404

Am I missing a setting or is this a bug?

Changing the colour of the magnifying glass icon?

Is there any way I can change the colour of the magnifying glass icon using CSS?

My image backgrounds have a similar colour to it, so the icon isn't visible to my users currently.

I am looking for a selector that will only affect the magnifying glass and not the general "360 view" circle that appears in the centre of the image.

X spin plus Y ?

I've got a slew of images naming convention of 'filename-01-01.jpeg' so I'm running into trouble displaying them as they have a column and a row number, not just one as required for this app. Short from renaming every file and forgetting the Y axis rotation, is there a way to use my files with two numbers instead of one ?

First preview image is random

We are using your awesome 360° product viewer ( https://github.com/scaleflex/js-cloudimage-360-view ), but we have just one question:

We have implemented your code into WordPress custom template. We are using 9 images of a window’s profile. The problem is, that from time to time, the preview doesn’t start from image number 1, but it seems, the number is random.

Here’s the link on live version: http://dev.bajan.sk/rafaelwin/okenne-profily/

The first image should be with front view and opened window.

But from time to time, no 1st image is visible, when user open the site

This happen especially in Firefox, every time you refresh the page with F5, you get another turn of imageset.

How can I be safe, that first image will be always loaded at the opening of the site?

How to reinit elements after ajax or fetch loading?

I have a problem. Some content im getting by ajax. And after, 360 plugin wont show. Im trying to reinit plugin window.CI360.init() or destroy, but thats not working. If element 360 is hidding (like in modal), and im show modal first image not showing.

image

Dynamic data-filename?

Is it possible to have a dynamic data-filename?

Ex. I have an Angular application and normally I would just modify it with string interpolation.

<div class="cloudimage-360" data-folder="../../../../assets/images/360images/" data-filename="{{filename}}_{index}.jpg" data-amount="12" data-magnifier="3" data-spin-reverse></div>

But when I do this it throws an error:
[ERROR ->]data-filename="{{filename}}_{index}.jpg"

Any suggestions?

View Image

Hi, great plugin. Is it possible to get the {index} of the image that is being viewed?

When you have rotated the image or when the image has loaded I would like to know which image is being viewed.

data-filename="myimage_{index}.jpg"

Thanks!

Add a normal zoom effect

Hello.
I've downloaded the library and im trying to edit the unminified file to add a standard-zoom function.

Actually, i've managed to edit the update function with a doubled size with this command:
t.drawImage(e, '-'+(r/2) , '-'+(a/2) , this.canvas.width * 2, this.canvas.height * 2)

My problem is that i need to add an eventlistener onclick, so i can activate my custom zoom function when you just click on the main image.
How can i add that? I've seen the whole code but im not too expert in JS and i don't understand how can i add my custom listener to the library.

Thank you in advance.

How to open the 360-view inside a modal

Hello,

I'm trying to open the 360-view inside a modal, but the modal loads empty, showing only the 360º view icon. On mouse drag, the image appears.

Is there a way to load the first image automatically, just like loading the 360-view directly on the page?

Thanks,

Server responded with a status of 429

I tried to setup a 360 degree view with this plugin and have the following

  • 40 images around 40kb each
  • All images hosted on a S3 bucket

But some of the images are not pulled in with the 429 Too Many Requests response. I have similar behavior when the images are hosted on another of my web servers. Is there a good way to handle this by
a) Adding small delay between image requests
b) Raise requests for missing images again ?

I understand the response is coming from S3 for requesting too many images too soon, I am looking for a decent way of handling cases like this.

Any suggestions / help on this matter would be greatly appreciated.

Loading cloudimage in a hidden div

I have a situation where I have cloudimage-360 loading in a hidden div (a modal).

Once I open the modal, I can see the '360º view' button but the canvas behind it has 0 heigh and 0 width. The first image of the model is not loaded.

If I click and drag the '360º view' button, the image loads.
Is there a way to overcome this?

drag event

is there an event for when the drag/move starts?
p.s. great plugin!

feat: controls

I need some controls because dragging is not the best solution for my use case (360 view within a modal). I've checked the source code but seems there's no hook for an easy extension.

So I ended up enabling keys and then dispatching the appropriate keyboard events on clicking/holding down my controls (prev/next) but this doesn't feel good and more like a hack.

What do you think about adding a controls feature to this plugin?

Possible markup could be:

<div class="cloudimage-360">
  <button class="cloudimage-360-prev">Prev</button>
  <button class="cloudimage-360-next">Next</button>
</div>

Add left padding on filename

const src = ${this.folder}${this.filename.replace('{index}', this.activeImage)};

If ma files are named
test-001.jpg
test-002.jpg

I can't use this plugin

I think it's quite simple to add an option to specify a left padding on filename

Thanks

Chrome warning for non passive event-listener

Hi @dzmitry-stramavus, thanks for the great work!
I've noticed this warning on the console and I think it is caused by this event listener.

In addition this kind of optimization should be necessary only on touchstart and touchmove but not in touchend. It could also be useful to apply a passive listener only if supported. Something like:

applyPassive() {
	if (this._supportsPassive !== undefined) {
		return this._supportsPassive ? { passive: true } : false
	}

	// feature detect
	let isSupported = false
	try {
		document.addEventListener('test', null, {
			get passive() {
				isSupported = true
			},
		})
	} catch (e) {
		// do nothing
	}

	this._supportsPassive = isSupported
	return this.applyPassive()
}

this.container.addEventListener('touchmove', this.touchmove.bind(this));

If you think this could be done I would be happy to prepare a PR

IE 11 sono

Hey,

I'm getting some console log errors in IE 11 which keeps mounting up (screenshot attached):

Screenshot 2020-11-10 at 10 17 54

Screenshot 2020-11-10 at 10 13 28

Any advice here would be grateful.

Translate the view360Icon?

Hello,

Is there a way to provide a custom SVG or translate the view360Icon?

I need to translate it to French.

Thanks,

Index is not defined when used the Lazyload

Hello;
When i active the lazyload with plugin lazysizes, i'm receive this error (it's works if disable the lazyload) :

Dom Code

<section>
            <div class="cloudimage-360"
                data-folder="/assets/img/wheel/"
                data-filename="wheel-{index}.jpeg"
                data-amount="70"
                 data-ratio="0.86"
                 data-autoplay
                 data-bottom-circle
                 data-lazyload></div>
</section>

image
image

Multires zoom?

As progressive image formats (like FLIF) aren't supported yet, it would increase performance and bandwith utilization significantly,
when multiresolution zooming is implemented. This means that the image is tiled and offered with different tile sizes for different zoom levels.

help canvas/transform/scale zoom and magnify works fine

Hi!

Is there any way to adjust position and level of magnifier zoom when image canvas is zoomed with transform scale ?

I add feature for zoom-in-out image using css transform scale.

It works fine but after zoom in or out, magnifier is working on origin image so it looks bad.

I checked source code and moveMagnifier and magnify is related but I failed to achieve my goal.

Can you give me some tip?? Thank you!!!!!!!!!

keyboard control direction strangely linked with autoplay direction

Another strange behavior I noticed was with the "data-keys" option, which enables keyboard control of the 360 viewer.

I see in the code that the direction for the keyboard arrows are linked to the autoplay direction for some very strange reason.

Here's the relevant section of the code, which is the keydown() function. I can see that the 37 and 39 key codes (left and right arrow on keyboard) conditionally call this.prev() and this.next() based on "this.reversed".

keydown(event) {
  ...
  if ([37, 39].includes(event.keyCode)) {
    if (37 === event.keyCode) {
      if (this.reversed)
        this.prev();
      else
        this.next();
    } else if (39 === event.keyCode) {
      if (this.reversed)
        this.next();
      else
        this.prev();
    }

    this.onSpin();
  }
  ...
}

I can see that "this.reversed" is set within the init() function and it is set to "autplayReverse".

init(container) {
   ...
  this.reversed = autoplayReverse;
   ...
}

I find this to be super confusing (that the autoplay direction is for both autoplay and keyboard control) and I think others may feel the same way too. I'm sure not everyone would agree this is exactly a bug, per say, but this still seems like an issue that will cause a lot of confusion.

Can the official dev add a new data option for the keyboard control direction? Something like "data-keys-reverse", which sets the direction purely for the keyboard control? This way, the keyboard control and autoplay direction would no longer be strangely linked together.

Manner to set initial image number?

Hello,
Terrific JS that you've shared... thank you! I have the following question:

Is there a manner in which a specific image number can be set as the default image that is displayed on the page?

For example, if I load 24 images... can I set it so that the initial image is # 12 instead of always starting with # 1 as the initial image? Thank you for any help on this!

How to customize preloaders

Good day!
Thanks for a cool and very useful plugin!

Is there an easy way to customize the preloader? There are actually two of them. The stripe at the top and the percents counter in the middle. I need to turn off the upper stripe/progress bar thing or move it to the bottom and change its color. Is that possible?

[Feature] Zoom with mouse wheel

Hi,
Can you implement a mouse wheel zoom feature?
Similar to navigation in a CAD software: scroll to zoom in/out. Click and drag to rotate.

intermediate frame

When using fewer images, like 32, it is the best if an "intermediate frame" can be inserted between 2 frames when spinning to make the transition smoother. For example, a fading out effect. Any plan on this enhancement?

Great work! Thanks

Offer a web component entrypoint?

Web components offer a really nice dev experience, and encapsulate component internals to prevent interference from third-party JS and CSS.

Instead of:

<div
   class="cloudimage-360"
   data-folder="https://scaleflex.cloudimg.io/crop/1920x700/n/https://scaleflex.airstore.io/demo/360-car/"
   data-filename="iris-{index}.jpeg"
   data-amount="36"
></div>

A developer would write something like:

<cloudimage-360
   folder="https://scaleflex.cloudimg.io/crop/1920x700/n/https://scaleflex.airstore.io/demo/360-car/"
   filename="iris-{index}.jpeg"
   amount="36"
></cloudimage-360>

Shadow DOM can hold the internals of the element so that CSS selectors don't accidentally select them.

With IDEs like VS Code supporting custom element metadata published to npm in custom-elements.json files, developers using cloudimage-360 via npm can get code-completion, hover-over docs, linting, etc., in any HTML-mode editing.

Synchronize 2 viewers in same CI360 instance

Hi,
Thanks for this awesome plugin by the way.
I would like to know if there is a way to synchronize two viewers in same instance when there is an update in the active frame.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.