@hilux/ngx-motion 1.1.0 → 1.1.2
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 +214 -268
- package/ng-package.json +7 -0
- package/package.json +21 -14
- package/src/lib/components/motion-one-presence.component.ts +116 -0
- package/src/lib/constants/motion-defaults.constants.ts +41 -0
- package/src/lib/directives/motion-animate.directive.ts +55 -0
- package/src/lib/directives/motion-if.directive.ts +138 -0
- package/src/lib/directives/motion-one.directive.backup.ts +1591 -0
- package/src/lib/directives/motion-one.directive.ts +1154 -0
- package/src/lib/directives/motion-presence.directive.ts +145 -0
- package/src/lib/services/motion-animation-options.service.ts +142 -0
- package/src/lib/services/motion-animation.service.ts +86 -0
- package/src/lib/services/motion-browser-safe.ts +64 -0
- package/src/lib/services/motion-gesture.service.ts +141 -0
- package/src/lib/services/motion-inview.service.ts +91 -0
- package/src/lib/services/motion-one.service.ts +424 -0
- package/src/lib/services/motion-stagger.service.ts +70 -0
- package/src/lib/services/motion-timeline.service.ts +182 -0
- package/src/lib/types/motion-animation.types.ts +46 -0
- package/src/lib/utils/color.utils.ts +54 -0
- package/src/lib/utils/easing.utils.ts +77 -0
- package/src/lib/utils/index.ts +7 -0
- package/src/lib/utils/style-extraction.utils.ts +70 -0
- package/src/lib/utils/timing.utils.ts +61 -0
- package/src/lib/utils/transform.utils.ts +112 -0
- package/src/lib/utils/variant.utils.ts +55 -0
- package/src/public-api.ts +21 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/fesm2022/hilux-ngx-motion.mjs +0 -1562
- package/fesm2022/hilux-ngx-motion.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/directives/motion-if.directive.d.ts +0 -14
- package/lib/directives/motion-one.directive.d.ts +0 -142
- package/lib/services/motion-animation.service.d.ts +0 -20
- package/lib/services/motion-browser-safe.d.ts +0 -10
- package/lib/services/motion-one.service.d.ts +0 -87
- package/public-api.d.ts +0 -6
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for Motion One animations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Transition configuration options similar to Framer Motion
|
|
7
|
+
*/
|
|
8
|
+
export interface TransitionOptions {
|
|
9
|
+
duration?: number;
|
|
10
|
+
delay?: number;
|
|
11
|
+
ease?: string | number[] | { type: 'spring'; stiffness?: number; damping?: number };
|
|
12
|
+
repeat?: number | boolean;
|
|
13
|
+
repeatType?: 'loop' | 'mirror' | 'reverse' | 'forwards' | 'pingPong';
|
|
14
|
+
repeatDelay?: number;
|
|
15
|
+
staggerChildren?: number;
|
|
16
|
+
staggerDirection?: number;
|
|
17
|
+
when?: 'beforeChildren' | 'afterChildren' | 'together';
|
|
18
|
+
delayChildren?: number;
|
|
19
|
+
times?: number[]; // keyframe times 0..1
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Variant definition that can include transition properties
|
|
24
|
+
*/
|
|
25
|
+
export interface VariantWithTransition {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
transition?: TransitionOptions;
|
|
28
|
+
at?: number; // Define when variant should be triggered
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Timeline step for orchestrated per-property animations
|
|
33
|
+
*/
|
|
34
|
+
export interface TimelineStep {
|
|
35
|
+
prop: string;
|
|
36
|
+
keyframes?: any[] | any;
|
|
37
|
+
to?: any;
|
|
38
|
+
duration: number;
|
|
39
|
+
delay?: number;
|
|
40
|
+
ease?: string | number[] | { type: 'spring'; stiffness?: number; damping?: number };
|
|
41
|
+
atTime?: number; // absolute start (s) relative to element start
|
|
42
|
+
times?: number[];
|
|
43
|
+
repeat?: number | boolean;
|
|
44
|
+
repeatType?: 'loop' | 'mirror' | 'reverse' | 'forwards' | 'pingPong';
|
|
45
|
+
repeatDelay?: number;
|
|
46
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { COLOR_PROPERTIES } from '../constants/motion-defaults.constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if a property is a color property
|
|
5
|
+
*/
|
|
6
|
+
export function isColorProperty(key: string): boolean {
|
|
7
|
+
return COLOR_PROPERTIES.includes(key as any);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Normalize color values to a consistent format
|
|
12
|
+
* Converts named colors to hex values for consistent animation
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeColor(color: any): string {
|
|
15
|
+
if (color == null) return '';
|
|
16
|
+
|
|
17
|
+
if (typeof color !== 'string') {
|
|
18
|
+
try {
|
|
19
|
+
return String(color);
|
|
20
|
+
} catch {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Already normalized formats
|
|
26
|
+
if (color.startsWith('rgb') || color.startsWith('#')) {
|
|
27
|
+
return color;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Named color mappings
|
|
31
|
+
const colorMap: Record<string, string> = {
|
|
32
|
+
aqua: '#00ffff',
|
|
33
|
+
red: '#ff0000',
|
|
34
|
+
blue: '#0000ff',
|
|
35
|
+
green: '#008000',
|
|
36
|
+
yellow: '#ffff00',
|
|
37
|
+
purple: '#800080',
|
|
38
|
+
orange: '#ffa500',
|
|
39
|
+
black: '#000000',
|
|
40
|
+
white: '#ffffff',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return colorMap[color] || color;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Normalize color values in an array or single value
|
|
48
|
+
*/
|
|
49
|
+
export function normalizeColorValue(value: any): any {
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
return value.map(v => normalizeColor(v));
|
|
52
|
+
}
|
|
53
|
+
return normalizeColor(value);
|
|
54
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { TransitionOptions } from '../types/motion-animation.types';
|
|
2
|
+
import { MotionAnimationService } from '../services/motion-animation.service';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolve easing string/config to Motion One easing function
|
|
6
|
+
*/
|
|
7
|
+
export function getEasing(
|
|
8
|
+
easingString: string | number[] | { type: 'spring'; stiffness?: number; damping?: number } | undefined,
|
|
9
|
+
motionAnimation: MotionAnimationService
|
|
10
|
+
): any {
|
|
11
|
+
if (!easingString) return motionAnimation.easeInOut;
|
|
12
|
+
|
|
13
|
+
// Array easing (cubic bezier)
|
|
14
|
+
if (Array.isArray(easingString)) {
|
|
15
|
+
return easingString;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Spring configuration
|
|
19
|
+
if (typeof easingString === 'object' && 'type' in easingString && easingString.type === 'spring') {
|
|
20
|
+
return motionAnimation.spring({
|
|
21
|
+
stiffness: easingString.stiffness || 100,
|
|
22
|
+
damping: easingString.damping || 10
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Named easing strings
|
|
27
|
+
if (typeof easingString === 'string') {
|
|
28
|
+
if (easingString === 'ease-in') return motionAnimation.easeIn;
|
|
29
|
+
if (easingString === 'ease-out') return motionAnimation.easeOut;
|
|
30
|
+
if (easingString === 'ease-in-out' || easingString === 'ease') return motionAnimation.easeInOut;
|
|
31
|
+
if (easingString === 'spring') return motionAnimation.spring();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return motionAnimation.easeInOut;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Map Framer Motion repeatType to Motion One direction
|
|
39
|
+
*/
|
|
40
|
+
export function mapRepeatTypeToDirection(
|
|
41
|
+
repeatType: TransitionOptions['repeatType'] | undefined
|
|
42
|
+
): 'normal' | 'reverse' | 'alternate' | undefined {
|
|
43
|
+
if (!repeatType) return undefined;
|
|
44
|
+
|
|
45
|
+
// Aliases
|
|
46
|
+
if (repeatType === 'forwards' || repeatType === 'loop') return 'normal';
|
|
47
|
+
if (repeatType === 'reverse') return 'reverse';
|
|
48
|
+
if (repeatType === 'pingPong' || repeatType === 'mirror') return 'alternate';
|
|
49
|
+
|
|
50
|
+
// Default
|
|
51
|
+
return 'normal';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Normalize repeat value (convert boolean/number to number)
|
|
56
|
+
*/
|
|
57
|
+
export function normalizeRepeatValue(repeat: number | boolean | undefined): number {
|
|
58
|
+
if (repeat === undefined) return 0;
|
|
59
|
+
if (repeat === true) return Infinity;
|
|
60
|
+
if (typeof repeat === 'number') return repeat;
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get repeat value from transition object or fallback
|
|
66
|
+
*/
|
|
67
|
+
export function getRepeatValue(transitionObj: TransitionOptions, fallbackRepeat: boolean): number {
|
|
68
|
+
if (transitionObj.repeat !== undefined) {
|
|
69
|
+
if (transitionObj.repeat === true) {
|
|
70
|
+
return Infinity;
|
|
71
|
+
} else if (typeof transitionObj.repeat === 'number') {
|
|
72
|
+
return transitionObj.repeat;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return fallbackRepeat ? Infinity : 0;
|
|
77
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { VariantWithTransition } from '../types/motion-animation.types';
|
|
2
|
+
import { EXCLUDED_PROPERTIES } from '../constants/motion-defaults.constants';
|
|
3
|
+
import { isTransformProperty } from './transform.utils';
|
|
4
|
+
import { isColorProperty, normalizeColorValue } from './color.utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extract only style properties from a variant (excluding transition and metadata)
|
|
8
|
+
*/
|
|
9
|
+
export function extractStyleProperties(variant: VariantWithTransition): Record<string, any> {
|
|
10
|
+
if (!variant) return {};
|
|
11
|
+
|
|
12
|
+
const result: Record<string, any> = {};
|
|
13
|
+
|
|
14
|
+
for (const key in variant) {
|
|
15
|
+
// Skip meta keys
|
|
16
|
+
if (EXCLUDED_PROPERTIES.includes(key as any)) continue;
|
|
17
|
+
|
|
18
|
+
// Allow raw transform strings to pass through
|
|
19
|
+
if (key === 'transform') {
|
|
20
|
+
result['transform'] = variant[key];
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// CRITICAL FIX: Pass transform properties directly to Motion One
|
|
25
|
+
// Motion One can animate rotate, scale, x, y, etc. as individual properties
|
|
26
|
+
// This provides much better spring animation interruption and avoids 3D transform issues
|
|
27
|
+
if (isTransformProperty(key)) {
|
|
28
|
+
// Pass the value directly - Motion One will handle it
|
|
29
|
+
result[key] = variant[key];
|
|
30
|
+
} else {
|
|
31
|
+
applyStyleProperty(result, key, variant[key]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Don't normalize transforms - let Motion One handle them natively
|
|
36
|
+
// normalizeTransformProperty(result);
|
|
37
|
+
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Apply a regular style property to the result object
|
|
43
|
+
* Handles color normalization if needed
|
|
44
|
+
*/
|
|
45
|
+
export function applyStyleProperty(
|
|
46
|
+
result: Record<string, any>,
|
|
47
|
+
key: string,
|
|
48
|
+
value: any
|
|
49
|
+
): void {
|
|
50
|
+
if (isColorProperty(key)) {
|
|
51
|
+
result[key] = normalizeColorValue(value);
|
|
52
|
+
} else {
|
|
53
|
+
result[key] = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Check if a variant has any style properties to apply
|
|
59
|
+
*/
|
|
60
|
+
export function hasStyleProperties(variant: VariantWithTransition): boolean {
|
|
61
|
+
if (!variant || typeof variant !== 'object') return false;
|
|
62
|
+
|
|
63
|
+
for (const key in variant) {
|
|
64
|
+
if (!EXCLUDED_PROPERTIES.includes(key as any)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize keyframe times array to 0-1 range
|
|
3
|
+
* Handles both normalized (0-1) and absolute time values
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeTimes(times: number[] | undefined, duration: number): number[] | undefined {
|
|
6
|
+
if (!times || times.length === 0) return undefined;
|
|
7
|
+
|
|
8
|
+
// Check if any values are above 1 (indicating absolute times)
|
|
9
|
+
const hasValuesAboveOne = times.some(t => t > 1);
|
|
10
|
+
if (!hasValuesAboveOne) return times;
|
|
11
|
+
|
|
12
|
+
// Find the maximum time value
|
|
13
|
+
const maxT = Math.max(...times);
|
|
14
|
+
|
|
15
|
+
// Ensure duration is valid (avoid division by zero)
|
|
16
|
+
const safeDuration = Math.max(duration, 0.000001);
|
|
17
|
+
|
|
18
|
+
// Determine divisor: use maxT if significantly larger than duration, else use duration
|
|
19
|
+
const divisor = maxT > safeDuration * 1.001 ? maxT : safeDuration;
|
|
20
|
+
|
|
21
|
+
// Normalize to 0-1 range
|
|
22
|
+
return times.map(t => {
|
|
23
|
+
const v = t / divisor;
|
|
24
|
+
return v < 0 ? 0 : v > 1 ? 1 : v;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Calculate stagger delay for a child element
|
|
30
|
+
* Takes into account the child's index and stagger direction
|
|
31
|
+
*/
|
|
32
|
+
export function calculateStaggerDelay(
|
|
33
|
+
index: number,
|
|
34
|
+
totalChildren: number,
|
|
35
|
+
staggerValue: number,
|
|
36
|
+
direction: number
|
|
37
|
+
): number {
|
|
38
|
+
let staggerIndex: number;
|
|
39
|
+
|
|
40
|
+
if (direction >= 0) {
|
|
41
|
+
// Forward direction: 0, 1, 2, 3...
|
|
42
|
+
staggerIndex = index;
|
|
43
|
+
} else {
|
|
44
|
+
// Reverse direction: 3, 2, 1, 0...
|
|
45
|
+
staggerIndex = totalChildren - 1 - index;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return staggerIndex * staggerValue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Calculate total duration including stagger for all children
|
|
53
|
+
*/
|
|
54
|
+
export function calculateTotalStaggerDuration(
|
|
55
|
+
childCount: number,
|
|
56
|
+
staggerValue: number,
|
|
57
|
+
baseDelay: number,
|
|
58
|
+
delayChildren: number
|
|
59
|
+
): number {
|
|
60
|
+
return baseDelay + delayChildren + (childCount * staggerValue);
|
|
61
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { TRANSFORM_PROPERTIES, IDENTITY_MATRIX } from '../constants/motion-defaults.constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if a property should be handled as a transform
|
|
5
|
+
*/
|
|
6
|
+
export function isTransformProperty(key: string): boolean {
|
|
7
|
+
return TRANSFORM_PROPERTIES.includes(key as any);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create an identity matrix for transform operations
|
|
12
|
+
*/
|
|
13
|
+
export function createIdentityMatrix(): number[] {
|
|
14
|
+
return [...IDENTITY_MATRIX];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Parse a matrix string to array of numbers
|
|
19
|
+
*/
|
|
20
|
+
export function parseMatrix(matrixString: string): number[] {
|
|
21
|
+
const match = matrixString.match(/matrix\((.*)\)/);
|
|
22
|
+
if (!match) return createIdentityMatrix();
|
|
23
|
+
return match[1].split(',').map(Number);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Multiply two 2D transformation matrices
|
|
28
|
+
*/
|
|
29
|
+
export function multiplyMatrices(a: number[], b: number[]): number[] {
|
|
30
|
+
return [
|
|
31
|
+
a[0] * b[0] + a[2] * b[1], // a
|
|
32
|
+
a[1] * b[0] + a[3] * b[1], // b
|
|
33
|
+
a[0] * b[2] + a[2] * b[3], // c
|
|
34
|
+
a[1] * b[2] + a[3] * b[3], // d
|
|
35
|
+
a[0] * b[4] + a[2] * b[5] + a[4], // e
|
|
36
|
+
a[1] * b[4] + a[3] * b[5] + a[5] // f
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Convert a matrix array to CSS matrix string
|
|
42
|
+
*/
|
|
43
|
+
export function matrixToCssString(matrix: number[]): string {
|
|
44
|
+
return `matrix(${matrix.join(',')})`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create a transformation matrix for a specific transform type
|
|
49
|
+
*/
|
|
50
|
+
export function createTransformMatrix(key: string, value: any): number[] {
|
|
51
|
+
switch (key) {
|
|
52
|
+
case 'x':
|
|
53
|
+
return [1, 0, 0, 1, value, 0];
|
|
54
|
+
case 'y':
|
|
55
|
+
return [1, 0, 0, 1, 0, value];
|
|
56
|
+
case 'rotate':
|
|
57
|
+
const rad = (value * Math.PI) / 180;
|
|
58
|
+
const cos = Math.cos(rad);
|
|
59
|
+
const sin = Math.sin(rad);
|
|
60
|
+
return [cos, sin, -sin, cos, 0, 0];
|
|
61
|
+
case 'scale':
|
|
62
|
+
return [value, 0, 0, value, 0, 0];
|
|
63
|
+
case 'scaleX':
|
|
64
|
+
return [value, 0, 0, 1, 0, 0];
|
|
65
|
+
case 'scaleY':
|
|
66
|
+
return [1, 0, 0, value, 0, 0];
|
|
67
|
+
default:
|
|
68
|
+
return createIdentityMatrix();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Apply a transform property to a result object
|
|
74
|
+
* Handles keyframe arrays and individual values
|
|
75
|
+
*/
|
|
76
|
+
export function applyTransformProperty(
|
|
77
|
+
result: Record<string, any>,
|
|
78
|
+
key: string,
|
|
79
|
+
value: any
|
|
80
|
+
): void {
|
|
81
|
+
// If keyframe array is provided, let Motion One handle it directly
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
result[key] = value;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Initialize transform matrix if it doesn't exist
|
|
88
|
+
if (!result['transform']) {
|
|
89
|
+
result['transform'] = matrixToCssString(createIdentityMatrix());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Parse current matrix
|
|
93
|
+
const currentMatrix = parseMatrix(result['transform']);
|
|
94
|
+
|
|
95
|
+
// Create new matrix based on the transform type
|
|
96
|
+
const newMatrix = createTransformMatrix(key, value);
|
|
97
|
+
|
|
98
|
+
// Multiply matrices
|
|
99
|
+
const finalMatrix = multiplyMatrices(currentMatrix, newMatrix);
|
|
100
|
+
|
|
101
|
+
// Apply the new matrix
|
|
102
|
+
result['transform'] = matrixToCssString(finalMatrix);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Normalize the transform property by trimming extra spaces
|
|
107
|
+
*/
|
|
108
|
+
export function normalizeTransformProperty(result: Record<string, any>): void {
|
|
109
|
+
if (result['transform']) {
|
|
110
|
+
result['transform'] = result['transform'].trim();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VariantWithTransition } from '../types/motion-animation.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a variant reference to its actual definition
|
|
5
|
+
* Handles both string references and direct object definitions
|
|
6
|
+
*/
|
|
7
|
+
export function resolveVariant(
|
|
8
|
+
variant: VariantWithTransition | string,
|
|
9
|
+
variants: { [key: string]: VariantWithTransition }
|
|
10
|
+
): VariantWithTransition {
|
|
11
|
+
if (typeof variant === 'string') {
|
|
12
|
+
return variants[variant] || {};
|
|
13
|
+
} else if (typeof variant === 'object' && variant !== null) {
|
|
14
|
+
return variant;
|
|
15
|
+
} else {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Extract metadata properties from a variant (properties that aren't styles)
|
|
22
|
+
*/
|
|
23
|
+
export function extractVariantMetadata(variant: VariantWithTransition): {
|
|
24
|
+
transition?: any;
|
|
25
|
+
at?: number;
|
|
26
|
+
} {
|
|
27
|
+
return {
|
|
28
|
+
transition: variant.transition,
|
|
29
|
+
at: variant.at
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if a variant has any style properties (excluding metadata)
|
|
35
|
+
*/
|
|
36
|
+
export function hasStyleProperties(variant: VariantWithTransition): boolean {
|
|
37
|
+
if (!variant || typeof variant !== 'object') return false;
|
|
38
|
+
|
|
39
|
+
const keys = Object.keys(variant);
|
|
40
|
+
const styleKeys = keys.filter(key => key !== 'transition' && key !== 'at');
|
|
41
|
+
|
|
42
|
+
return styleKeys.length > 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Check if a variant is empty or undefined
|
|
47
|
+
*/
|
|
48
|
+
export function isEmptyVariant(variant: VariantWithTransition | string | undefined): boolean {
|
|
49
|
+
if (!variant) return true;
|
|
50
|
+
if (typeof variant === 'string') return false; // String references are not empty
|
|
51
|
+
if (typeof variant === 'object') {
|
|
52
|
+
return Object.keys(variant).length === 0;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of ngx-motion
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Motion One specific exports
|
|
6
|
+
export * from './lib/directives/motion-one.directive';
|
|
7
|
+
export * from './lib/directives/motion-if.directive';
|
|
8
|
+
export * from './lib/directives/motion-presence.directive';
|
|
9
|
+
export * from './lib/services/motion-one.service';
|
|
10
|
+
export * from './lib/services/motion-animation.service';
|
|
11
|
+
|
|
12
|
+
// Export interfaces and types
|
|
13
|
+
export type {
|
|
14
|
+
TransitionOptions,
|
|
15
|
+
VariantWithTransition,
|
|
16
|
+
TimelineStep
|
|
17
|
+
} from './lib/types/motion-animation.types';
|
|
18
|
+
|
|
19
|
+
export type {
|
|
20
|
+
MotionElement
|
|
21
|
+
} from './lib/services/motion-one.service';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/lib",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"inlineSources": true,
|
|
10
|
+
"types": [],
|
|
11
|
+
"lib": ["ES2022", "dom"],
|
|
12
|
+
"skipLibCheck": true
|
|
13
|
+
},
|
|
14
|
+
"exclude": [
|
|
15
|
+
"**/*.spec.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.lib.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"declarationMap": false
|
|
7
|
+
},
|
|
8
|
+
"angularCompilerOptions": {
|
|
9
|
+
"compilationMode": "partial"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/spec",
|
|
7
|
+
"types": [
|
|
8
|
+
"jasmine"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"**/*.spec.ts",
|
|
13
|
+
"**/*.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|