@levita-js/vue 0.1.1
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/LICENSE +21 -0
- package/dist/index.cjs +123 -0
- package/dist/index.d.cts +165 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +165 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +123 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jérôme André
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let levita_js = require("levita-js");
|
|
3
|
+
let vue = require("vue");
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Vue 3 wrapper for the Levita 3D tilt effect.
|
|
8
|
+
*
|
|
9
|
+
* Accepts all `LevitaOptions` as props. The Levita instance is created
|
|
10
|
+
* on mount and destroyed on unmount. Changing any tilt prop recreates
|
|
11
|
+
* the instance.
|
|
12
|
+
*
|
|
13
|
+
* Exposes `element`, `instance`, and `requestPermission()` via template ref.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```vue
|
|
17
|
+
* <script setup>
|
|
18
|
+
* import { Tilt } from '@levita-js/vue';
|
|
19
|
+
* import 'levita-js/style.css';
|
|
20
|
+
* <\/script>
|
|
21
|
+
*
|
|
22
|
+
* <template>
|
|
23
|
+
* <Tilt :glare="true" :shadow="true" :max="20">
|
|
24
|
+
* <h1>Hello</h1>
|
|
25
|
+
* </Tilt>
|
|
26
|
+
* </template>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const Tilt = (0, vue.defineComponent)({
|
|
30
|
+
name: "Tilt",
|
|
31
|
+
props: {
|
|
32
|
+
max: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: void 0
|
|
35
|
+
},
|
|
36
|
+
perspective: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: void 0
|
|
39
|
+
},
|
|
40
|
+
scale: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: void 0
|
|
43
|
+
},
|
|
44
|
+
speed: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: void 0
|
|
47
|
+
},
|
|
48
|
+
easing: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: void 0
|
|
51
|
+
},
|
|
52
|
+
reverse: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: void 0
|
|
55
|
+
},
|
|
56
|
+
axis: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: void 0
|
|
59
|
+
},
|
|
60
|
+
reset: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: void 0
|
|
63
|
+
},
|
|
64
|
+
glare: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: void 0
|
|
67
|
+
},
|
|
68
|
+
maxGlare: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: void 0
|
|
71
|
+
},
|
|
72
|
+
shadow: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: void 0
|
|
75
|
+
},
|
|
76
|
+
gyroscope: {
|
|
77
|
+
type: [String, Boolean],
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
disabled: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: void 0
|
|
83
|
+
},
|
|
84
|
+
eventsEl: {
|
|
85
|
+
type: Object,
|
|
86
|
+
default: void 0
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
slots: Object,
|
|
90
|
+
setup(props, { slots, expose }) {
|
|
91
|
+
const elRef = (0, vue.ref)(null);
|
|
92
|
+
let instance = null;
|
|
93
|
+
/** Create a fresh Levita instance on the container element. */
|
|
94
|
+
const init = () => {
|
|
95
|
+
if (!elRef.value) return;
|
|
96
|
+
instance?.destroy();
|
|
97
|
+
instance = new levita_js.Levita(elRef.value, (0, levita_js.buildOptions)(props));
|
|
98
|
+
};
|
|
99
|
+
/** Request accelerometer permission (must be called from a user gesture on iOS). */
|
|
100
|
+
const requestPermission = async () => {
|
|
101
|
+
return await instance?.requestPermission() ?? false;
|
|
102
|
+
};
|
|
103
|
+
expose({
|
|
104
|
+
get element() {
|
|
105
|
+
return elRef.value;
|
|
106
|
+
},
|
|
107
|
+
get instance() {
|
|
108
|
+
return instance;
|
|
109
|
+
},
|
|
110
|
+
requestPermission
|
|
111
|
+
});
|
|
112
|
+
(0, vue.onMounted)(init);
|
|
113
|
+
(0, vue.onUnmounted)(() => {
|
|
114
|
+
instance?.destroy();
|
|
115
|
+
instance = null;
|
|
116
|
+
});
|
|
117
|
+
(0, vue.watch)(() => levita_js.OPTION_KEYS.map((k) => props[k]), () => init());
|
|
118
|
+
return () => (0, vue.h)("div", { ref: elRef }, slots.default?.({}));
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
exports.Tilt = Tilt;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as vue from "vue";
|
|
2
|
+
import { PropType, SlotsType } from "vue";
|
|
3
|
+
import { Axis, GyroscopeMode } from "levita-js";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Vue 3 wrapper for the Levita 3D tilt effect.
|
|
8
|
+
*
|
|
9
|
+
* Accepts all `LevitaOptions` as props. The Levita instance is created
|
|
10
|
+
* on mount and destroyed on unmount. Changing any tilt prop recreates
|
|
11
|
+
* the instance.
|
|
12
|
+
*
|
|
13
|
+
* Exposes `element`, `instance`, and `requestPermission()` via template ref.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```vue
|
|
17
|
+
* <script setup>
|
|
18
|
+
* import { Tilt } from '@levita-js/vue';
|
|
19
|
+
* import 'levita-js/style.css';
|
|
20
|
+
* </script>
|
|
21
|
+
*
|
|
22
|
+
* <template>
|
|
23
|
+
* <Tilt :glare="true" :shadow="true" :max="20">
|
|
24
|
+
* <h1>Hello</h1>
|
|
25
|
+
* </Tilt>
|
|
26
|
+
* </template>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare const Tilt: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
30
|
+
max: {
|
|
31
|
+
type: NumberConstructor;
|
|
32
|
+
default: undefined;
|
|
33
|
+
};
|
|
34
|
+
perspective: {
|
|
35
|
+
type: NumberConstructor;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
scale: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
speed: {
|
|
43
|
+
type: NumberConstructor;
|
|
44
|
+
default: undefined;
|
|
45
|
+
};
|
|
46
|
+
easing: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: undefined;
|
|
49
|
+
};
|
|
50
|
+
reverse: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
54
|
+
axis: {
|
|
55
|
+
type: PropType<Axis>;
|
|
56
|
+
default: undefined;
|
|
57
|
+
};
|
|
58
|
+
reset: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
default: undefined;
|
|
61
|
+
};
|
|
62
|
+
glare: {
|
|
63
|
+
type: BooleanConstructor;
|
|
64
|
+
default: undefined;
|
|
65
|
+
};
|
|
66
|
+
maxGlare: {
|
|
67
|
+
type: NumberConstructor;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
shadow: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
74
|
+
gyroscope: {
|
|
75
|
+
type: PropType<GyroscopeMode>;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
disabled: {
|
|
79
|
+
type: BooleanConstructor;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
eventsEl: {
|
|
83
|
+
type: PropType<HTMLElement | null>;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
89
|
+
max: {
|
|
90
|
+
type: NumberConstructor;
|
|
91
|
+
default: undefined;
|
|
92
|
+
};
|
|
93
|
+
perspective: {
|
|
94
|
+
type: NumberConstructor;
|
|
95
|
+
default: undefined;
|
|
96
|
+
};
|
|
97
|
+
scale: {
|
|
98
|
+
type: NumberConstructor;
|
|
99
|
+
default: undefined;
|
|
100
|
+
};
|
|
101
|
+
speed: {
|
|
102
|
+
type: NumberConstructor;
|
|
103
|
+
default: undefined;
|
|
104
|
+
};
|
|
105
|
+
easing: {
|
|
106
|
+
type: StringConstructor;
|
|
107
|
+
default: undefined;
|
|
108
|
+
};
|
|
109
|
+
reverse: {
|
|
110
|
+
type: BooleanConstructor;
|
|
111
|
+
default: undefined;
|
|
112
|
+
};
|
|
113
|
+
axis: {
|
|
114
|
+
type: PropType<Axis>;
|
|
115
|
+
default: undefined;
|
|
116
|
+
};
|
|
117
|
+
reset: {
|
|
118
|
+
type: BooleanConstructor;
|
|
119
|
+
default: undefined;
|
|
120
|
+
};
|
|
121
|
+
glare: {
|
|
122
|
+
type: BooleanConstructor;
|
|
123
|
+
default: undefined;
|
|
124
|
+
};
|
|
125
|
+
maxGlare: {
|
|
126
|
+
type: NumberConstructor;
|
|
127
|
+
default: undefined;
|
|
128
|
+
};
|
|
129
|
+
shadow: {
|
|
130
|
+
type: BooleanConstructor;
|
|
131
|
+
default: undefined;
|
|
132
|
+
};
|
|
133
|
+
gyroscope: {
|
|
134
|
+
type: PropType<GyroscopeMode>;
|
|
135
|
+
default: undefined;
|
|
136
|
+
};
|
|
137
|
+
disabled: {
|
|
138
|
+
type: BooleanConstructor;
|
|
139
|
+
default: undefined;
|
|
140
|
+
};
|
|
141
|
+
eventsEl: {
|
|
142
|
+
type: PropType<HTMLElement | null>;
|
|
143
|
+
default: undefined;
|
|
144
|
+
};
|
|
145
|
+
}>> & Readonly<{}>, {
|
|
146
|
+
max: number;
|
|
147
|
+
perspective: number;
|
|
148
|
+
scale: number;
|
|
149
|
+
speed: number;
|
|
150
|
+
easing: string;
|
|
151
|
+
reverse: boolean;
|
|
152
|
+
axis: Axis;
|
|
153
|
+
reset: boolean;
|
|
154
|
+
glare: boolean;
|
|
155
|
+
maxGlare: number;
|
|
156
|
+
shadow: boolean;
|
|
157
|
+
gyroscope: GyroscopeMode;
|
|
158
|
+
disabled: boolean;
|
|
159
|
+
eventsEl: HTMLElement | null;
|
|
160
|
+
}, SlotsType<{
|
|
161
|
+
default: Record<string, never>;
|
|
162
|
+
}>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
163
|
+
//#endregion
|
|
164
|
+
export { Tilt };
|
|
165
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;cAAa,IAAA,MAAI,eAAA,CAoBqB,GAAA,CApBrB,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;UAUS,QAAA,CAAS,IAAA;;;;;;;;;;;;;;;;;;;;UAML,QAAA,CAAS,aAAA;;;;;;;;UAIT,QAAA,CAAS,WAAA;;;oBApBtB,GAAA,CAAA,YAAA;;4GAoBqB,GAAA,CAAA,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;UAVZ,QAAA,CAAS,IAAA;;;;;;;;;;;;;;;;;;;;UAML,QAAA,CAAS,aAAA;;;;;;;;UAIT,QAAA,CAAS,WAAA;;;;;;;;;;;;;;;;;;;WAGA,MAAA;AAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Axis, GyroscopeMode } from "levita-js";
|
|
2
|
+
import * as vue from "vue";
|
|
3
|
+
import { PropType, SlotsType } from "vue";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Vue 3 wrapper for the Levita 3D tilt effect.
|
|
8
|
+
*
|
|
9
|
+
* Accepts all `LevitaOptions` as props. The Levita instance is created
|
|
10
|
+
* on mount and destroyed on unmount. Changing any tilt prop recreates
|
|
11
|
+
* the instance.
|
|
12
|
+
*
|
|
13
|
+
* Exposes `element`, `instance`, and `requestPermission()` via template ref.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```vue
|
|
17
|
+
* <script setup>
|
|
18
|
+
* import { Tilt } from '@levita-js/vue';
|
|
19
|
+
* import 'levita-js/style.css';
|
|
20
|
+
* </script>
|
|
21
|
+
*
|
|
22
|
+
* <template>
|
|
23
|
+
* <Tilt :glare="true" :shadow="true" :max="20">
|
|
24
|
+
* <h1>Hello</h1>
|
|
25
|
+
* </Tilt>
|
|
26
|
+
* </template>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare const Tilt: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
30
|
+
max: {
|
|
31
|
+
type: NumberConstructor;
|
|
32
|
+
default: undefined;
|
|
33
|
+
};
|
|
34
|
+
perspective: {
|
|
35
|
+
type: NumberConstructor;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
scale: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
speed: {
|
|
43
|
+
type: NumberConstructor;
|
|
44
|
+
default: undefined;
|
|
45
|
+
};
|
|
46
|
+
easing: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: undefined;
|
|
49
|
+
};
|
|
50
|
+
reverse: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
54
|
+
axis: {
|
|
55
|
+
type: PropType<Axis>;
|
|
56
|
+
default: undefined;
|
|
57
|
+
};
|
|
58
|
+
reset: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
default: undefined;
|
|
61
|
+
};
|
|
62
|
+
glare: {
|
|
63
|
+
type: BooleanConstructor;
|
|
64
|
+
default: undefined;
|
|
65
|
+
};
|
|
66
|
+
maxGlare: {
|
|
67
|
+
type: NumberConstructor;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
shadow: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
74
|
+
gyroscope: {
|
|
75
|
+
type: PropType<GyroscopeMode>;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
disabled: {
|
|
79
|
+
type: BooleanConstructor;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
eventsEl: {
|
|
83
|
+
type: PropType<HTMLElement | null>;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
89
|
+
max: {
|
|
90
|
+
type: NumberConstructor;
|
|
91
|
+
default: undefined;
|
|
92
|
+
};
|
|
93
|
+
perspective: {
|
|
94
|
+
type: NumberConstructor;
|
|
95
|
+
default: undefined;
|
|
96
|
+
};
|
|
97
|
+
scale: {
|
|
98
|
+
type: NumberConstructor;
|
|
99
|
+
default: undefined;
|
|
100
|
+
};
|
|
101
|
+
speed: {
|
|
102
|
+
type: NumberConstructor;
|
|
103
|
+
default: undefined;
|
|
104
|
+
};
|
|
105
|
+
easing: {
|
|
106
|
+
type: StringConstructor;
|
|
107
|
+
default: undefined;
|
|
108
|
+
};
|
|
109
|
+
reverse: {
|
|
110
|
+
type: BooleanConstructor;
|
|
111
|
+
default: undefined;
|
|
112
|
+
};
|
|
113
|
+
axis: {
|
|
114
|
+
type: PropType<Axis>;
|
|
115
|
+
default: undefined;
|
|
116
|
+
};
|
|
117
|
+
reset: {
|
|
118
|
+
type: BooleanConstructor;
|
|
119
|
+
default: undefined;
|
|
120
|
+
};
|
|
121
|
+
glare: {
|
|
122
|
+
type: BooleanConstructor;
|
|
123
|
+
default: undefined;
|
|
124
|
+
};
|
|
125
|
+
maxGlare: {
|
|
126
|
+
type: NumberConstructor;
|
|
127
|
+
default: undefined;
|
|
128
|
+
};
|
|
129
|
+
shadow: {
|
|
130
|
+
type: BooleanConstructor;
|
|
131
|
+
default: undefined;
|
|
132
|
+
};
|
|
133
|
+
gyroscope: {
|
|
134
|
+
type: PropType<GyroscopeMode>;
|
|
135
|
+
default: undefined;
|
|
136
|
+
};
|
|
137
|
+
disabled: {
|
|
138
|
+
type: BooleanConstructor;
|
|
139
|
+
default: undefined;
|
|
140
|
+
};
|
|
141
|
+
eventsEl: {
|
|
142
|
+
type: PropType<HTMLElement | null>;
|
|
143
|
+
default: undefined;
|
|
144
|
+
};
|
|
145
|
+
}>> & Readonly<{}>, {
|
|
146
|
+
max: number;
|
|
147
|
+
perspective: number;
|
|
148
|
+
scale: number;
|
|
149
|
+
speed: number;
|
|
150
|
+
easing: string;
|
|
151
|
+
reverse: boolean;
|
|
152
|
+
axis: Axis;
|
|
153
|
+
reset: boolean;
|
|
154
|
+
glare: boolean;
|
|
155
|
+
maxGlare: number;
|
|
156
|
+
shadow: boolean;
|
|
157
|
+
gyroscope: GyroscopeMode;
|
|
158
|
+
disabled: boolean;
|
|
159
|
+
eventsEl: HTMLElement | null;
|
|
160
|
+
}, SlotsType<{
|
|
161
|
+
default: Record<string, never>;
|
|
162
|
+
}>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
163
|
+
//#endregion
|
|
164
|
+
export { Tilt };
|
|
165
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;cAAa,IAAA,MAAI,eAAA,CAoBqB,GAAA,CApBrB,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;UAUS,QAAA,CAAS,IAAA;;;;;;;;;;;;;;;;;;;;UAML,QAAA,CAAS,aAAA;;;;;;;;UAIT,QAAA,CAAS,WAAA;;;oBApBtB,GAAA,CAAA,YAAA;;4GAoBqB,GAAA,CAAA,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;UAVZ,QAAA,CAAS,IAAA;;;;;;;;;;;;;;;;;;;;UAML,QAAA,CAAS,aAAA;;;;;;;;UAIT,QAAA,CAAS,WAAA;;;;;;;;;;;;;;;;;;;WAGA,MAAA;AAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Levita, OPTION_KEYS, buildOptions } from "levita-js";
|
|
2
|
+
import { defineComponent, h, onMounted, onUnmounted, ref, watch } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vue 3 wrapper for the Levita 3D tilt effect.
|
|
7
|
+
*
|
|
8
|
+
* Accepts all `LevitaOptions` as props. The Levita instance is created
|
|
9
|
+
* on mount and destroyed on unmount. Changing any tilt prop recreates
|
|
10
|
+
* the instance.
|
|
11
|
+
*
|
|
12
|
+
* Exposes `element`, `instance`, and `requestPermission()` via template ref.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```vue
|
|
16
|
+
* <script setup>
|
|
17
|
+
* import { Tilt } from '@levita-js/vue';
|
|
18
|
+
* import 'levita-js/style.css';
|
|
19
|
+
* <\/script>
|
|
20
|
+
*
|
|
21
|
+
* <template>
|
|
22
|
+
* <Tilt :glare="true" :shadow="true" :max="20">
|
|
23
|
+
* <h1>Hello</h1>
|
|
24
|
+
* </Tilt>
|
|
25
|
+
* </template>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const Tilt = defineComponent({
|
|
29
|
+
name: "Tilt",
|
|
30
|
+
props: {
|
|
31
|
+
max: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: void 0
|
|
34
|
+
},
|
|
35
|
+
perspective: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: void 0
|
|
38
|
+
},
|
|
39
|
+
scale: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
speed: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
easing: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
reverse: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: void 0
|
|
54
|
+
},
|
|
55
|
+
axis: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: void 0
|
|
58
|
+
},
|
|
59
|
+
reset: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: void 0
|
|
62
|
+
},
|
|
63
|
+
glare: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: void 0
|
|
66
|
+
},
|
|
67
|
+
maxGlare: {
|
|
68
|
+
type: Number,
|
|
69
|
+
default: void 0
|
|
70
|
+
},
|
|
71
|
+
shadow: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: void 0
|
|
74
|
+
},
|
|
75
|
+
gyroscope: {
|
|
76
|
+
type: [String, Boolean],
|
|
77
|
+
default: void 0
|
|
78
|
+
},
|
|
79
|
+
disabled: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: void 0
|
|
82
|
+
},
|
|
83
|
+
eventsEl: {
|
|
84
|
+
type: Object,
|
|
85
|
+
default: void 0
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
slots: Object,
|
|
89
|
+
setup(props, { slots, expose }) {
|
|
90
|
+
const elRef = ref(null);
|
|
91
|
+
let instance = null;
|
|
92
|
+
/** Create a fresh Levita instance on the container element. */
|
|
93
|
+
const init = () => {
|
|
94
|
+
if (!elRef.value) return;
|
|
95
|
+
instance?.destroy();
|
|
96
|
+
instance = new Levita(elRef.value, buildOptions(props));
|
|
97
|
+
};
|
|
98
|
+
/** Request accelerometer permission (must be called from a user gesture on iOS). */
|
|
99
|
+
const requestPermission = async () => {
|
|
100
|
+
return await instance?.requestPermission() ?? false;
|
|
101
|
+
};
|
|
102
|
+
expose({
|
|
103
|
+
get element() {
|
|
104
|
+
return elRef.value;
|
|
105
|
+
},
|
|
106
|
+
get instance() {
|
|
107
|
+
return instance;
|
|
108
|
+
},
|
|
109
|
+
requestPermission
|
|
110
|
+
});
|
|
111
|
+
onMounted(init);
|
|
112
|
+
onUnmounted(() => {
|
|
113
|
+
instance?.destroy();
|
|
114
|
+
instance = null;
|
|
115
|
+
});
|
|
116
|
+
watch(() => OPTION_KEYS.map((k) => props[k]), () => init());
|
|
117
|
+
return () => h("div", { ref: elRef }, slots.default?.({}));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
export { Tilt };
|
|
123
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Axis, GyroscopeMode } from \"levita-js\";\nimport { buildOptions, Levita, OPTION_KEYS } from \"levita-js\";\nimport {\n\tdefineComponent,\n\th,\n\tonMounted,\n\tonUnmounted,\n\ttype PropType,\n\tref,\n\ttype SlotsType,\n\twatch,\n} from \"vue\";\n\n/**\n * Vue 3 wrapper for the Levita 3D tilt effect.\n *\n * Accepts all `LevitaOptions` as props. The Levita instance is created\n * on mount and destroyed on unmount. Changing any tilt prop recreates\n * the instance.\n *\n * Exposes `element`, `instance`, and `requestPermission()` via template ref.\n *\n * @example\n * ```vue\n * <script setup>\n * import { Tilt } from '@levita-js/vue';\n * import 'levita-js/style.css';\n * </script>\n *\n * <template>\n * <Tilt :glare=\"true\" :shadow=\"true\" :max=\"20\">\n * <h1>Hello</h1>\n * </Tilt>\n * </template>\n * ```\n */\nexport const Tilt = defineComponent({\n\tname: \"Tilt\",\n\n\tprops: {\n\t\tmax: { type: Number, default: undefined },\n\t\tperspective: { type: Number, default: undefined },\n\t\tscale: { type: Number, default: undefined },\n\t\tspeed: { type: Number, default: undefined },\n\t\teasing: { type: String, default: undefined },\n\t\treverse: { type: Boolean, default: undefined },\n\t\taxis: { type: String as PropType<Axis>, default: undefined },\n\t\treset: { type: Boolean, default: undefined },\n\t\tglare: { type: Boolean, default: undefined },\n\t\tmaxGlare: { type: Number, default: undefined },\n\t\tshadow: { type: Boolean, default: undefined },\n\t\tgyroscope: {\n\t\t\ttype: [String, Boolean] as PropType<GyroscopeMode>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tdisabled: { type: Boolean, default: undefined },\n\t\teventsEl: { type: Object as PropType<HTMLElement | null>, default: undefined },\n\t},\n\n\tslots: Object as SlotsType<{ default: Record<string, never> }>,\n\n\tsetup(props, { slots, expose }) {\n\t\tconst elRef = ref<HTMLElement | null>(null);\n\t\tlet instance: Levita | null = null;\n\n\t\t/** Create a fresh Levita instance on the container element. */\n\t\tconst init = () => {\n\t\t\tif (!elRef.value) return;\n\t\t\tinstance?.destroy();\n\t\t\tinstance = new Levita(elRef.value, buildOptions(props));\n\t\t};\n\n\t\t/** Request accelerometer permission (must be called from a user gesture on iOS). */\n\t\tconst requestPermission = async (): Promise<boolean> => {\n\t\t\treturn (await instance?.requestPermission()) ?? false;\n\t\t};\n\n\t\texpose({\n\t\t\t/** The underlying DOM element. */\n\t\t\tget element() {\n\t\t\t\treturn elRef.value;\n\t\t\t},\n\t\t\t/** The Levita instance driving the tilt effect. */\n\t\t\tget instance() {\n\t\t\t\treturn instance;\n\t\t\t},\n\t\t\trequestPermission,\n\t\t});\n\n\t\tonMounted(init);\n\n\t\tonUnmounted(() => {\n\t\t\tinstance?.destroy();\n\t\t\tinstance = null;\n\t\t});\n\n\t\twatch(\n\t\t\t() => OPTION_KEYS.map((k) => props[k]),\n\t\t\t() => init(),\n\t\t);\n\n\t\treturn () => h(\"div\", { ref: elRef }, slots.default?.({}));\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,OAAO,gBAAgB;CACnC,MAAM;CAEN,OAAO;EACN,KAAK;GAAE,MAAM;GAAQ,SAAS;GAAW;EACzC,aAAa;GAAE,MAAM;GAAQ,SAAS;GAAW;EACjD,OAAO;GAAE,MAAM;GAAQ,SAAS;GAAW;EAC3C,OAAO;GAAE,MAAM;GAAQ,SAAS;GAAW;EAC3C,QAAQ;GAAE,MAAM;GAAQ,SAAS;GAAW;EAC5C,SAAS;GAAE,MAAM;GAAS,SAAS;GAAW;EAC9C,MAAM;GAAE,MAAM;GAA0B,SAAS;GAAW;EAC5D,OAAO;GAAE,MAAM;GAAS,SAAS;GAAW;EAC5C,OAAO;GAAE,MAAM;GAAS,SAAS;GAAW;EAC5C,UAAU;GAAE,MAAM;GAAQ,SAAS;GAAW;EAC9C,QAAQ;GAAE,MAAM;GAAS,SAAS;GAAW;EAC7C,WAAW;GACV,MAAM,CAAC,QAAQ,QAAQ;GACvB,SAAS;GACT;EACD,UAAU;GAAE,MAAM;GAAS,SAAS;GAAW;EAC/C,UAAU;GAAE,MAAM;GAAwC,SAAS;GAAW;EAC9E;CAED,OAAO;CAEP,MAAM,OAAO,EAAE,OAAO,UAAU;EAC/B,MAAM,QAAQ,IAAwB,KAAK;EAC3C,IAAI,WAA0B;;EAG9B,MAAM,aAAa;AAClB,OAAI,CAAC,MAAM,MAAO;AAClB,aAAU,SAAS;AACnB,cAAW,IAAI,OAAO,MAAM,OAAO,aAAa,MAAM,CAAC;;;EAIxD,MAAM,oBAAoB,YAA8B;AACvD,UAAQ,MAAM,UAAU,mBAAmB,IAAK;;AAGjD,SAAO;GAEN,IAAI,UAAU;AACb,WAAO,MAAM;;GAGd,IAAI,WAAW;AACd,WAAO;;GAER;GACA,CAAC;AAEF,YAAU,KAAK;AAEf,oBAAkB;AACjB,aAAU,SAAS;AACnB,cAAW;IACV;AAEF,cACO,YAAY,KAAK,MAAM,MAAM,GAAG,QAChC,MAAM,CACZ;AAED,eAAa,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,EAAE,CAAC,CAAC;;CAE3D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@levita-js/vue",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Vue wrapper for Levita 3D tilt & parallax",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vue": ">=3.3"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"levita-js": "0.1.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@vue/test-utils": "^2.4.6",
|
|
33
|
+
"tsdown": "^0.20.3",
|
|
34
|
+
"vue": "^3.5.0"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/jeromearsene/levita.git",
|
|
40
|
+
"directory": "packages/vue"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/jeromearsene/levita#readme",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsdown"
|
|
45
|
+
}
|
|
46
|
+
}
|