@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 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
- Check for cloud solution on [3DWeb.io](https://3dweb.io)
10
-
11
- ## Installation
12
- using npm with typescript declaration file:
13
-
14
- npm i @3dweb/360javascriptviewer
15
-
16
- import {JavascriptViewer} from "@3dweb/360javascriptviewer";
17
-
18
-
19
- or use the CDN to get the latest version
20
-
21
- <script src="https://cdn.jsdelivr.net/npm/@3dweb/360javascriptviewer@1/lib/JavascriptViewer.min.js"></script>
22
-
23
- ## Basic usage
24
- First create a div where the 360 presentation will be created. We use the size of this div to calculate
25
- zoom positions. The events for dragging and zooming are also added to this div (default #jsv-holder).
26
- Insert a image in it which is often the first image of the 360 image serie. This image will be replaced by the
27
- 360 presentation when it's fully loaded. If you don't specify otherwise this image is used to determine the other image filenames.
28
- 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.
29
- But if you have other filenames/locations for your 360 images, you can change this naming format behaviour with the imageUrlFormat parameter.
30
-
31
-
32
-
33
- <div id="jsv-holder">
34
- <img id="jsv-image" alt="example" src="https://360-javascriptviewer.com/images/ipod/ipod.jpg">
35
- </div>
36
-
37
- <script>
38
- const viewer = new JavascriptViewer({
39
- mainHolderId: 'jsv-holder',
40
- mainImageId: 'jsv-image',
41
- totalFrames: 72,
42
- speed: 70,
43
- defaultProgressBar: true
44
- });
45
-
46
- // use events for example
47
- viewer.events().loadImage.on((progress) => {
48
- // use this for your own progress bar
49
- console.log(`loading ${progress.percentage}%`)
50
- })
51
-
52
- viewer.events().started.on((result) => {
53
- // use a promise or a start event to trigger things
54
- })
55
-
56
- viewer.start().then(() => {
57
- viewer.rotateDegrees(180).then(() => {
58
- // continue with your amazing intro
59
- })
60
- });
61
- </script>
62
-
63
- # API
64
- ## Constructor
65
-
66
- | property | type | description | default |
67
- |-----------------------------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------|
68
- | id | string | ID of the presentation created by 3dweb.io | jsv-image |
69
- | 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 |
70
- | mainHolderId | string | ID of the div where the presentation runs in. | jsv-holder |
71
- | mainImageUrl | string | URl of the first image, doesn't have to be in the document. Not needed when using imageUrls | |
72
- | totalFrames | number | Amount of frames in the presentation, more images means smoother rotations. | 72 |
73
- | imageUrls | string[] | Array of image urls, overrides totalFrames and imageUrlFormat | [] |
74
- | firstImageNumber | number | After loading the presentation this is the first frame visible. | 1 |
75
- | reverse | boolean | Invert the rotation direction when dragging. | false |
76
- | speed | number | Speed of rotating. -199 to 100 | 80 |
77
- | inertia | number | Delay when stop dragging. | 20 |
78
- | defaultProgressBar | boolean | Disable the build in progress bar, use this when you have implemented your own loader or don't like this one. | true |
79
- | defaultProgressBarColor | string | Change the color of the progress bar, can be hex of rgb. | rgb(0, 0, 0) |
80
- | defaultProgressBarBackgroundColor | string | Change the background color of the progress bar, can be hex of rgb. | rgba(255, 255, 255, 0.5) |
81
- | defaultProgressBarHeight | string | Change the height of the progress bar, can be any css value for height. | 5px |
82
- | 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} |
83
- | extraImageClass | string | Add a class to all the images used in the presentation, separate multiple classes with a space. | empty |
84
- | imageAltText | string | Add an alt text to the images, all images will have the same alt text. | empty |
85
- | startFrameNo | number | Use this setting in combination with imageUrlFormat startFrameNo: 4 => first file is ipod_04.jpg | 1 |
86
- | 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 |
87
- | autoRotateSpeed | number | Speed of autorotation. -199 to 100 | 1 |
88
- | autoRotateReverse | boolean | Use this setting for changing the direction of the auto rotating. | 1 |
89
- | enableImageEvents | boolean | Use this setting for enabling click pinch and wheel events on images. | 0 |
90
- | zoom | boolean | Use this setting for enabling zoom functions. Zoom on wheel event or pinch. | 0 |
91
- | zoomWheelSpeed | number | Change the speed of zooming with the mousewheel. | 50 |
92
- | zoomMax | number | If zoom is enabled this is the max zoom factor. | 2 |
93
- | stopAtEdges | boolean | Blocks repeating images after reaching last image. | 0 |
94
- | autoCDNResizer | boolean | Set the query params height and width for use with an image resizer. | 0 |
95
- | autoCDNResizerConfig | IAutoCDNResizerConfig | Config for adding query params to image urls. | 0 |
96
- | enableChangeImageEvent | boolean | Enable changeImage event on rotation, could be CPU heavy | 0 |
97
- | cursorConfig | ICursorConfig | Change the cursors for the presentation | |
98
- | notificationConfig | InotificationConfig | Configure the default notifications | |
99
-
100
- ## Methods
101
- - **start()**:Promise<void>
102
- Start the presentation, loading all images and replace the main image with a 360 presentation.
103
- - **destroy()**:Promise<boolean>
104
- Destroys the presentation and returns to previous state-
105
- - **setId(id: string)**:Promise<void>
106
- Destroys the presentation and creates the presentation again with the new ID. Only for presentations in 3dweb.io
107
- - **rotateDegrees(degree: number)**:Promise<IResponse>
108
- Set the desired rotation and the 360 model is rotating to it.
109
- - **rotateToDegree(targetDegree: number, shortestWay?: boolean, useEasing?: boolean))**:Promise<IResponse>
110
- Rotate to a certain degree. Frame nr 1 is 0 degrees.
111
- - **rotateToFrame(frame: number, shortestWay?: boolean, useEasing?: boolean))**:Promise<IResponse>
112
- Rotate to a certain frame.
113
- - **setSpeed(speed:number)**:void
114
- Zoom and pan in the image.
115
- - **zoomTo(factor: number, x: number, y: number)**:Promise<void>
116
- Zoom with a factor and pan in percentage from the middle -1-0 and 0-1.
117
- - **setInertia(inertia:number)**:void
118
- Set the current inertia of the viewer
119
- - **events()**:IEvents
120
- Use this to register events.-
121
- **isZoomedIn()**:boolean
122
- Checks if the presentation is zoomed.
123
-
124
- ## Events
125
- - **loadImage**:IProgress
126
- Use this event to create your own progress bar
127
- ` viewer.events().loadImage.on((progress) => {
128
- // use the progress object for your own loader
129
- }) `
130
-
131
- - **started**:boolean
132
- Use this event to trigger other actions when the viewer is ready
133
- ` viewer.events().started.on((boolean) => {
134
- // start intro animations or other creative ideas
135
- }) `
136
-
137
-
138
- - **startDragging**:IHandle
139
- Use this event to capture the user drag movement.
140
- ` viewer.events().startDragging.on((handle) => {
141
- // show or hide information on the viewer or send statistics
142
- }) `
143
-
144
- - **changeImage**:IStatus
145
- Fires when a new image becomes visible, works in combination with enableChangeImageEvent:true
146
- ` viewer.events().changeImage.on((handle) => {
147
- // show or hide information on the viewer or send statistics
148
- }) `
149
-
150
- - **endAutoRotate**:IStatus
151
- Fires when autorotate stops
152
- ` viewer.events().endAutoRotate.on((status) => {
153
- // show or hide information on the viewer or send statistics
154
- }) `
155
-
156
- - **click**:IClick
157
- Fires when the user clicks on a image, works in combination with enableImageEvents: true
158
- ` viewer.events().click.on((click) => {
159
- // Use this event for zoom functions
160
- }) `
161
-
162
- - **pinch**:IPinch
163
- Fires when the user pinch on a image (zoom on mobile with 2 fingers), works in combination with enableImageEvents: true
164
- ` viewer.events().pinch.on((click) => {
165
- // Use this event for zoom functions
166
- }) `
167
-
168
- - **scroll**:IScroll
169
- Fires when the user use the mouse scroll, works in combination with enableImageEvents: true
170
- ` viewer.events().pinch.on((click) => {
171
- // Use this event for zoom functions
172
- }) `
173
-
174
- - **doubleClick**:IClick
175
- Fires when the user double clicks on a image, works in combination with enableImageEvents: true
176
- ` viewer.events().pinch.on((click) => {
177
- // Use this event for zoom functions
178
- }) `
179
-
180
-
181
- ## Interfaces
182
- - IResponse {
183
- &ensp; currentDegree: number;
184
- }
185
- - IAutoCDNResizerConfig {
186
- &ensp; useWidth: boolean;
187
- &ensp; useHeight: boolean; //default true
188
- &ensp; scaleWithZoomMax: boolean; //default false loads images with the zoomMax factor for height or width
189
- }
190
- - notificationConfig {
191
- &ensp; dragToRotate: {
192
- &ensp;&ensp; showStartToRotateDefaultNotification: boolean,
193
- &ensp;&ensp; imageUrl: string,
194
- &ensp;&ensp; languages: ITranslation[],
195
- &ensp;&ensp; mainColor: string //hex,rgb or rgba color
196
- &ensp;&ensp; textColor: string //hex,rgb or rgba color
197
- &ensp; }
198
- }
199
-
200
- - ITranslation { [
201
- &ensp; language: string, //ISO Language Code (en-US,nl-NL)
202
- &ensp; text: string
203
- ]}
204
-
205
- - IStatus {
206
- &ensp; currentDegree: number;
207
- &ensp; currentImage: IImage;
208
- &ensp; completed: boolean;
209
- }
210
- - IImage {
211
- &ensp; id: string;
212
- &ensp; src: string;
213
- &ensp; 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
+ &ensp; currentDegree: number;
180
+ }
181
+ - IAutoCDNResizerConfig {
182
+ &ensp; useWidth: boolean;
183
+ &ensp; useHeight: boolean; //default true
184
+ &ensp; scaleWithZoomMax: boolean; //default false loads images with the zoomMax factor for height or width
185
+ }
186
+ - notificationConfig {
187
+ &ensp; dragToRotate: {
188
+ &ensp;&ensp; showStartToRotateDefaultNotification: boolean,
189
+ &ensp;&ensp; imageUrl: string,
190
+ &ensp;&ensp; languages: ITranslation[],
191
+ &ensp;&ensp; mainColor: string //hex,rgb or rgba color
192
+ &ensp;&ensp; textColor: string //hex,rgb or rgba color
193
+ &ensp; }
194
+ }
195
+
196
+ - ITranslation { [
197
+ &ensp; language: string, //ISO Language Code (en-US,nl-NL)
198
+ &ensp; text: string
199
+ ]}
200
+
201
+ - IStatus {
202
+ &ensp; currentDegree: number;
203
+ &ensp; currentImage: IImage;
204
+ &ensp; completed: boolean;
205
+ }
206
+ - IImage {
207
+ &ensp; id: string;
208
+ &ensp; src: string;
209
+ &ensp; sequence: number;
214
210
  }