@3dweb/360javascriptviewer 1.8.49 → 1.8.50
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/LICENCE +6 -6
- package/Readme.md +209 -213
- package/lib/JavascriptViewer.esm.js +1 -1
- package/lib/JavascriptViewer.js +1 -1
- package/package.json +85 -85
- package/typings/JavascriptViewer.d.ts +406 -406
package/LICENCE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright 2020 Jeroen Termaat
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2020 Jeroen Termaat
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/Readme.md
CHANGED
|
@@ -1,214 +1,210 @@
|
|
|
1
|
-
# 360 Javascript Viewer
|
|
2
|
-
A flexible light responsive 360 image viewer with zoom functions. You can use it with npm (typescript support)
|
|
3
|
-
or include the script on your page. Autorotate, batch loading of images, inertia and speed control.
|
|
4
|
-
Events for making custom progress bars, intro animations and custom zoom functions.
|
|
5
|
-
Several methods for navigation from outside which return promises for easy chaining of actions.
|
|
6
|
-
Use all kind of images from any location with flexible start numbering and filenames.
|
|
7
|
-
|
|
8
|
-
Check for examples on [360-javascriptviewer.com](https://360-javascriptviewer.com)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
- **
|
|
102
|
-
|
|
103
|
-
- **
|
|
104
|
-
|
|
105
|
-
- **
|
|
106
|
-
|
|
107
|
-
- **
|
|
108
|
-
|
|
109
|
-
- **
|
|
110
|
-
|
|
111
|
-
- **
|
|
112
|
-
|
|
113
|
-
- **
|
|
114
|
-
|
|
115
|
-
- **
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
 
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
 
|
|
188
|
-
 
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
 
|
|
192
|
-
  
|
|
193
|
-
&ensp
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
 
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
 
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
 
|
|
208
|
-
 
|
|
209
|
-
|
|
210
|
-
- IImage {
|
|
211
|
-
  id: string;
|
|
212
|
-
  src: string;
|
|
213
|
-
  sequence: number;
|
|
1
|
+
# 360 Javascript Viewer
|
|
2
|
+
A flexible light responsive 360 image viewer with zoom functions. You can use it with npm (typescript support)
|
|
3
|
+
or include the script on your page. Autorotate, batch loading of images, inertia and speed control.
|
|
4
|
+
Events for making custom progress bars, intro animations and custom zoom functions.
|
|
5
|
+
Several methods for navigation from outside which return promises for easy chaining of actions.
|
|
6
|
+
Use all kind of images from any location with flexible start numbering and filenames.
|
|
7
|
+
|
|
8
|
+
Check for examples on [360-javascriptviewer.com](https://360-javascriptviewer.com)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
using npm with typescript declaration file:
|
|
12
|
+
|
|
13
|
+
npm i @3dweb/360javascriptviewer
|
|
14
|
+
|
|
15
|
+
import {JavascriptViewer} from "@3dweb/360javascriptviewer";
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
or use the CDN to get the latest version
|
|
19
|
+
|
|
20
|
+
<script src="https://cdn.jsdelivr.net/npm/@3dweb/360javascriptviewer@1/lib/JavascriptViewer.min.js"></script>
|
|
21
|
+
|
|
22
|
+
## Basic usage
|
|
23
|
+
First create a div where the 360 presentation will be created. We use the size of this div to calculate
|
|
24
|
+
zoom positions. The events for dragging and zooming are also added to this div (default #jsv-holder).
|
|
25
|
+
Insert a image in it which is often the first image of the 360 image serie. This image will be replaced by the
|
|
26
|
+
360 presentation when it's fully loaded. If you don't specify otherwise this image is used to determine the other image filenames.
|
|
27
|
+
If the main image is product.jpg, the other images in the same folder must be called product_1.jpg, product_2.jpg and so on.
|
|
28
|
+
But if you have other filenames/locations for your 360 images, you can change this naming format behaviour with the imageUrlFormat parameter.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<div id="jsv-holder">
|
|
33
|
+
<img id="jsv-image" alt="example" src="https://360-javascriptviewer.com/images/ipod/ipod.jpg">
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
const viewer = new JavascriptViewer({
|
|
38
|
+
mainHolderId: 'jsv-holder',
|
|
39
|
+
mainImageId: 'jsv-image',
|
|
40
|
+
totalFrames: 72,
|
|
41
|
+
speed: 70,
|
|
42
|
+
defaultProgressBar: true
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// use events for example
|
|
46
|
+
viewer.events().loadImage.on((progress) => {
|
|
47
|
+
// use this for your own progress bar
|
|
48
|
+
console.log(`loading ${progress.percentage}%`)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
viewer.events().started.on((result) => {
|
|
52
|
+
// use a promise or a start event to trigger things
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
viewer.start().then(() => {
|
|
56
|
+
viewer.rotateDegrees(180).then(() => {
|
|
57
|
+
// continue with your amazing intro
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
# API
|
|
63
|
+
## Constructor
|
|
64
|
+
|
|
65
|
+
| property | type | description | default |
|
|
66
|
+
|-----------------------------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------|
|
|
67
|
+
| mainImageId | string | ID of the image which is the base for all the frames. You can also use mainImageUrl if the path of the other files are different. | jsv-image |
|
|
68
|
+
| mainHolderId | string | ID of the div where the presentation runs in. | jsv-holder |
|
|
69
|
+
| mainImageUrl | string | URl of the first image, doesn't have to be in the document. Not needed when using imageUrls | |
|
|
70
|
+
| totalFrames | number | Amount of frames in the presentation, more images means smoother rotations. | 72 |
|
|
71
|
+
| imageUrls | string[] | Array of image urls, overrides totalFrames and imageUrlFormat | [] |
|
|
72
|
+
| firstImageNumber | number | After loading the presentation this is the first frame visible. | 1 |
|
|
73
|
+
| reverse | boolean | Invert the rotation direction when dragging. | false |
|
|
74
|
+
| speed | number | Speed of rotating. -199 to 100 | 80 |
|
|
75
|
+
| inertia | number | Delay when stop dragging. | 20 |
|
|
76
|
+
| defaultProgressBar | boolean | Disable the build in progress bar, use this when you have implemented your own loader or don't like this one. | true |
|
|
77
|
+
| defaultProgressBarColor | string | Change the color of the progress bar, can be hex of rgb. | rgb(0, 0, 0) |
|
|
78
|
+
| defaultProgressBarBackgroundColor | string | Change the background color of the progress bar, can be hex of rgb. | rgba(255, 255, 255, 0.5) |
|
|
79
|
+
| defaultProgressBarHeight | string | Change the height of the progress bar, can be any css value for height. | 5px |
|
|
80
|
+
| imageUrlFormat | string | Format for determining the filenames of the frames {filename}_xx.{extension} is the default ipod_x.jpg => ipod_1.jpg ipod_xx.jpg => ipod_01.jpg https://other.cdn/images/ipod_xx.jpg => https://other.cdn/images/ipod_01.jpg | {filename}_xx.{extension} |
|
|
81
|
+
| extraImageClass | string | Add a class to all the images used in the presentation, separate multiple classes with a space. | empty |
|
|
82
|
+
| imageAltText | string | Add an alt text to the images, all images will have the same alt text. | empty |
|
|
83
|
+
| startFrameNo | number | Use this setting in combination with imageUrlFormat startFrameNo: 4 => first file is ipod_04.jpg | 1 |
|
|
84
|
+
| autoRotate | number | Use this setting for rotating the view at start. Rotation stops when user drags the model or another animation method is called. | 0 |
|
|
85
|
+
| autoRotateSpeed | number | Speed of autorotation. -199 to 100 | 1 |
|
|
86
|
+
| autoRotateReverse | boolean | Use this setting for changing the direction of the auto rotating. | 1 |
|
|
87
|
+
| enableImageEvents | boolean | Use this setting for enabling click pinch and wheel events on images. | 0 |
|
|
88
|
+
| zoom | boolean | Use this setting for enabling zoom functions. Zoom on wheel event or pinch. | 0 |
|
|
89
|
+
| zoomWheelSpeed | number | Change the speed of zooming with the mousewheel. | 50 |
|
|
90
|
+
| zoomMax | number | If zoom is enabled this is the max zoom factor. | 2 |
|
|
91
|
+
| stopAtEdges | boolean | Blocks repeating images after reaching last image. | 0 |
|
|
92
|
+
| autoCDNResizer | boolean | Set the query params height and width for use with an image resizer. | 0 |
|
|
93
|
+
| autoCDNResizerConfig | IAutoCDNResizerConfig | Config for adding query params to image urls. | 0 |
|
|
94
|
+
| enableChangeImageEvent | boolean | Enable changeImage event on rotation, could be CPU heavy | 0 |
|
|
95
|
+
| cursorConfig | ICursorConfig | Change the cursors for the presentation | |
|
|
96
|
+
| notificationConfig | InotificationConfig | Configure the default notifications | |
|
|
97
|
+
|
|
98
|
+
## Methods
|
|
99
|
+
- **start()**:Promise<void>
|
|
100
|
+
Start the presentation, loading all images and replace the main image with a 360 presentation.
|
|
101
|
+
- **destroy()**:Promise<boolean>
|
|
102
|
+
Destroys the presentation and returns to previous state-
|
|
103
|
+
- **rotateDegrees(degree: number)**:Promise<IResponse>
|
|
104
|
+
Set the desired rotation and the 360 model is rotating to it.
|
|
105
|
+
- **rotateToDegree(targetDegree: number, shortestWay?: boolean, useEasing?: boolean))**:Promise<IResponse>
|
|
106
|
+
Rotate to a certain degree. Frame nr 1 is 0 degrees.
|
|
107
|
+
- **rotateToFrame(frame: number, shortestWay?: boolean, useEasing?: boolean))**:Promise<IResponse>
|
|
108
|
+
Rotate to a certain frame.
|
|
109
|
+
- **setSpeed(speed:number)**:void
|
|
110
|
+
Zoom and pan in the image.
|
|
111
|
+
- **zoomTo(factor: number, x: number, y: number)**:Promise<void>
|
|
112
|
+
Zoom with a factor and pan in percentage from the middle -1-0 and 0-1.
|
|
113
|
+
- **setInertia(inertia:number)**:void
|
|
114
|
+
Set the current inertia of the viewer
|
|
115
|
+
- **events()**:IEvents
|
|
116
|
+
Use this to register events.-
|
|
117
|
+
**isZoomedIn()**:boolean
|
|
118
|
+
Checks if the presentation is zoomed.
|
|
119
|
+
|
|
120
|
+
## Events
|
|
121
|
+
- **loadImage**:IProgress
|
|
122
|
+
Use this event to create your own progress bar
|
|
123
|
+
` viewer.events().loadImage.on((progress) => {
|
|
124
|
+
// use the progress object for your own loader
|
|
125
|
+
}) `
|
|
126
|
+
|
|
127
|
+
- **started**:boolean
|
|
128
|
+
Use this event to trigger other actions when the viewer is ready
|
|
129
|
+
` viewer.events().started.on((boolean) => {
|
|
130
|
+
// start intro animations or other creative ideas
|
|
131
|
+
}) `
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
- **startDragging**:IHandle
|
|
135
|
+
Use this event to capture the user drag movement.
|
|
136
|
+
` viewer.events().startDragging.on((handle) => {
|
|
137
|
+
// show or hide information on the viewer or send statistics
|
|
138
|
+
}) `
|
|
139
|
+
|
|
140
|
+
- **changeImage**:IStatus
|
|
141
|
+
Fires when a new image becomes visible, works in combination with enableChangeImageEvent:true
|
|
142
|
+
` viewer.events().changeImage.on((handle) => {
|
|
143
|
+
// show or hide information on the viewer or send statistics
|
|
144
|
+
}) `
|
|
145
|
+
|
|
146
|
+
- **endAutoRotate**:IStatus
|
|
147
|
+
Fires when autorotate stops
|
|
148
|
+
` viewer.events().endAutoRotate.on((status) => {
|
|
149
|
+
// show or hide information on the viewer or send statistics
|
|
150
|
+
}) `
|
|
151
|
+
|
|
152
|
+
- **click**:IClick
|
|
153
|
+
Fires when the user clicks on a image, works in combination with enableImageEvents: true
|
|
154
|
+
` viewer.events().click.on((click) => {
|
|
155
|
+
// Use this event for zoom functions
|
|
156
|
+
}) `
|
|
157
|
+
|
|
158
|
+
- **pinch**:IPinch
|
|
159
|
+
Fires when the user pinch on a image (zoom on mobile with 2 fingers), works in combination with enableImageEvents: true
|
|
160
|
+
` viewer.events().pinch.on((click) => {
|
|
161
|
+
// Use this event for zoom functions
|
|
162
|
+
}) `
|
|
163
|
+
|
|
164
|
+
- **scroll**:IScroll
|
|
165
|
+
Fires when the user use the mouse scroll, works in combination with enableImageEvents: true
|
|
166
|
+
` viewer.events().pinch.on((click) => {
|
|
167
|
+
// Use this event for zoom functions
|
|
168
|
+
}) `
|
|
169
|
+
|
|
170
|
+
- **doubleClick**:IClick
|
|
171
|
+
Fires when the user double clicks on a image, works in combination with enableImageEvents: true
|
|
172
|
+
` viewer.events().pinch.on((click) => {
|
|
173
|
+
// Use this event for zoom functions
|
|
174
|
+
}) `
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
## Interfaces
|
|
178
|
+
- IResponse {
|
|
179
|
+
  currentDegree: number;
|
|
180
|
+
}
|
|
181
|
+
- IAutoCDNResizerConfig {
|
|
182
|
+
  useWidth: boolean;
|
|
183
|
+
  useHeight: boolean; //default true
|
|
184
|
+
  scaleWithZoomMax: boolean; //default false loads images with the zoomMax factor for height or width
|
|
185
|
+
}
|
|
186
|
+
- notificationConfig {
|
|
187
|
+
  dragToRotate: {
|
|
188
|
+
   showStartToRotateDefaultNotification: boolean,
|
|
189
|
+
   imageUrl: string,
|
|
190
|
+
   languages: ITranslation[],
|
|
191
|
+
   mainColor: string //hex,rgb or rgba color
|
|
192
|
+
   textColor: string //hex,rgb or rgba color
|
|
193
|
+
  }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
- ITranslation { [
|
|
197
|
+
  language: string, //ISO Language Code (en-US,nl-NL)
|
|
198
|
+
  text: string
|
|
199
|
+
]}
|
|
200
|
+
|
|
201
|
+
- IStatus {
|
|
202
|
+
  currentDegree: number;
|
|
203
|
+
  currentImage: IImage;
|
|
204
|
+
  completed: boolean;
|
|
205
|
+
}
|
|
206
|
+
- IImage {
|
|
207
|
+
  id: string;
|
|
208
|
+
  src: string;
|
|
209
|
+
  sequence: number;
|
|
214
210
|
}
|