@uibit/360-viewer 0.1.1 → 0.2.0
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/README.md +1 -1
- package/dist/frameworks/angular/index.ts +54 -44
- package/dist/frameworks/astro/index.d.ts +9 -1
- package/dist/frameworks/preact/index.d.ts +2 -0
- package/dist/frameworks/react/index.ts +127 -0
- package/dist/frameworks/solid/index.d.ts +1 -1
- package/dist/frameworks/stencil/index.d.ts +2 -0
- package/dist/frameworks/svelte/index.svelte +61 -23
- package/dist/frameworks/vue/index.ts +121 -25
- package/package.json +6 -3
- package/dist/frameworks/react/index.d.ts +0 -23
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@uibit/360-viewer)
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
[Interactive Demonstration](https://rawlings.github.io/uibit/viewer
|
|
6
|
+
[Interactive Demonstration](https://rawlings.github.io/uibit/components/360-viewer)
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -1,56 +1,66 @@
|
|
|
1
1
|
import { Component, ChangeDetectionStrategy, ElementRef, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
|
|
2
2
|
import '@uibit/360-viewer';
|
|
3
3
|
import type { Viewer360 as HTMLElementClass } from '@uibit/360-viewer';
|
|
4
|
-
|
|
5
4
|
@Component({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
selector: 'uibit-360-viewer',
|
|
6
|
+
template: '<ng-content></ng-content>',
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
standalone: true,
|
|
9
|
+
host: {
|
|
10
|
+
'(change)': 'change.emit($event)'
|
|
11
|
+
}
|
|
13
12
|
})
|
|
14
13
|
export class NgxViewer360 {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
constructor(private el: ElementRef<HTMLElementClass>){
|
|
15
|
+
effect(()=>{
|
|
16
|
+
if (this.el.nativeElement) {
|
|
17
|
+
this.el.nativeElement.autoRotate = this.autoRotate();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
effect(()=>{
|
|
21
|
+
if (this.el.nativeElement) {
|
|
22
|
+
this.el.nativeElement.rotationSpeed = this.rotationSpeed();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
effect(()=>{
|
|
26
|
+
if (this.el.nativeElement) {
|
|
27
|
+
this.el.nativeElement.dragSensitivity = this.dragSensitivity();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
effect(()=>{
|
|
31
|
+
if (this.el.nativeElement) {
|
|
32
|
+
this.el.nativeElement.showControls = this.showControls();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
effect(()=>{
|
|
36
|
+
if (this.el.nativeElement) {
|
|
37
|
+
this.el.nativeElement.showProgressBar = this.showProgressBar();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
effect(()=>{
|
|
41
|
+
if (this.el.nativeElement) {
|
|
42
|
+
this.el.nativeElement.locale = this.locale();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
readonly autoRotate = input<boolean, any>(false, {
|
|
47
|
+
transform: booleanAttribute
|
|
20
48
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.el.nativeElement.rotationSpeed = this.rotationSpeed();
|
|
24
|
-
}
|
|
49
|
+
readonly rotationSpeed = input<number, any>(150, {
|
|
50
|
+
transform: numberAttribute
|
|
25
51
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.el.nativeElement.dragSensitivity = this.dragSensitivity();
|
|
29
|
-
}
|
|
52
|
+
readonly dragSensitivity = input<number, any>(15, {
|
|
53
|
+
transform: numberAttribute
|
|
30
54
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.el.nativeElement.showControls = this.showControls();
|
|
34
|
-
}
|
|
55
|
+
readonly showControls = input<boolean, any>(true, {
|
|
56
|
+
transform: booleanAttribute
|
|
35
57
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.el.nativeElement.showProgressBar = this.showProgressBar();
|
|
39
|
-
}
|
|
58
|
+
readonly showProgressBar = input<boolean, any>(true, {
|
|
59
|
+
transform: booleanAttribute
|
|
40
60
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
readonly autoRotate = input<boolean, any>(false, { transform: booleanAttribute });
|
|
49
|
-
readonly rotationSpeed = input<number, any>(150, { transform: numberAttribute });
|
|
50
|
-
readonly dragSensitivity = input<number, any>(15, { transform: numberAttribute });
|
|
51
|
-
readonly showControls = input<boolean, any>(true, { transform: booleanAttribute });
|
|
52
|
-
readonly showProgressBar = input<boolean, any>(true, { transform: booleanAttribute });
|
|
53
|
-
readonly locale = input<string, any>('');
|
|
54
|
-
|
|
55
|
-
readonly change = output<CustomEvent<{ index: number, total: number }>>();
|
|
61
|
+
readonly locale = input<string>('');
|
|
62
|
+
readonly change = output<CustomEvent<{
|
|
63
|
+
index: number;
|
|
64
|
+
total: number;
|
|
65
|
+
}>>();
|
|
56
66
|
}
|
|
@@ -4,7 +4,15 @@ import '@uibit/360-viewer';
|
|
|
4
4
|
declare global {
|
|
5
5
|
namespace astroHTML.JSX {
|
|
6
6
|
interface IntrinsicElements {
|
|
7
|
-
'uibit-360-viewer': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes
|
|
7
|
+
'uibit-360-viewer': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
|
|
8
|
+
autoRotate?: boolean;
|
|
9
|
+
rotationSpeed?: number;
|
|
10
|
+
dragSensitivity?: number;
|
|
11
|
+
showControls?: boolean;
|
|
12
|
+
showProgressBar?: boolean;
|
|
13
|
+
locale?: string;
|
|
14
|
+
"on:change"?: (event: CustomEvent<{ index: number, total: number }>) => void;
|
|
15
|
+
};
|
|
8
16
|
}
|
|
9
17
|
}
|
|
10
18
|
}
|
|
@@ -12,6 +12,8 @@ declare module 'preact' {
|
|
|
12
12
|
showControls?: boolean;
|
|
13
13
|
showProgressBar?: boolean;
|
|
14
14
|
locale?: string;
|
|
15
|
+
onChange?: (event: CustomEvent<{ index: number, total: number }>) => void;
|
|
16
|
+
"on:change"?: (event: CustomEvent<{ index: number, total: number }>) => void;
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
2
|
+
import type { Viewer360 as HTMLElementClass } from '@uibit/360-viewer';
|
|
3
|
+
import '@uibit/360-viewer';
|
|
4
|
+
const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
5
|
+
export interface Viewer360Props extends Omit<React.HTMLAttributes<HTMLElementClass>, 'autoRotate' | 'rotationSpeed' | 'dragSensitivity' | 'showControls' | 'showProgressBar' | 'locale' | 'onChange'> {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
autoRotate?: boolean;
|
|
8
|
+
rotationSpeed?: number;
|
|
9
|
+
dragSensitivity?: number;
|
|
10
|
+
showControls?: boolean;
|
|
11
|
+
showProgressBar?: boolean;
|
|
12
|
+
locale?: string;
|
|
13
|
+
onChange?: (event: CustomEvent<{
|
|
14
|
+
index: number;
|
|
15
|
+
total: number;
|
|
16
|
+
}>) => void;
|
|
17
|
+
}
|
|
18
|
+
export const Viewer360 = ({ ref, children, ...props }: Viewer360Props & {
|
|
19
|
+
ref?: React.Ref<HTMLElementClass>;
|
|
20
|
+
})=>{
|
|
21
|
+
const innerRef = useRef<HTMLElementClass>(null);
|
|
22
|
+
const propsRef = useRef(props);
|
|
23
|
+
propsRef.current = props;
|
|
24
|
+
useImperativeHandle(ref, ()=>innerRef.current!);
|
|
25
|
+
useTypeOfLayoutEffect(()=>{
|
|
26
|
+
const element = innerRef.current;
|
|
27
|
+
if (element && props.autoRotate !== undefined) {
|
|
28
|
+
(element as any).autoRotate = props.autoRotate;
|
|
29
|
+
}
|
|
30
|
+
}, [
|
|
31
|
+
props.autoRotate
|
|
32
|
+
]);
|
|
33
|
+
useTypeOfLayoutEffect(()=>{
|
|
34
|
+
const element = innerRef.current;
|
|
35
|
+
if (element && props.rotationSpeed !== undefined) {
|
|
36
|
+
(element as any).rotationSpeed = props.rotationSpeed;
|
|
37
|
+
}
|
|
38
|
+
}, [
|
|
39
|
+
props.rotationSpeed
|
|
40
|
+
]);
|
|
41
|
+
useTypeOfLayoutEffect(()=>{
|
|
42
|
+
const element = innerRef.current;
|
|
43
|
+
if (element && props.dragSensitivity !== undefined) {
|
|
44
|
+
(element as any).dragSensitivity = props.dragSensitivity;
|
|
45
|
+
}
|
|
46
|
+
}, [
|
|
47
|
+
props.dragSensitivity
|
|
48
|
+
]);
|
|
49
|
+
useTypeOfLayoutEffect(()=>{
|
|
50
|
+
const element = innerRef.current;
|
|
51
|
+
if (element && props.showControls !== undefined) {
|
|
52
|
+
(element as any).showControls = props.showControls;
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
props.showControls
|
|
56
|
+
]);
|
|
57
|
+
useTypeOfLayoutEffect(()=>{
|
|
58
|
+
const element = innerRef.current;
|
|
59
|
+
if (element && props.showProgressBar !== undefined) {
|
|
60
|
+
(element as any).showProgressBar = props.showProgressBar;
|
|
61
|
+
}
|
|
62
|
+
}, [
|
|
63
|
+
props.showProgressBar
|
|
64
|
+
]);
|
|
65
|
+
useTypeOfLayoutEffect(()=>{
|
|
66
|
+
const element = innerRef.current;
|
|
67
|
+
if (element && props.locale !== undefined) {
|
|
68
|
+
(element as any).locale = props.locale;
|
|
69
|
+
}
|
|
70
|
+
}, [
|
|
71
|
+
props.locale
|
|
72
|
+
]);
|
|
73
|
+
useTypeOfLayoutEffect(()=>{
|
|
74
|
+
const element = innerRef.current;
|
|
75
|
+
if (!element) return;
|
|
76
|
+
const handleEvent = (event: Event)=>{
|
|
77
|
+
if (propsRef.current.onChange) {
|
|
78
|
+
propsRef.current.onChange(event as any);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
element.addEventListener('change', handleEvent);
|
|
82
|
+
return ()=>{
|
|
83
|
+
element.removeEventListener('change', handleEvent);
|
|
84
|
+
};
|
|
85
|
+
}, []);
|
|
86
|
+
const domProps = {
|
|
87
|
+
...props
|
|
88
|
+
};
|
|
89
|
+
const customPropNames = [
|
|
90
|
+
'autoRotate',
|
|
91
|
+
'rotationSpeed',
|
|
92
|
+
'dragSensitivity',
|
|
93
|
+
'showControls',
|
|
94
|
+
'showProgressBar',
|
|
95
|
+
'locale',
|
|
96
|
+
'onChange'
|
|
97
|
+
];
|
|
98
|
+
for (const key of customPropNames){
|
|
99
|
+
delete (domProps as any)[key];
|
|
100
|
+
}
|
|
101
|
+
return React.createElement('uibit-360-viewer', {
|
|
102
|
+
ref: innerRef,
|
|
103
|
+
...domProps
|
|
104
|
+
}, children);
|
|
105
|
+
};
|
|
106
|
+
declare global {
|
|
107
|
+
namespace React {
|
|
108
|
+
namespace JSX {
|
|
109
|
+
interface IntrinsicElements {
|
|
110
|
+
'uibit-360-viewer': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
|
|
111
|
+
children?: React.ReactNode;
|
|
112
|
+
class?: string;
|
|
113
|
+
autoRotate?: boolean;
|
|
114
|
+
rotationSpeed?: number;
|
|
115
|
+
dragSensitivity?: number;
|
|
116
|
+
showControls?: boolean;
|
|
117
|
+
showProgressBar?: boolean;
|
|
118
|
+
locale?: string;
|
|
119
|
+
onChange?: (event: CustomEvent<{
|
|
120
|
+
index: number;
|
|
121
|
+
total: number;
|
|
122
|
+
}>) => void;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -11,6 +11,8 @@ declare module '@stencil/core' {
|
|
|
11
11
|
showControls?: boolean;
|
|
12
12
|
showProgressBar?: boolean;
|
|
13
13
|
locale?: string;
|
|
14
|
+
onChange?: (event: CustomEvent<{ index: number, total: number }>) => void;
|
|
15
|
+
"on:change"?: (event: CustomEvent<{ index: number, total: number }>) => void;
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -1,52 +1,90 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import '@uibit/360-viewer';
|
|
3
3
|
import type { Viewer360 as HTMLElementClass } from '@uibit/360-viewer';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
autoRotate =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
autoRotate = $bindable(),
|
|
7
|
+
rotationSpeed = $bindable(),
|
|
8
|
+
dragSensitivity = $bindable(),
|
|
9
|
+
showControls = $bindable(),
|
|
10
|
+
showProgressBar = $bindable(),
|
|
11
|
+
locale = $bindable(),
|
|
12
|
+
children,
|
|
13
|
+
...restProps
|
|
13
14
|
} = $props<{
|
|
14
|
-
children?:
|
|
15
|
+
children?: import('svelte').Snippet;
|
|
15
16
|
autoRotate?: boolean;
|
|
16
17
|
rotationSpeed?: number;
|
|
17
18
|
dragSensitivity?: number;
|
|
18
19
|
showControls?: boolean;
|
|
19
20
|
showProgressBar?: boolean;
|
|
20
21
|
locale?: string;
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
[key: string]: any;
|
|
22
24
|
}>();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (elementRef && autoRotate !== undefined) {
|
|
25
|
+
|
|
26
|
+
let elementRef: HTMLElementClass | null = $state(null);
|
|
27
|
+
|
|
28
|
+
$effect(() => {
|
|
29
|
+
if (elementRef && autoRotate !== undefined && elementRef.autoRotate !== autoRotate) {
|
|
28
30
|
elementRef.autoRotate = autoRotate;
|
|
29
31
|
}
|
|
30
|
-
if (elementRef && rotationSpeed !== undefined) {
|
|
32
|
+
if (elementRef && rotationSpeed !== undefined && elementRef.rotationSpeed !== rotationSpeed) {
|
|
31
33
|
elementRef.rotationSpeed = rotationSpeed;
|
|
32
34
|
}
|
|
33
|
-
if (elementRef && dragSensitivity !== undefined) {
|
|
35
|
+
if (elementRef && dragSensitivity !== undefined && elementRef.dragSensitivity !== dragSensitivity) {
|
|
34
36
|
elementRef.dragSensitivity = dragSensitivity;
|
|
35
37
|
}
|
|
36
|
-
if (elementRef && showControls !== undefined) {
|
|
38
|
+
if (elementRef && showControls !== undefined && elementRef.showControls !== showControls) {
|
|
37
39
|
elementRef.showControls = showControls;
|
|
38
40
|
}
|
|
39
|
-
if (elementRef && showProgressBar !== undefined) {
|
|
41
|
+
if (elementRef && showProgressBar !== undefined && elementRef.showProgressBar !== showProgressBar) {
|
|
40
42
|
elementRef.showProgressBar = showProgressBar;
|
|
41
43
|
}
|
|
42
|
-
if (elementRef && locale !== undefined) {
|
|
44
|
+
if (elementRef && locale !== undefined && elementRef.locale !== locale) {
|
|
43
45
|
elementRef.locale = locale;
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
|
-
|
|
48
|
+
|
|
49
|
+
$effect(() => {
|
|
50
|
+
const element = elementRef;
|
|
51
|
+
if (!element) return;
|
|
52
|
+
|
|
53
|
+
const handleEvent = () => {
|
|
54
|
+
if (autoRotate !== element.autoRotate) {
|
|
55
|
+
autoRotate = element.autoRotate as any;
|
|
56
|
+
}
|
|
57
|
+
if (rotationSpeed !== element.rotationSpeed) {
|
|
58
|
+
rotationSpeed = element.rotationSpeed as any;
|
|
59
|
+
}
|
|
60
|
+
if (dragSensitivity !== element.dragSensitivity) {
|
|
61
|
+
dragSensitivity = element.dragSensitivity as any;
|
|
62
|
+
}
|
|
63
|
+
if (showControls !== element.showControls) {
|
|
64
|
+
showControls = element.showControls as any;
|
|
65
|
+
}
|
|
66
|
+
if (showProgressBar !== element.showProgressBar) {
|
|
67
|
+
showProgressBar = element.showProgressBar as any;
|
|
68
|
+
}
|
|
69
|
+
if (locale !== element.locale) {
|
|
70
|
+
locale = element.locale as any;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const events = ['change', 'input'];
|
|
75
|
+
for (const event of events) {
|
|
76
|
+
element.addEventListener(event, handleEvent);
|
|
77
|
+
}
|
|
78
|
+
return () => {
|
|
79
|
+
for (const event of events) {
|
|
80
|
+
element.removeEventListener(event, handleEvent);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
|
|
47
85
|
</script>
|
|
48
86
|
|
|
49
|
-
<uibit-360-viewer bind:this={elementRef} {
|
|
87
|
+
<uibit-360-viewer bind:this={elementRef} {...restProps}>
|
|
50
88
|
|
|
51
89
|
{#if children}
|
|
52
90
|
{@render children()}
|
|
@@ -1,29 +1,125 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue';
|
|
1
|
+
import { defineComponent, h, ref, watch } from 'vue';
|
|
2
2
|
import type { Viewer360 as HTMLElementClass } from '@uibit/360-viewer';
|
|
3
3
|
import '@uibit/360-viewer';
|
|
4
|
-
|
|
5
4
|
export const Viewer360 = defineComponent({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
name: 'Viewer360',
|
|
6
|
+
props: {
|
|
7
|
+
autoRotate: {
|
|
8
|
+
type: [
|
|
9
|
+
String,
|
|
10
|
+
Number,
|
|
11
|
+
Boolean,
|
|
12
|
+
Array,
|
|
13
|
+
Object
|
|
14
|
+
] as any
|
|
15
|
+
},
|
|
16
|
+
rotationSpeed: {
|
|
17
|
+
type: [
|
|
18
|
+
String,
|
|
19
|
+
Number,
|
|
20
|
+
Boolean,
|
|
21
|
+
Array,
|
|
22
|
+
Object
|
|
23
|
+
] as any
|
|
24
|
+
},
|
|
25
|
+
dragSensitivity: {
|
|
26
|
+
type: [
|
|
27
|
+
String,
|
|
28
|
+
Number,
|
|
29
|
+
Boolean,
|
|
30
|
+
Array,
|
|
31
|
+
Object
|
|
32
|
+
] as any
|
|
33
|
+
},
|
|
34
|
+
showControls: {
|
|
35
|
+
type: [
|
|
36
|
+
String,
|
|
37
|
+
Number,
|
|
38
|
+
Boolean,
|
|
39
|
+
Array,
|
|
40
|
+
Object
|
|
41
|
+
] as any
|
|
42
|
+
},
|
|
43
|
+
showProgressBar: {
|
|
44
|
+
type: [
|
|
45
|
+
String,
|
|
46
|
+
Number,
|
|
47
|
+
Boolean,
|
|
48
|
+
Array,
|
|
49
|
+
Object
|
|
50
|
+
] as any
|
|
51
|
+
},
|
|
52
|
+
locale: {
|
|
53
|
+
type: [
|
|
54
|
+
String,
|
|
55
|
+
Number,
|
|
56
|
+
Boolean,
|
|
57
|
+
Array,
|
|
58
|
+
Object
|
|
59
|
+
] as any
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
emits: [
|
|
63
|
+
'change'
|
|
64
|
+
],
|
|
65
|
+
setup (props, { slots, emit }) {
|
|
66
|
+
const elementRef = ref<HTMLElementClass | null>(null);
|
|
67
|
+
if (false) {
|
|
68
|
+
watch(()=>props.modelValue, (newVal)=>{
|
|
69
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
70
|
+
elementRef.value.value = newVal;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
watch(()=>props.value, (newVal)=>{
|
|
74
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
75
|
+
elementRef.value.value = newVal;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
watch(()=>props.autoRotate, (newVal)=>{
|
|
80
|
+
if (elementRef.value && newVal !== undefined) {
|
|
81
|
+
(elementRef.value as any).autoRotate = newVal;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
watch(()=>props.rotationSpeed, (newVal)=>{
|
|
85
|
+
if (elementRef.value && newVal !== undefined) {
|
|
86
|
+
(elementRef.value as any).rotationSpeed = newVal;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
watch(()=>props.dragSensitivity, (newVal)=>{
|
|
90
|
+
if (elementRef.value && newVal !== undefined) {
|
|
91
|
+
(elementRef.value as any).dragSensitivity = newVal;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
watch(()=>props.showControls, (newVal)=>{
|
|
95
|
+
if (elementRef.value && newVal !== undefined) {
|
|
96
|
+
(elementRef.value as any).showControls = newVal;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
watch(()=>props.showProgressBar, (newVal)=>{
|
|
100
|
+
if (elementRef.value && newVal !== undefined) {
|
|
101
|
+
(elementRef.value as any).showProgressBar = newVal;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
watch(()=>props.locale, (newVal)=>{
|
|
105
|
+
if (elementRef.value && newVal !== undefined) {
|
|
106
|
+
(elementRef.value as any).locale = newVal;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return ()=>{
|
|
110
|
+
const eventListeners: Record<string, any> = {};
|
|
111
|
+
eventListeners['onChange'] = (event: Event)=>{
|
|
112
|
+
emit('change', event);
|
|
113
|
+
};
|
|
114
|
+
const mergedProps = {
|
|
115
|
+
...props,
|
|
116
|
+
...eventListeners,
|
|
117
|
+
ref: elementRef
|
|
118
|
+
};
|
|
119
|
+
if (false && props.modelValue !== undefined) {
|
|
120
|
+
(mergedProps as any).value = props.modelValue;
|
|
121
|
+
}
|
|
122
|
+
return h('uibit-360-viewer', mergedProps, slots.default?.());
|
|
123
|
+
};
|
|
124
|
+
}
|
|
29
125
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibit/360-viewer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Interactive 360-degree image viewer component. Display products and objects from every angle with smooth mouse/touch dragging, auto-rotation, and preloading.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"./360-viewer.css": "./dist/360-viewer.css",
|
|
14
14
|
"./custom-elements.json": "./custom-elements.json",
|
|
15
|
-
"./react":
|
|
15
|
+
"./react": {
|
|
16
|
+
"types": "./dist/frameworks/react/index.ts",
|
|
17
|
+
"import": "./dist/frameworks/react/index.ts"
|
|
18
|
+
},
|
|
16
19
|
"./vue": "./dist/frameworks/vue/index.ts",
|
|
17
20
|
"./svelte": "./dist/frameworks/svelte/index.svelte",
|
|
18
21
|
"./angular": "./dist/frameworks/angular/index.ts",
|
|
@@ -52,7 +55,7 @@
|
|
|
52
55
|
"@types/node": "^20.19.43",
|
|
53
56
|
"lit": "^3.3.3",
|
|
54
57
|
"typescript": "7.0.2",
|
|
55
|
-
"@uibit/codegen": "0.
|
|
58
|
+
"@uibit/codegen": "0.2.0"
|
|
56
59
|
},
|
|
57
60
|
"peerDependencies": {
|
|
58
61
|
"lit": "^3.0.0",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes, ClassAttributes } from 'react';
|
|
2
|
-
import type { Viewer360 as HTMLElementClass } from '@uibit/360-viewer';
|
|
3
|
-
import '@uibit/360-viewer';
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
namespace React {
|
|
7
|
-
namespace JSX {
|
|
8
|
-
interface IntrinsicElements {
|
|
9
|
-
'uibit-360-viewer': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
class?: string;
|
|
12
|
-
autoRotate?: boolean;
|
|
13
|
-
rotationSpeed?: number;
|
|
14
|
-
dragSensitivity?: number;
|
|
15
|
-
showControls?: boolean;
|
|
16
|
-
showProgressBar?: boolean;
|
|
17
|
-
locale?: string;
|
|
18
|
-
onChange?: (event: any) => void;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|