@gluhar/app 4.2.1 → 4.3.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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.3.0](https://github.com/gluharco/gluhar/compare/@gluhar/app@4.2.2...@gluhar/app@4.3.0) (2025-10-06)
7
+
8
+
9
+ ### 🚀 Enhancements
10
+
11
+ - Added useLenis composable to easily enable lenis and GLenisScroller component for a nested inner scroller element ([6b5a120](https://github.com/gluharco/gluhar/commit/6b5a120afd84c2701a85e89c063b6ec234e4d96f))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.2.2](https://github.com/gluharco/gluhar/compare/@gluhar/app@4.2.1...@gluhar/app@4.2.2) (2025-09-02)
18
+
19
+
20
+ ### 🩹 Fixes
21
+
22
+ - Remove return that breaks all below ([13cc919](https://github.com/gluharco/gluhar/commit/13cc919031d677b01af3daff22a2377cf56b715f))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [4.2.1](https://github.com/gluharco/gluhar/compare/@gluhar/app@4.2.0...@gluhar/app@4.2.1) (2025-09-02)
7
29
 
8
30
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gluhar/app",
3
3
  "configKey": "gluhar",
4
- "version": "4.2.1",
4
+ "version": "4.3.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.3",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -25,9 +25,9 @@ const module = defineNuxtModule({
25
25
  if (vgsap !== false) {
26
26
  if (vgsap?.dev) {
27
27
  await installModule("@gluhar/v-gsap-nuxt", vgsap);
28
- return;
28
+ } else {
29
+ await installModule("v-gsap-nuxt", vgsap);
29
30
  }
30
- await installModule("v-gsap-nuxt", vgsap);
31
31
  }
32
32
  if (image !== false) {
33
33
  await installModule("@nuxt/image", image);
@@ -0,0 +1,35 @@
1
+ <script setup lang="ts">
2
+ import { useResizeObserver } from "@vueuse/core";
3
+ import { ref, type CSSProperties } from "vue";
4
+ import { useLenis } from "#imports";
5
+
6
+ defineProps<{
7
+ contentClass?: string;
8
+ contentStyle?: CSSProperties;
9
+ }>();
10
+
11
+ const scrollerRef = ref<HTMLDivElement>();
12
+ const contentRef = ref<HTMLDivElement>();
13
+
14
+ const { lenis } = useLenis(scrollerRef);
15
+
16
+ const prevHeight = ref(0);
17
+
18
+ useResizeObserver(contentRef, (entries) => {
19
+ const entry = entries[0];
20
+ const { height } = entry.contentRect;
21
+
22
+ if (height === prevHeight.value) return;
23
+
24
+ prevHeight.value = height;
25
+ lenis.value?.resize();
26
+ });
27
+ </script>
28
+
29
+ <template>
30
+ <div class="lenis-scroller overflow-y-auto" ref="scrollerRef">
31
+ <div :class="contentClass" :style="contentStyle" ref="contentRef">
32
+ <slot />
33
+ </div>
34
+ </div>
35
+ </template>
@@ -0,0 +1,370 @@
1
+ import Lenis from "lenis";
2
+ import { type Ref } from "vue";
3
+ interface LenisOptions {
4
+ wrapper?: HTMLElement | string;
5
+ content?: HTMLElement;
6
+ lerp?: number;
7
+ duration?: number;
8
+ orientation?: "vertical" | "horizontal";
9
+ gestureOrientation?: "vertical" | "horizontal" | "both";
10
+ smoothWheel?: boolean;
11
+ smoothTouch?: boolean;
12
+ wheelMultiplier?: number;
13
+ touchMultiplier?: number;
14
+ normalizeWheel?: boolean;
15
+ easing?: (t: number) => number;
16
+ }
17
+ export declare const useLenis: (wrapperOrOptions?: string | HTMLElement | Ref<HTMLElement | undefined> | LenisOptions) => {
18
+ lenis: Ref<{
19
+ isTouching?: boolean | undefined;
20
+ time: number;
21
+ userData: import("lenis").UserData;
22
+ lastVelocity: number;
23
+ velocity: number;
24
+ direction: 1 | -1 | 0;
25
+ options: {
26
+ wrapper: Window | HTMLElement | Element;
27
+ content: HTMLElement | Element;
28
+ eventsTarget: Window | HTMLElement | Element;
29
+ smoothWheel: boolean;
30
+ syncTouch: boolean;
31
+ syncTouchLerp: number;
32
+ touchInertiaExponent: number;
33
+ lerp: number;
34
+ infinite: boolean;
35
+ orientation: import("lenis").Orientation;
36
+ gestureOrientation: import("lenis").GestureOrientation;
37
+ touchMultiplier: number;
38
+ wheelMultiplier: number;
39
+ autoResize: boolean;
40
+ overscroll: boolean;
41
+ autoRaf: boolean;
42
+ anchors: boolean | {
43
+ offset?: number | undefined;
44
+ immediate?: boolean | undefined;
45
+ lock?: boolean | undefined;
46
+ duration?: number | undefined;
47
+ easing?: import("lenis").EasingFunction | undefined;
48
+ lerp?: number | undefined;
49
+ onStart?: ((lenis: Lenis) => void) | undefined;
50
+ onComplete?: ((lenis: Lenis) => void) | undefined;
51
+ force?: boolean | undefined;
52
+ programmatic?: boolean | undefined;
53
+ userData?: import("lenis").UserData | undefined;
54
+ };
55
+ autoToggle: boolean;
56
+ allowNestedScroll: boolean;
57
+ __experimental__naiveDimensions: boolean;
58
+ virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
59
+ duration?: number | undefined;
60
+ easing?: import("lenis").EasingFunction | undefined;
61
+ prevent?: ((node: HTMLElement) => boolean) | undefined;
62
+ };
63
+ targetScroll: number;
64
+ animatedScroll: number;
65
+ readonly dimensions: {
66
+ width: number;
67
+ height: number;
68
+ scrollHeight: number;
69
+ scrollWidth: number;
70
+ destroy: () => void;
71
+ resize: () => void;
72
+ onWrapperResize: () => void;
73
+ onContentResize: () => void;
74
+ readonly limit: {
75
+ x: number;
76
+ y: number;
77
+ };
78
+ };
79
+ destroy: () => void;
80
+ on: {
81
+ (event: "scroll", callback: import("lenis").ScrollCallback): () => void;
82
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
83
+ };
84
+ off: {
85
+ (event: "scroll", callback: import("lenis").ScrollCallback): void;
86
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
87
+ };
88
+ resize: () => void;
89
+ start: () => void;
90
+ stop: () => void;
91
+ raf: (time: number) => void;
92
+ scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
93
+ readonly rootElement: HTMLElement;
94
+ readonly limit: number;
95
+ readonly isHorizontal: boolean;
96
+ readonly actualScroll: number;
97
+ readonly scroll: number;
98
+ readonly progress: number;
99
+ isScrolling: import("lenis").Scrolling;
100
+ isStopped: boolean;
101
+ isLocked: boolean;
102
+ readonly isSmooth: boolean;
103
+ readonly className: string;
104
+ } | null, Lenis | {
105
+ isTouching?: boolean | undefined;
106
+ time: number;
107
+ userData: import("lenis").UserData;
108
+ lastVelocity: number;
109
+ velocity: number;
110
+ direction: 1 | -1 | 0;
111
+ options: {
112
+ wrapper: Window | HTMLElement | Element;
113
+ content: HTMLElement | Element;
114
+ eventsTarget: Window | HTMLElement | Element;
115
+ smoothWheel: boolean;
116
+ syncTouch: boolean;
117
+ syncTouchLerp: number;
118
+ touchInertiaExponent: number;
119
+ lerp: number;
120
+ infinite: boolean;
121
+ orientation: import("lenis").Orientation;
122
+ gestureOrientation: import("lenis").GestureOrientation;
123
+ touchMultiplier: number;
124
+ wheelMultiplier: number;
125
+ autoResize: boolean;
126
+ overscroll: boolean;
127
+ autoRaf: boolean;
128
+ anchors: boolean | {
129
+ offset?: number | undefined;
130
+ immediate?: boolean | undefined;
131
+ lock?: boolean | undefined;
132
+ duration?: number | undefined;
133
+ easing?: import("lenis").EasingFunction | undefined;
134
+ lerp?: number | undefined;
135
+ onStart?: ((lenis: Lenis) => void) | undefined;
136
+ onComplete?: ((lenis: Lenis) => void) | undefined;
137
+ force?: boolean | undefined;
138
+ programmatic?: boolean | undefined;
139
+ userData?: import("lenis").UserData | undefined;
140
+ };
141
+ autoToggle: boolean;
142
+ allowNestedScroll: boolean;
143
+ __experimental__naiveDimensions: boolean;
144
+ virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
145
+ duration?: number | undefined;
146
+ easing?: import("lenis").EasingFunction | undefined;
147
+ prevent?: ((node: HTMLElement) => boolean) | undefined;
148
+ };
149
+ targetScroll: number;
150
+ animatedScroll: number;
151
+ readonly dimensions: {
152
+ width: number;
153
+ height: number;
154
+ scrollHeight: number;
155
+ scrollWidth: number;
156
+ destroy: () => void;
157
+ resize: () => void;
158
+ onWrapperResize: () => void;
159
+ onContentResize: () => void;
160
+ readonly limit: {
161
+ x: number;
162
+ y: number;
163
+ };
164
+ };
165
+ destroy: () => void;
166
+ on: {
167
+ (event: "scroll", callback: import("lenis").ScrollCallback): () => void;
168
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
169
+ };
170
+ off: {
171
+ (event: "scroll", callback: import("lenis").ScrollCallback): void;
172
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
173
+ };
174
+ resize: () => void;
175
+ start: () => void;
176
+ stop: () => void;
177
+ raf: (time: number) => void;
178
+ scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
179
+ readonly rootElement: HTMLElement;
180
+ readonly limit: number;
181
+ readonly isHorizontal: boolean;
182
+ readonly actualScroll: number;
183
+ readonly scroll: number;
184
+ readonly progress: number;
185
+ isScrolling: import("lenis").Scrolling;
186
+ isStopped: boolean;
187
+ isLocked: boolean;
188
+ readonly isSmooth: boolean;
189
+ readonly className: string;
190
+ } | null>;
191
+ destroy: () => void;
192
+ createInstance?: undefined;
193
+ } | {
194
+ lenis: Ref<{
195
+ isTouching?: boolean | undefined;
196
+ time: number;
197
+ userData: import("lenis").UserData;
198
+ lastVelocity: number;
199
+ velocity: number;
200
+ direction: 1 | -1 | 0;
201
+ options: {
202
+ wrapper: Window | HTMLElement | Element;
203
+ content: HTMLElement | Element;
204
+ eventsTarget: Window | HTMLElement | Element;
205
+ smoothWheel: boolean;
206
+ syncTouch: boolean;
207
+ syncTouchLerp: number;
208
+ touchInertiaExponent: number;
209
+ lerp: number;
210
+ infinite: boolean;
211
+ orientation: import("lenis").Orientation;
212
+ gestureOrientation: import("lenis").GestureOrientation;
213
+ touchMultiplier: number;
214
+ wheelMultiplier: number;
215
+ autoResize: boolean;
216
+ overscroll: boolean;
217
+ autoRaf: boolean;
218
+ anchors: boolean | {
219
+ offset?: number | undefined;
220
+ immediate?: boolean | undefined;
221
+ lock?: boolean | undefined;
222
+ duration?: number | undefined;
223
+ easing?: import("lenis").EasingFunction | undefined;
224
+ lerp?: number | undefined;
225
+ onStart?: ((lenis: Lenis) => void) | undefined;
226
+ onComplete?: ((lenis: Lenis) => void) | undefined;
227
+ force?: boolean | undefined;
228
+ programmatic?: boolean | undefined;
229
+ userData?: import("lenis").UserData | undefined;
230
+ };
231
+ autoToggle: boolean;
232
+ allowNestedScroll: boolean;
233
+ __experimental__naiveDimensions: boolean;
234
+ virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
235
+ duration?: number | undefined;
236
+ easing?: import("lenis").EasingFunction | undefined;
237
+ prevent?: ((node: HTMLElement) => boolean) | undefined;
238
+ };
239
+ targetScroll: number;
240
+ animatedScroll: number;
241
+ readonly dimensions: {
242
+ width: number;
243
+ height: number;
244
+ scrollHeight: number;
245
+ scrollWidth: number;
246
+ destroy: () => void;
247
+ resize: () => void;
248
+ onWrapperResize: () => void;
249
+ onContentResize: () => void;
250
+ readonly limit: {
251
+ x: number;
252
+ y: number;
253
+ };
254
+ };
255
+ destroy: () => void;
256
+ on: {
257
+ (event: "scroll", callback: import("lenis").ScrollCallback): () => void;
258
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
259
+ };
260
+ off: {
261
+ (event: "scroll", callback: import("lenis").ScrollCallback): void;
262
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
263
+ };
264
+ resize: () => void;
265
+ start: () => void;
266
+ stop: () => void;
267
+ raf: (time: number) => void;
268
+ scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
269
+ readonly rootElement: HTMLElement;
270
+ readonly limit: number;
271
+ readonly isHorizontal: boolean;
272
+ readonly actualScroll: number;
273
+ readonly scroll: number;
274
+ readonly progress: number;
275
+ isScrolling: import("lenis").Scrolling;
276
+ isStopped: boolean;
277
+ isLocked: boolean;
278
+ readonly isSmooth: boolean;
279
+ readonly className: string;
280
+ } | null, Lenis | {
281
+ isTouching?: boolean | undefined;
282
+ time: number;
283
+ userData: import("lenis").UserData;
284
+ lastVelocity: number;
285
+ velocity: number;
286
+ direction: 1 | -1 | 0;
287
+ options: {
288
+ wrapper: Window | HTMLElement | Element;
289
+ content: HTMLElement | Element;
290
+ eventsTarget: Window | HTMLElement | Element;
291
+ smoothWheel: boolean;
292
+ syncTouch: boolean;
293
+ syncTouchLerp: number;
294
+ touchInertiaExponent: number;
295
+ lerp: number;
296
+ infinite: boolean;
297
+ orientation: import("lenis").Orientation;
298
+ gestureOrientation: import("lenis").GestureOrientation;
299
+ touchMultiplier: number;
300
+ wheelMultiplier: number;
301
+ autoResize: boolean;
302
+ overscroll: boolean;
303
+ autoRaf: boolean;
304
+ anchors: boolean | {
305
+ offset?: number | undefined;
306
+ immediate?: boolean | undefined;
307
+ lock?: boolean | undefined;
308
+ duration?: number | undefined;
309
+ easing?: import("lenis").EasingFunction | undefined;
310
+ lerp?: number | undefined;
311
+ onStart?: ((lenis: Lenis) => void) | undefined;
312
+ onComplete?: ((lenis: Lenis) => void) | undefined;
313
+ force?: boolean | undefined;
314
+ programmatic?: boolean | undefined;
315
+ userData?: import("lenis").UserData | undefined;
316
+ };
317
+ autoToggle: boolean;
318
+ allowNestedScroll: boolean;
319
+ __experimental__naiveDimensions: boolean;
320
+ virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
321
+ duration?: number | undefined;
322
+ easing?: import("lenis").EasingFunction | undefined;
323
+ prevent?: ((node: HTMLElement) => boolean) | undefined;
324
+ };
325
+ targetScroll: number;
326
+ animatedScroll: number;
327
+ readonly dimensions: {
328
+ width: number;
329
+ height: number;
330
+ scrollHeight: number;
331
+ scrollWidth: number;
332
+ destroy: () => void;
333
+ resize: () => void;
334
+ onWrapperResize: () => void;
335
+ onContentResize: () => void;
336
+ readonly limit: {
337
+ x: number;
338
+ y: number;
339
+ };
340
+ };
341
+ destroy: () => void;
342
+ on: {
343
+ (event: "scroll", callback: import("lenis").ScrollCallback): () => void;
344
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
345
+ };
346
+ off: {
347
+ (event: "scroll", callback: import("lenis").ScrollCallback): void;
348
+ (event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
349
+ };
350
+ resize: () => void;
351
+ start: () => void;
352
+ stop: () => void;
353
+ raf: (time: number) => void;
354
+ scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
355
+ readonly rootElement: HTMLElement;
356
+ readonly limit: number;
357
+ readonly isHorizontal: boolean;
358
+ readonly actualScroll: number;
359
+ readonly scroll: number;
360
+ readonly progress: number;
361
+ isScrolling: import("lenis").Scrolling;
362
+ isStopped: boolean;
363
+ isLocked: boolean;
364
+ readonly isSmooth: boolean;
365
+ readonly className: string;
366
+ } | null>;
367
+ createInstance: (customOptions?: LenisOptions) => Lenis | null;
368
+ destroy: () => void;
369
+ };
370
+ export {};
@@ -0,0 +1,101 @@
1
+ import Lenis from "lenis";
2
+ import { ScrollTrigger } from "gsap/ScrollTrigger";
3
+ import { computed, onMounted, onUnmounted, isRef, ref } from "vue";
4
+ import { useClientOnly, useGSAP, watch } from "#imports";
5
+ const globalLenis = ref(null);
6
+ const globalDestroy = () => {
7
+ if (globalLenis.value) {
8
+ globalLenis.value.destroy();
9
+ globalLenis.value = null;
10
+ }
11
+ };
12
+ export const useLenis = (wrapperOrOptions) => {
13
+ const { isClient } = useClientOnly();
14
+ const gsap = useGSAP();
15
+ if (!wrapperOrOptions) {
16
+ return {
17
+ lenis: globalLenis,
18
+ destroy: globalDestroy
19
+ };
20
+ }
21
+ const lenis = ref(null);
22
+ const options = computed(() => {
23
+ if (!isClient.value) return {};
24
+ if (typeof wrapperOrOptions === "string" || wrapperOrOptions instanceof HTMLElement) {
25
+ return { wrapper: wrapperOrOptions };
26
+ }
27
+ if (isRef(wrapperOrOptions)) {
28
+ return { wrapper: wrapperOrOptions.value };
29
+ }
30
+ return wrapperOrOptions || {};
31
+ });
32
+ const initLenis = (customOptions = {}) => {
33
+ if (!isClient.value) return null;
34
+ const currentOptions = options.value;
35
+ if (currentOptions.wrapper === void 0) {
36
+ return null;
37
+ }
38
+ const lenisOptions = {
39
+ wrapper: window,
40
+ // Default to window/body instead of #scroller
41
+ ...currentOptions,
42
+ ...customOptions
43
+ };
44
+ let wrapper = lenisOptions.wrapper;
45
+ if (typeof wrapper === "string") {
46
+ wrapper = document.querySelector(wrapper) || window;
47
+ }
48
+ const lenisInstance = new Lenis({
49
+ ...lenisOptions,
50
+ wrapper
51
+ });
52
+ lenisInstance.on("scroll", ScrollTrigger.update);
53
+ gsap.ticker.add((time) => {
54
+ lenisInstance.raf(time * 1e3);
55
+ });
56
+ gsap.ticker.lagSmoothing(0);
57
+ return lenisInstance;
58
+ };
59
+ const createInstance = (customOptions = {}) => {
60
+ const instance = initLenis(customOptions);
61
+ if (!lenis.value) {
62
+ lenis.value = instance;
63
+ }
64
+ return instance;
65
+ };
66
+ const destroy = () => {
67
+ if (lenis.value) {
68
+ lenis.value.destroy();
69
+ lenis.value = null;
70
+ }
71
+ };
72
+ watch(
73
+ () => options.value.wrapper,
74
+ (newWrapper) => {
75
+ if (newWrapper && !lenis.value) {
76
+ lenis.value = initLenis();
77
+ if (newWrapper === "#scroller" || typeof newWrapper === "object" && newWrapper?.id === "scroller") {
78
+ globalLenis.value = lenis.value;
79
+ }
80
+ }
81
+ },
82
+ { immediate: true }
83
+ );
84
+ onMounted(() => {
85
+ if (!lenis.value) {
86
+ lenis.value = initLenis();
87
+ const currentWrapper = options.value.wrapper;
88
+ if (currentWrapper === "#scroller" || typeof currentWrapper === "object" && currentWrapper?.id === "scroller") {
89
+ globalLenis.value = lenis.value;
90
+ }
91
+ }
92
+ });
93
+ onUnmounted(() => {
94
+ destroy();
95
+ });
96
+ return {
97
+ lenis,
98
+ createInstance,
99
+ destroy
100
+ };
101
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gluhar/app",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "Gluhar main package. This combines and configures @gluhar/theme, @gluhar/i18n, @gluhar/sanity and @gluhar/core into one main package. Provides numerous components, composables, utils and types.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,6 +48,7 @@
48
48
  "@sanity/image-url": "^1.1.0",
49
49
  "dayjs-nuxt": "^2.1.11",
50
50
  "defu": "^6.1.4",
51
+ "lenis": "^1.3.11",
51
52
  "pinia": "^2.2.2",
52
53
  "v-gsap-nuxt": "^1.4.2"
53
54
  },
@@ -63,5 +64,5 @@
63
64
  "nuxt": "^3.13.1",
64
65
  "vitest": "^2.0.5"
65
66
  },
66
- "gitHead": "0ce5211ad166a7731e3e20f771d6adf4d47fb38b"
67
+ "gitHead": "12d17bee9d86790a8f21e2788c5d4b3c8df6ef5c"
67
68
  }