@hilux/ngx-motion 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hilux/ngx-motion",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A library for Angular motion directives",
5
5
  "main": "bundles/ngx-motion.umd.js",
6
6
  "module": "fesm5/ngx-motion.js",
@@ -10,6 +10,7 @@ import {
10
10
 
11
11
  @Directive({
12
12
  selector: "[animatePresence]",
13
+ standalone: true,
13
14
  })
14
15
  export class MotionHostDirective {
15
16
  @ContentChildren(MotionDirective) motionElements!: QueryList<MotionDirective>;
@@ -16,6 +16,7 @@ import { MotionHostDirective} from "./ngx-motion-container.directive";
16
16
 
17
17
  @Directive({
18
18
  selector: "[motion]",
19
+ standalone: true,
19
20
  })
20
21
  export class MotionDirective implements OnDestroy {
21
22
  @Input() initial: any = {};
@@ -23,6 +24,8 @@ export class MotionDirective implements OnDestroy {
23
24
  @Input() exit: any = {};
24
25
  @Input() duration = "0.3s";
25
26
  @Input() easing = "ease";
27
+ @Input() onHover: any = {};
28
+ @Input() variant: string = '';
26
29
 
27
30
  @Output() animationComplete = new EventEmitter<void>();
28
31
 
@@ -37,6 +40,9 @@ export class MotionDirective implements OnDestroy {
37
40
  } else {
38
41
  this.runAnimation(this.initial);
39
42
  }
43
+ if (this.onHover) {
44
+ this.runAnimation(this.onHover);
45
+ }
40
46
  }
41
47
 
42
48
  ngOnDestroy() {
@@ -57,6 +63,10 @@ export class MotionDirective implements OnDestroy {
57
63
  animate(`${this.duration} ${this.easing}`, style(styles)),
58
64
  ]);
59
65
 
66
+ if (this.variant) {
67
+ styles = { ...styles, ...this.getVariantStyles(this.variant) };
68
+ }
69
+
60
70
  if (this.player) {
61
71
  this.player.destroy();
62
72
  }
@@ -94,4 +104,15 @@ export class MotionDirective implements OnDestroy {
94
104
  getDuration(): number {
95
105
  return parseFloat(this.duration) * 1000; // Convert to milliseconds
96
106
  }
107
+
108
+ private getVariantStyles(variant: string): any {
109
+ switch (variant) {
110
+ case 'fade':
111
+ return { opacity: 0 };
112
+ case 'scale':
113
+ return { transform: 'scale(1.2)' };
114
+ default:
115
+ return {};
116
+ }
117
+ }
97
118
  }