vevet 5.2.0 → 5.2.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/lib/cdn/vevet.iife.min.js +29 -29
- package/lib/cjs/base/Callbacks/index.js +6 -3
- package/lib/cjs/base/Callbacks/index.js.map +1 -1
- package/lib/cjs/base/Module/index.js +12 -10
- package/lib/cjs/base/Module/index.js.map +1 -1
- package/lib/cjs/components/Canvas/index.js +2 -2
- package/lib/cjs/components/Canvas/index.js.map +1 -1
- package/lib/cjs/components/CanvasMedia/index.js +2 -2
- package/lib/cjs/components/CanvasMedia/index.js.map +1 -1
- package/lib/cjs/components/Cursor/index.js +2 -2
- package/lib/cjs/components/Cursor/index.js.map +1 -1
- package/lib/cjs/components/InView/index.js +2 -2
- package/lib/cjs/components/InView/index.js.map +1 -1
- package/lib/cjs/components/Marquee/index.js +2 -2
- package/lib/cjs/components/Marquee/index.js.map +1 -1
- package/lib/cjs/components/Pointers/index.js +2 -2
- package/lib/cjs/components/Pointers/index.js.map +1 -1
- package/lib/cjs/components/Preloader/index.js +2 -2
- package/lib/cjs/components/Preloader/index.js.map +1 -1
- package/lib/cjs/components/ProgressPreloader/index.js +2 -2
- package/lib/cjs/components/ProgressPreloader/index.js.map +1 -1
- package/lib/cjs/components/Raf/index.js +2 -2
- package/lib/cjs/components/Raf/index.js.map +1 -1
- package/lib/cjs/components/ScrollProgress/index.js +2 -2
- package/lib/cjs/components/ScrollProgress/index.js.map +1 -1
- package/lib/cjs/components/Scrollbar/index.js +2 -2
- package/lib/cjs/components/Scrollbar/index.js.map +1 -1
- package/lib/cjs/components/Snap/index.js +2 -2
- package/lib/cjs/components/Snap/index.js.map +1 -1
- package/lib/cjs/components/SplitText/index.js +2 -2
- package/lib/cjs/components/SplitText/index.js.map +1 -1
- package/lib/cjs/components/Swipe/index.js +5 -5
- package/lib/cjs/components/Swipe/index.js.map +1 -1
- package/lib/cjs/components/Timeline/index.js +2 -2
- package/lib/cjs/components/Timeline/index.js.map +1 -1
- package/lib/cjs/manifest.json +1 -1
- package/lib/esm/base/Callbacks/index.js +5 -3
- package/lib/esm/base/Callbacks/index.js.map +1 -1
- package/lib/esm/base/Module/index.js +10 -8
- package/lib/esm/base/Module/index.js.map +1 -1
- package/lib/esm/components/Canvas/index.js +2 -2
- package/lib/esm/components/Canvas/index.js.map +1 -1
- package/lib/esm/components/CanvasMedia/index.js +2 -2
- package/lib/esm/components/CanvasMedia/index.js.map +1 -1
- package/lib/esm/components/Cursor/index.js +2 -2
- package/lib/esm/components/Cursor/index.js.map +1 -1
- package/lib/esm/components/InView/index.js +2 -2
- package/lib/esm/components/InView/index.js.map +1 -1
- package/lib/esm/components/Marquee/index.js +2 -2
- package/lib/esm/components/Marquee/index.js.map +1 -1
- package/lib/esm/components/Pointers/index.js +2 -2
- package/lib/esm/components/Pointers/index.js.map +1 -1
- package/lib/esm/components/Preloader/index.js +2 -2
- package/lib/esm/components/Preloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/index.js +2 -2
- package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
- package/lib/esm/components/Raf/index.js +2 -2
- package/lib/esm/components/Raf/index.js.map +1 -1
- package/lib/esm/components/ScrollProgress/index.js +2 -2
- package/lib/esm/components/ScrollProgress/index.js.map +1 -1
- package/lib/esm/components/Scrollbar/index.js +2 -2
- package/lib/esm/components/Scrollbar/index.js.map +1 -1
- package/lib/esm/components/Snap/index.js +2 -2
- package/lib/esm/components/Snap/index.js.map +1 -1
- package/lib/esm/components/SplitText/index.js +2 -2
- package/lib/esm/components/SplitText/index.js.map +1 -1
- package/lib/esm/components/Swipe/index.js +5 -5
- package/lib/esm/components/Swipe/index.js.map +1 -1
- package/lib/esm/components/Timeline/index.js +2 -2
- package/lib/esm/components/Timeline/index.js.map +1 -1
- package/lib/esm/manifest.json +1 -1
- package/lib/types/base/Callbacks/index.d.ts +7 -5
- package/lib/types/base/Callbacks/index.d.ts.map +1 -1
- package/lib/types/base/Callbacks/types.d.ts +9 -5
- package/lib/types/base/Callbacks/types.d.ts.map +1 -1
- package/lib/types/base/Module/index.d.ts +5 -5
- package/lib/types/base/Module/index.d.ts.map +1 -1
- package/lib/types/base/Module/types.d.ts +3 -3
- package/lib/types/base/Module/types.d.ts.map +1 -1
- package/lib/types/base/Responsive/types.d.ts +2 -2
- package/lib/types/base/Responsive/types.d.ts.map +1 -1
- package/lib/types/components/Canvas/index.d.ts +5 -5
- package/lib/types/components/Canvas/index.d.ts.map +1 -1
- package/lib/types/components/CanvasMedia/index.d.ts +5 -5
- package/lib/types/components/CanvasMedia/index.d.ts.map +1 -1
- package/lib/types/components/Cursor/index.d.ts +5 -5
- package/lib/types/components/Cursor/index.d.ts.map +1 -1
- package/lib/types/components/InView/index.d.ts +5 -5
- package/lib/types/components/InView/index.d.ts.map +1 -1
- package/lib/types/components/InView/types.d.ts.map +1 -1
- package/lib/types/components/Marquee/index.d.ts +5 -5
- package/lib/types/components/Marquee/index.d.ts.map +1 -1
- package/lib/types/components/Pointers/index.d.ts +5 -5
- package/lib/types/components/Pointers/index.d.ts.map +1 -1
- package/lib/types/components/Preloader/index.d.ts +5 -5
- package/lib/types/components/Preloader/index.d.ts.map +1 -1
- package/lib/types/components/ProgressPreloader/index.d.ts +5 -5
- package/lib/types/components/ProgressPreloader/index.d.ts.map +1 -1
- package/lib/types/components/Raf/index.d.ts +5 -5
- package/lib/types/components/Raf/index.d.ts.map +1 -1
- package/lib/types/components/ScrollProgress/index.d.ts +5 -5
- package/lib/types/components/ScrollProgress/index.d.ts.map +1 -1
- package/lib/types/components/Scrollbar/index.d.ts +5 -5
- package/lib/types/components/Scrollbar/index.d.ts.map +1 -1
- package/lib/types/components/Snap/index.d.ts +5 -5
- package/lib/types/components/Snap/index.d.ts.map +1 -1
- package/lib/types/components/SplitText/index.d.ts +5 -5
- package/lib/types/components/SplitText/index.d.ts.map +1 -1
- package/lib/types/components/Swipe/index.d.ts +5 -5
- package/lib/types/components/Swipe/index.d.ts.map +1 -1
- package/lib/types/components/Swipe/types.d.ts +5 -0
- package/lib/types/components/Swipe/types.d.ts.map +1 -1
- package/lib/types/components/Timeline/index.d.ts +5 -5
- package/lib/types/components/Timeline/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/base/Callbacks/index.ts +15 -7
- package/src/base/Callbacks/types.ts +12 -7
- package/src/base/Module/index.ts +24 -15
- package/src/base/Module/types.ts +3 -3
- package/src/base/Responsive/types.ts +4 -5
- package/src/components/Canvas/index.ts +12 -11
- package/src/components/CanvasMedia/index.ts +12 -11
- package/src/components/Cursor/index.ts +12 -11
- package/src/components/InView/index.ts +12 -11
- package/src/components/InView/types.ts +2 -6
- package/src/components/Marquee/index.ts +12 -11
- package/src/components/Pointers/index.ts +12 -11
- package/src/components/Preloader/index.ts +12 -11
- package/src/components/ProgressPreloader/index.ts +12 -14
- package/src/components/Raf/index.ts +14 -13
- package/src/components/ScrollProgress/index.ts +12 -13
- package/src/components/Scrollbar/index.ts +12 -11
- package/src/components/Snap/index.ts +12 -11
- package/src/components/SplitText/index.ts +12 -11
- package/src/components/Swipe/index.ts +15 -13
- package/src/components/Swipe/types.ts +6 -0
- package/src/components/Timeline/index.ts +12 -11
- package/src/manifest.json +1 -1
package/src/base/Module/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
IModuleCallbacksMap,
|
|
5
5
|
IModuleMutableProps,
|
|
6
6
|
IModuleStaticProps,
|
|
7
|
+
TModuleOnCallbacksProps,
|
|
7
8
|
} from './types';
|
|
8
9
|
import { mergeWithNoUndefined } from '@/internal/mergeWithNoUndefined';
|
|
9
10
|
import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
|
|
@@ -65,7 +66,7 @@ export class Module<
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/** Callbacks instance */
|
|
68
|
-
protected _callbacks: Callbacks<CallbacksMap>;
|
|
69
|
+
protected _callbacks: Callbacks<CallbacksMap, this>;
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
* Retrieves the module's callbacks instance.
|
|
@@ -80,8 +81,14 @@ export class Module<
|
|
|
80
81
|
/**
|
|
81
82
|
* Creates a new instance of the Module class.
|
|
82
83
|
*/
|
|
83
|
-
constructor(
|
|
84
|
-
|
|
84
|
+
constructor(
|
|
85
|
+
props?: StaticProps & MutableProps,
|
|
86
|
+
onCallbacks?: TModuleOnCallbacksProps<
|
|
87
|
+
CallbacksMap,
|
|
88
|
+
Module<CallbacksMap, StaticProps, MutableProps>
|
|
89
|
+
>,
|
|
90
|
+
) {
|
|
91
|
+
this._callbacks = new Callbacks({ ctx: this });
|
|
85
92
|
|
|
86
93
|
this._props = mergeWithNoUndefined(
|
|
87
94
|
{
|
|
@@ -93,18 +100,20 @@ export class Module<
|
|
|
93
100
|
|
|
94
101
|
// Initialize callbacks
|
|
95
102
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
callbacksProps.forEach((key) => {
|
|
101
|
-
let target = key.slice(2);
|
|
102
|
-
target = target.charAt(0).toLowerCase() + target.slice(1);
|
|
103
|
-
this._callbacks.on(
|
|
104
|
-
target as keyof CallbacksMap,
|
|
105
|
-
this._props[key as keyof typeof props],
|
|
103
|
+
if (onCallbacks) {
|
|
104
|
+
const callbacksProps = Object.keys(onCallbacks).filter((key) =>
|
|
105
|
+
key.startsWith('on'),
|
|
106
106
|
);
|
|
107
|
-
|
|
107
|
+
|
|
108
|
+
callbacksProps.forEach((key) => {
|
|
109
|
+
let target = key.slice(2);
|
|
110
|
+
target = target.charAt(0).toLowerCase() + target.slice(1);
|
|
111
|
+
this._callbacks.on(
|
|
112
|
+
target as keyof CallbacksMap,
|
|
113
|
+
onCallbacks[key as keyof typeof props],
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
/**
|
|
@@ -150,7 +159,7 @@ export class Module<
|
|
|
150
159
|
@noopIfDestroyed
|
|
151
160
|
public on<T extends keyof CallbacksMap>(
|
|
152
161
|
target: T,
|
|
153
|
-
listener: TCallbacksAction<CallbacksMap[T]>,
|
|
162
|
+
listener: TCallbacksAction<CallbacksMap[T], this>,
|
|
154
163
|
settings: ICallbacksSettings = {},
|
|
155
164
|
) {
|
|
156
165
|
return this.callbacks.on(target, listener, settings);
|
package/src/base/Module/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICallbacksMap } from '../Callbacks';
|
|
1
|
+
import { ICallbacksMap, TCallbacksAction } from '../Callbacks';
|
|
2
2
|
|
|
3
3
|
export interface IModuleStaticProps {
|
|
4
4
|
__staticProp?: null;
|
|
@@ -20,6 +20,6 @@ export interface IModuleCallbacksMap extends ICallbacksMap {
|
|
|
20
20
|
props: undefined;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export type
|
|
24
|
-
[K in keyof T as `on${Capitalize<string & K>}`]:
|
|
23
|
+
export type TModuleOnCallbacksProps<T, Ctx> = Partial<{
|
|
24
|
+
[K in keyof T as `on${Capitalize<string & K>}`]: TCallbacksAction<T[K], Ctx>;
|
|
25
25
|
}>;
|
|
@@ -2,8 +2,8 @@ import { Module } from '../Module';
|
|
|
2
2
|
|
|
3
3
|
export type TResponsiveSource = Record<string, any> | Module;
|
|
4
4
|
|
|
5
|
-
export type TResponsivePick<T> =
|
|
6
|
-
T extends
|
|
5
|
+
export type TResponsivePick<T extends TResponsiveSource> =
|
|
6
|
+
T['_getMutable'] extends Function
|
|
7
7
|
? Partial<ReturnType<T['_getMutable']>>
|
|
8
8
|
: Partial<T>;
|
|
9
9
|
|
|
@@ -24,6 +24,5 @@ export type TResponsiveRule<T extends TResponsiveSource> = {
|
|
|
24
24
|
props: TResponsivePick<T>;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export type TResponsiveProps<T extends TResponsiveSource> =
|
|
28
|
-
? T['props']
|
|
29
|
-
: T;
|
|
27
|
+
export type TResponsiveProps<T extends TResponsiveSource> =
|
|
28
|
+
T['_getMutable'] extends Function ? T['props'] : T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TRequiredProps } from '@/internal/requiredProps';
|
|
2
2
|
import { onResize } from '@/utils/listeners/onResize';
|
|
3
|
-
import { Module,
|
|
3
|
+
import { Module, TModuleOnCallbacksProps } from '@/base/Module';
|
|
4
4
|
import {
|
|
5
5
|
ICanvasCallbacksMap,
|
|
6
6
|
ICanvasMutableProps,
|
|
@@ -22,12 +22,12 @@ export * from './types';
|
|
|
22
22
|
* @group Components
|
|
23
23
|
*/
|
|
24
24
|
export class Canvas<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
> extends Module<
|
|
25
|
+
C extends ICanvasCallbacksMap = ICanvasCallbacksMap,
|
|
26
|
+
S extends ICanvasStaticProps = ICanvasStaticProps,
|
|
27
|
+
M extends ICanvasMutableProps = ICanvasMutableProps,
|
|
28
|
+
> extends Module<C, S, M> {
|
|
29
29
|
/** Get default static properties */
|
|
30
|
-
public _getStatic(): TRequiredProps<
|
|
30
|
+
public _getStatic(): TRequiredProps<S> {
|
|
31
31
|
return {
|
|
32
32
|
...super._getStatic(),
|
|
33
33
|
container: null,
|
|
@@ -36,17 +36,17 @@ export class Canvas<
|
|
|
36
36
|
resizeOnRuntime: false,
|
|
37
37
|
viewportTarget: 'any',
|
|
38
38
|
resizeDebounce: 0,
|
|
39
|
-
} as TRequiredProps<
|
|
39
|
+
} as TRequiredProps<S>;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/** Get default mutable properties */
|
|
43
|
-
public _getMutable(): TRequiredProps<
|
|
43
|
+
public _getMutable(): TRequiredProps<M> {
|
|
44
44
|
return {
|
|
45
45
|
...super._getMutable(),
|
|
46
46
|
width: 'auto',
|
|
47
47
|
height: 'auto',
|
|
48
48
|
dpr: 'auto',
|
|
49
|
-
} as TRequiredProps<
|
|
49
|
+
} as TRequiredProps<M>;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** The canvas element created for rendering */
|
|
@@ -108,9 +108,10 @@ export class Canvas<
|
|
|
108
108
|
* Constructor for the Ctx2D class.
|
|
109
109
|
*/
|
|
110
110
|
constructor(
|
|
111
|
-
props?:
|
|
111
|
+
props?: S & M,
|
|
112
|
+
onCallbacks?: TModuleOnCallbacksProps<C, Canvas<C, S, M>>,
|
|
112
113
|
) {
|
|
113
|
-
super(props);
|
|
114
|
+
super(props, onCallbacks as any);
|
|
114
115
|
|
|
115
116
|
const {
|
|
116
117
|
append: shouldAppend,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { Canvas, ICanvasRenderArg } from '../Canvas';
|
|
9
9
|
import { addEventListener } from '@/utils';
|
|
10
10
|
import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
|
|
11
|
-
import {
|
|
11
|
+
import { TModuleOnCallbacksProps } from '@/base';
|
|
12
12
|
|
|
13
13
|
export * from './types';
|
|
14
14
|
|
|
@@ -21,30 +21,31 @@ export * from './types';
|
|
|
21
21
|
* @group Components
|
|
22
22
|
*/
|
|
23
23
|
export class CanvasMedia<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
> extends Canvas<
|
|
24
|
+
C extends ICanvasMediaCallbacksMap = ICanvasMediaCallbacksMap,
|
|
25
|
+
S extends ICanvasMediaStaticProps = ICanvasMediaStaticProps,
|
|
26
|
+
M extends ICanvasMediaMutableProps = ICanvasMediaMutableProps,
|
|
27
|
+
> extends Canvas<C, S, M> {
|
|
28
28
|
/** Get default static properties */
|
|
29
|
-
public _getStatic(): TRequiredProps<
|
|
29
|
+
public _getStatic(): TRequiredProps<S> {
|
|
30
30
|
return {
|
|
31
31
|
...super._getStatic(),
|
|
32
32
|
autoRenderVideo: true,
|
|
33
|
-
} as TRequiredProps<
|
|
33
|
+
} as TRequiredProps<S>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/** Get default mutable properties */
|
|
37
|
-
public _getMutable(): TRequiredProps<
|
|
37
|
+
public _getMutable(): TRequiredProps<M> {
|
|
38
38
|
return {
|
|
39
39
|
...super._getMutable(),
|
|
40
40
|
rule: 'cover',
|
|
41
|
-
} as TRequiredProps<
|
|
41
|
+
} as TRequiredProps<M>;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
constructor(
|
|
45
|
-
props?:
|
|
45
|
+
props?: S & M,
|
|
46
|
+
onCallbacks?: TModuleOnCallbacksProps<C, CanvasMedia<C, S, M>>,
|
|
46
47
|
) {
|
|
47
|
-
super(props);
|
|
48
|
+
super(props, onCallbacks as any);
|
|
48
49
|
|
|
49
50
|
this._setMediaEvents();
|
|
50
51
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ICursorStaticProps,
|
|
8
8
|
ICursorType,
|
|
9
9
|
} from './types';
|
|
10
|
-
import { Module,
|
|
10
|
+
import { Module, TModuleOnCallbacksProps } from '@/base/Module';
|
|
11
11
|
import { Raf } from '../Raf';
|
|
12
12
|
import { addEventListener } from '@/utils/listeners';
|
|
13
13
|
import { initVevet } from '@/global/initVevet';
|
|
@@ -30,21 +30,21 @@ export * from './types';
|
|
|
30
30
|
* @group Components
|
|
31
31
|
*/
|
|
32
32
|
export class Cursor<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
> extends Module<
|
|
33
|
+
C extends ICursorCallbacksMap = ICursorCallbacksMap,
|
|
34
|
+
S extends ICursorStaticProps = ICursorStaticProps,
|
|
35
|
+
M extends ICursorMutableProps = ICursorMutableProps,
|
|
36
|
+
> extends Module<C, S, M> {
|
|
37
37
|
/** Get default static properties */
|
|
38
|
-
public _getStatic(): TRequiredProps<
|
|
38
|
+
public _getStatic(): TRequiredProps<S> {
|
|
39
39
|
return {
|
|
40
40
|
...super._getStatic(),
|
|
41
41
|
container: window,
|
|
42
42
|
hideNative: false,
|
|
43
|
-
} as TRequiredProps<
|
|
43
|
+
} as TRequiredProps<S>;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/** Get default mutable properties */
|
|
47
|
-
public _getMutable(): TRequiredProps<
|
|
47
|
+
public _getMutable(): TRequiredProps<M> {
|
|
48
48
|
return {
|
|
49
49
|
...super._getMutable(),
|
|
50
50
|
enabled: true,
|
|
@@ -52,7 +52,7 @@ export class Cursor<
|
|
|
52
52
|
height: 50,
|
|
53
53
|
lerp: 0.2,
|
|
54
54
|
autoStop: true,
|
|
55
|
-
} as TRequiredProps<
|
|
55
|
+
} as TRequiredProps<M>;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -177,9 +177,10 @@ export class Cursor<
|
|
|
177
177
|
protected _activeTypes: string[];
|
|
178
178
|
|
|
179
179
|
constructor(
|
|
180
|
-
props?:
|
|
180
|
+
props?: S & M,
|
|
181
|
+
onCallbacks?: TModuleOnCallbacksProps<C, Cursor<C, S, M>>,
|
|
181
182
|
) {
|
|
182
|
-
super(props);
|
|
183
|
+
super(props, onCallbacks as any);
|
|
183
184
|
|
|
184
185
|
// Set default variables
|
|
185
186
|
const { width, height, enabled: isEnabled } = this.props;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IInViewMutableProps,
|
|
7
7
|
IInViewStaticProps,
|
|
8
8
|
} from './types';
|
|
9
|
-
import { Module,
|
|
9
|
+
import { Module, TModuleOnCallbacksProps } from '@/base/Module';
|
|
10
10
|
import { initVevet } from '@/global/initVevet';
|
|
11
11
|
import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
|
|
12
12
|
import { cnToggle } from '@/internal/cn';
|
|
@@ -22,31 +22,31 @@ export * from './types';
|
|
|
22
22
|
* @group Components
|
|
23
23
|
*/
|
|
24
24
|
export class InView<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
> extends Module<
|
|
25
|
+
C extends IInViewCallbacksMap = IInViewCallbacksMap,
|
|
26
|
+
S extends IInViewStaticProps = IInViewStaticProps,
|
|
27
|
+
M extends IInViewMutableProps = IInViewMutableProps,
|
|
28
|
+
> extends Module<C, S, M> {
|
|
29
29
|
/**
|
|
30
30
|
* Returns default static properties.
|
|
31
31
|
*/
|
|
32
|
-
public _getStatic(): TRequiredProps<
|
|
32
|
+
public _getStatic(): TRequiredProps<S> {
|
|
33
33
|
return {
|
|
34
34
|
...super._getStatic(),
|
|
35
35
|
hasOut: true,
|
|
36
36
|
maxInitialDelay: 1000,
|
|
37
37
|
scrollDirection: 'vertical',
|
|
38
|
-
} as TRequiredProps<
|
|
38
|
+
} as TRequiredProps<S>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Returns default mutable properties.
|
|
43
43
|
*/
|
|
44
|
-
public _getMutable(): TRequiredProps<
|
|
44
|
+
public _getMutable(): TRequiredProps<M> {
|
|
45
45
|
return {
|
|
46
46
|
...super._getMutable(),
|
|
47
47
|
enabled: true,
|
|
48
48
|
rootMargin: '0% 0% -5% 0%',
|
|
49
|
-
} as TRequiredProps<
|
|
49
|
+
} as TRequiredProps<M>;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** Intersection observer for detecting elements entering the viewport. */
|
|
@@ -79,9 +79,10 @@ export class InView<
|
|
|
79
79
|
* Initializes the `InView` module.
|
|
80
80
|
*/
|
|
81
81
|
constructor(
|
|
82
|
-
props?:
|
|
82
|
+
props?: S & M,
|
|
83
|
+
onCallbacks?: TModuleOnCallbacksProps<C, InView<C, S, M>>,
|
|
83
84
|
) {
|
|
84
|
-
super(props);
|
|
85
|
+
super(props, onCallbacks as any);
|
|
85
86
|
|
|
86
87
|
this._setup();
|
|
87
88
|
}
|
|
@@ -51,16 +51,12 @@ export interface IInViewCallbacksMap extends IModuleCallbacksMap {
|
|
|
51
51
|
/**
|
|
52
52
|
* Fires when an element enters the viewport.
|
|
53
53
|
*/
|
|
54
|
-
in: {
|
|
55
|
-
element: Element;
|
|
56
|
-
};
|
|
54
|
+
in: { element: Element };
|
|
57
55
|
|
|
58
56
|
/**
|
|
59
57
|
* Fires when an element leaves the viewport.
|
|
60
58
|
*/
|
|
61
|
-
out: {
|
|
62
|
-
element: Element;
|
|
63
|
-
};
|
|
59
|
+
out: { element: Element };
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
/**
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IMarqueeMutableProps,
|
|
7
7
|
IMarqueeStaticProps,
|
|
8
8
|
} from './types';
|
|
9
|
-
import { Module,
|
|
9
|
+
import { Module, TModuleOnCallbacksProps } from '@/base/Module';
|
|
10
10
|
import { Raf } from '../Raf';
|
|
11
11
|
import { initVevet } from '@/global/initVevet';
|
|
12
12
|
import { toPixels } from '@/utils';
|
|
@@ -27,23 +27,23 @@ export * from './types';
|
|
|
27
27
|
* @group Components
|
|
28
28
|
*/
|
|
29
29
|
export class Marquee<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
> extends Module<
|
|
30
|
+
C extends IMarqueeCallbacksMap = IMarqueeCallbacksMap,
|
|
31
|
+
S extends IMarqueeStaticProps = IMarqueeStaticProps,
|
|
32
|
+
M extends IMarqueeMutableProps = IMarqueeMutableProps,
|
|
33
|
+
> extends Module<C, S, M> {
|
|
34
34
|
/** Get default static properties. */
|
|
35
|
-
public _getStatic(): TRequiredProps<
|
|
35
|
+
public _getStatic(): TRequiredProps<S> {
|
|
36
36
|
return {
|
|
37
37
|
...super._getStatic(),
|
|
38
38
|
resizeDebounce: 0,
|
|
39
39
|
hasWillChange: true,
|
|
40
40
|
cloneNodes: true,
|
|
41
41
|
direction: 'horizontal',
|
|
42
|
-
} as TRequiredProps<
|
|
42
|
+
} as TRequiredProps<S>;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** Get default mutable properties. */
|
|
46
|
-
public _getMutable(): TRequiredProps<
|
|
46
|
+
public _getMutable(): TRequiredProps<M> {
|
|
47
47
|
return {
|
|
48
48
|
...super._getMutable(),
|
|
49
49
|
speed: 1,
|
|
@@ -53,7 +53,7 @@ export class Marquee<
|
|
|
53
53
|
centered: false,
|
|
54
54
|
adjustSpeed: true,
|
|
55
55
|
pauseOnOut: true,
|
|
56
|
-
} as TRequiredProps<
|
|
56
|
+
} as TRequiredProps<M>;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/** Current container size (width or height depending on direction) */
|
|
@@ -124,9 +124,10 @@ export class Marquee<
|
|
|
124
124
|
protected _intersection?: IntersectionObserver;
|
|
125
125
|
|
|
126
126
|
constructor(
|
|
127
|
-
props?:
|
|
127
|
+
props?: S & M,
|
|
128
|
+
onCallbacks?: TModuleOnCallbacksProps<C, Marquee<C, S, M>>,
|
|
128
129
|
) {
|
|
129
|
-
super(props);
|
|
130
|
+
super(props, onCallbacks as any);
|
|
130
131
|
|
|
131
132
|
const { container } = this.props;
|
|
132
133
|
const { isVertical } = this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Module,
|
|
1
|
+
import { Module, TModuleOnCallbacksProps } from '@/base';
|
|
2
2
|
import {
|
|
3
3
|
IPointersCallbacksMap,
|
|
4
4
|
IPointersItem,
|
|
@@ -24,14 +24,14 @@ export * from './types';
|
|
|
24
24
|
* @group Components
|
|
25
25
|
*/
|
|
26
26
|
export class Pointers<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
> extends Module<
|
|
27
|
+
C extends IPointersCallbacksMap = IPointersCallbacksMap,
|
|
28
|
+
S extends IPointersStaticProps = IPointersStaticProps,
|
|
29
|
+
M extends IPointersMutableProps = IPointersMutableProps,
|
|
30
|
+
> extends Module<C, S, M> {
|
|
31
31
|
/**
|
|
32
32
|
* Returns the default static properties.
|
|
33
33
|
*/
|
|
34
|
-
public _getStatic(): TRequiredProps<
|
|
34
|
+
public _getStatic(): TRequiredProps<S> {
|
|
35
35
|
return {
|
|
36
36
|
...super._getStatic(),
|
|
37
37
|
buttons: [0],
|
|
@@ -39,17 +39,17 @@ export class Pointers<
|
|
|
39
39
|
minPointers: 1,
|
|
40
40
|
maxPointers: 5,
|
|
41
41
|
disableUserSelect: true,
|
|
42
|
-
} as TRequiredProps<
|
|
42
|
+
} as TRequiredProps<S>;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Returns the default mutable properties.
|
|
47
47
|
*/
|
|
48
|
-
public _getMutable(): TRequiredProps<
|
|
48
|
+
public _getMutable(): TRequiredProps<M> {
|
|
49
49
|
return {
|
|
50
50
|
...super._getMutable(),
|
|
51
51
|
enabled: true,
|
|
52
|
-
} as TRequiredProps<
|
|
52
|
+
} as TRequiredProps<M>;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -89,9 +89,10 @@ export class Pointers<
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
constructor(
|
|
92
|
-
props?:
|
|
92
|
+
props?: S & M,
|
|
93
|
+
onCallbacks?: TModuleOnCallbacksProps<C, Pointers<C, S, M>>,
|
|
93
94
|
) {
|
|
94
|
-
super(props);
|
|
95
|
+
super(props, onCallbacks as any);
|
|
95
96
|
|
|
96
97
|
// Defaults
|
|
97
98
|
this._pointersMap = new Map();
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
IPreloaderMutableProps,
|
|
5
5
|
IPreloaderStaticProps,
|
|
6
6
|
} from './types';
|
|
7
|
-
import { Module,
|
|
7
|
+
import { Module, TModuleOnCallbacksProps } from '@/base/Module';
|
|
8
8
|
import { Timeline } from '../Timeline';
|
|
9
9
|
import { initVevet } from '@/global/initVevet';
|
|
10
10
|
import { isNumber } from '@/internal/isNumber';
|
|
@@ -20,25 +20,25 @@ export * from './types';
|
|
|
20
20
|
* @group Components
|
|
21
21
|
*/
|
|
22
22
|
export class Preloader<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
> extends Module<
|
|
23
|
+
C extends IPreloaderCallbacksMap = IPreloaderCallbacksMap,
|
|
24
|
+
S extends IPreloaderStaticProps = IPreloaderStaticProps,
|
|
25
|
+
M extends IPreloaderMutableProps = IPreloaderMutableProps,
|
|
26
|
+
> extends Module<C, S, M> {
|
|
27
27
|
/**
|
|
28
28
|
* Retrieves the default static properties.
|
|
29
29
|
*/
|
|
30
|
-
public _getStatic(): TRequiredProps<
|
|
30
|
+
public _getStatic(): TRequiredProps<S> {
|
|
31
31
|
return {
|
|
32
32
|
...super._getStatic(),
|
|
33
33
|
hide: 250,
|
|
34
|
-
} as TRequiredProps<
|
|
34
|
+
} as TRequiredProps<S>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Retrieves the default mutable properties.
|
|
39
39
|
*/
|
|
40
|
-
public _getMutable(): TRequiredProps<
|
|
41
|
-
return { ...super._getMutable() } as TRequiredProps<
|
|
40
|
+
public _getMutable(): TRequiredProps<M> {
|
|
41
|
+
return { ...super._getMutable() } as TRequiredProps<M>;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/** Indicates if the preloader is in the process of being hidden. */
|
|
@@ -58,9 +58,10 @@ export class Preloader<
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
constructor(
|
|
61
|
-
props?:
|
|
61
|
+
props?: S & M,
|
|
62
|
+
onCallbacks?: TModuleOnCallbacksProps<C, Preloader<C, S, M>>,
|
|
62
63
|
) {
|
|
63
|
-
super(props);
|
|
64
|
+
super(props, onCallbacks as any);
|
|
64
65
|
|
|
65
66
|
// Handle page load event
|
|
66
67
|
const timeout = setTimeout(() => {
|
|
@@ -14,9 +14,9 @@ import { Preloader } from '../Preloader';
|
|
|
14
14
|
import { Raf } from '../Raf';
|
|
15
15
|
import { initVevet } from '@/global/initVevet';
|
|
16
16
|
import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
|
|
17
|
-
import { TModuleCallbacksProps } from '@/base';
|
|
18
17
|
import { cnHas } from '@/internal/cn';
|
|
19
18
|
import { doc } from '@/internal/env';
|
|
19
|
+
import { TModuleOnCallbacksProps } from '@/base';
|
|
20
20
|
|
|
21
21
|
export * from './types';
|
|
22
22
|
|
|
@@ -31,17 +31,14 @@ const PAGE_RESOURCE = `vevet-page-${Math.random()}`;
|
|
|
31
31
|
* @group Components
|
|
32
32
|
*/
|
|
33
33
|
export class ProgressPreloader<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
MutableProps extends
|
|
39
|
-
IProgressPreloaderMutableProps = IProgressPreloaderMutableProps,
|
|
40
|
-
> extends Preloader<CallbacksMap, StaticProps, MutableProps> {
|
|
34
|
+
C extends IProgressPreloaderCallbacksMap = IProgressPreloaderCallbacksMap,
|
|
35
|
+
S extends IProgressPreloaderStaticProps = IProgressPreloaderStaticProps,
|
|
36
|
+
M extends IProgressPreloaderMutableProps = IProgressPreloaderMutableProps,
|
|
37
|
+
> extends Preloader<C, S, M> {
|
|
41
38
|
/**
|
|
42
39
|
* Retrieves the default static properties.
|
|
43
40
|
*/
|
|
44
|
-
public _getStatic(): TRequiredProps<
|
|
41
|
+
public _getStatic(): TRequiredProps<S> {
|
|
45
42
|
return {
|
|
46
43
|
...super._getStatic(),
|
|
47
44
|
preloadImages: true,
|
|
@@ -50,14 +47,14 @@ export class ProgressPreloader<
|
|
|
50
47
|
ignoreClassName: 'js-preload-ignore',
|
|
51
48
|
lerp: 0.1,
|
|
52
49
|
endDuration: 500,
|
|
53
|
-
} as TRequiredProps<
|
|
50
|
+
} as TRequiredProps<S>;
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
/**
|
|
57
54
|
* Retrieves the default mutable properties.
|
|
58
55
|
*/
|
|
59
|
-
public _getMutable(): TRequiredProps<
|
|
60
|
-
return { ...super._getMutable() } as TRequiredProps<
|
|
56
|
+
public _getMutable(): TRequiredProps<M> {
|
|
57
|
+
return { ...super._getMutable() } as TRequiredProps<M>;
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
/**
|
|
@@ -111,9 +108,10 @@ export class ProgressPreloader<
|
|
|
111
108
|
protected _raf: Raf;
|
|
112
109
|
|
|
113
110
|
constructor(
|
|
114
|
-
props?:
|
|
111
|
+
props?: S & M,
|
|
112
|
+
onCallbacks?: TModuleOnCallbacksProps<C, ProgressPreloader<C, S, M>>,
|
|
115
113
|
) {
|
|
116
|
-
super(props);
|
|
114
|
+
super(props, onCallbacks as any);
|
|
117
115
|
|
|
118
116
|
// Initialize animation frame if interpolation is enabled
|
|
119
117
|
this._raf = new Raf();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TRequiredProps } from '@/internal/requiredProps';
|
|
2
|
-
import { Module,
|
|
2
|
+
import { Module, TModuleOnCallbacksProps } from '@/base/Module';
|
|
3
3
|
import { IRafCallbacksMap, IRafMutableProps, IRafStaticProps } from './types';
|
|
4
4
|
import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
|
|
5
5
|
|
|
@@ -13,23 +13,23 @@ export * from './types';
|
|
|
13
13
|
* @group Components
|
|
14
14
|
*/
|
|
15
15
|
export class Raf<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> extends Module<
|
|
16
|
+
C extends IRafCallbacksMap = IRafCallbacksMap,
|
|
17
|
+
S extends IRafStaticProps = IRafStaticProps,
|
|
18
|
+
M extends IRafMutableProps = IRafMutableProps,
|
|
19
|
+
> extends Module<C, S, M> {
|
|
20
20
|
/** Get default static properties */
|
|
21
|
-
public _getStatic(): TRequiredProps<
|
|
22
|
-
return { ...super._getStatic() } as TRequiredProps<
|
|
21
|
+
public _getStatic(): TRequiredProps<S> {
|
|
22
|
+
return { ...super._getStatic() } as TRequiredProps<S>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Get default mutable properties */
|
|
26
|
-
public _getMutable(): TRequiredProps<
|
|
26
|
+
public _getMutable(): TRequiredProps<M> {
|
|
27
27
|
return {
|
|
28
28
|
...super._getMutable(),
|
|
29
29
|
fps: 'auto',
|
|
30
30
|
enabled: false,
|
|
31
31
|
fpsRecalcFrames: 10,
|
|
32
|
-
} as TRequiredProps<
|
|
32
|
+
} as TRequiredProps<M>;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/** Indicates if the animation frame is currently running */
|
|
@@ -84,9 +84,10 @@ export class Raf<
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
constructor(
|
|
87
|
-
props?:
|
|
87
|
+
props?: S & M,
|
|
88
|
+
onCallbacks?: TModuleOnCallbacksProps<C, Raf<C, S, M>>,
|
|
88
89
|
) {
|
|
89
|
-
super(props);
|
|
90
|
+
super(props, onCallbacks as any);
|
|
90
91
|
|
|
91
92
|
// Initialize FPS
|
|
92
93
|
this._fps = this.props.fps === 'auto' ? this._fps : this.props.fps;
|
|
@@ -117,7 +118,7 @@ export class Raf<
|
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
this.updateProps({ enabled: true } as
|
|
121
|
+
this.updateProps({ enabled: true } as M);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
/** Internal method to start the loop */
|
|
@@ -141,7 +142,7 @@ export class Raf<
|
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
this.updateProps({ enabled: false } as
|
|
145
|
+
this.updateProps({ enabled: false } as M);
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
/** Internal method to pause the loop */
|