{"version":3,"file":"my-angular-animation.mjs","sources":["../../../projects/my-angular-animation/src/lib/animate.component.ts","../../../projects/my-angular-animation/src/lib/animate.component.html","../../../projects/my-angular-animation/src/public-api.ts","../../../projects/my-angular-animation/src/my-angular-animation.ts"],"sourcesContent":["import { AfterViewInit, Component, ElementRef, Input, output, OutputEmitterRef, Renderer2, ViewChild, ViewEncapsulation } from '@angular/core';\r\n\r\n@Component({\r\n  selector: 'animate',\r\n  imports: [],\r\n  templateUrl: './animate.component.html',\r\n  styleUrl: './animate.component.css',\r\n  encapsulation: ViewEncapsulation.None\r\n})\r\nexport class AnimateComponent implements AfterViewInit {\r\n\r\n  @Input() id: string = \"\";\r\n  @Input() animation: string = \"\";\r\n  @Input() durationInSeconds: number = 1;\r\n  @Input() delayInSeconds: number = 0;\r\n  @Input() isManualTrigger: boolean = false;\r\n\r\n  _iterationCount: string = \"1\";\r\n\r\n  get iterationCount(): number {\r\n      return parseInt(this._iterationCount)\r\n  }\r\n  @Input() set iterationCount(value: number) {\r\n    if (value <= 0) {\r\n      this._iterationCount = \"infinite\";\r\n    }\r\n    else if (value != undefined)\r\n      this._iterationCount = parseInt(value.toString()).toString();\r\n    else\r\n      this._iterationCount = \"1\";\r\n  }\r\n\r\n  durInSecs = this.durationInSeconds + \"s\";\r\n  delInSecs = this.delayInSeconds + \"s\";\r\n\r\n  onAnimationTriggered = output<void>();\r\n\r\n  @ViewChild('myAnimationElement') myAnimationElement: ElementRef | undefined;\r\n\r\n  static bounce: string = \"bounce\";\r\n  static bounceIn: string = \"bounce-in\";\r\n  static fadeIn: string = \"fade-in\";\r\n  static fadeOut: string = \"fade-out\";\r\n  static fadeInOut: string = \"fade-in-out\";\r\n  static fadeOutIn: string = \"fade-out-in\";\r\n  static flip: string = \"flip\";\r\n  static shake: string = \"shake\";\r\n  static swing: string = \"swing\";\r\n  static slideUp: string = \"slide-up\";\r\n  static slideDown: string = \"slide-down\";\r\n  static slideLeft: string = \"slide-left\";\r\n  static slideRight: string = \"slide-right\";\r\n  static wobble: string = \"wobble\";\r\n\r\n  constructor(private renderer: Renderer2) {\r\n  }\r\n\r\n  ngOnInit() {    \r\n    this.setCSSVariables();\r\n  }\r\n\r\n  ngAfterViewInit() {\r\n    if (!this.isManualTrigger)\r\n      this.trigger();    \r\n  }\r\n\r\n  triggerAnimation() {\r\n    if (this.isManualTrigger)\r\n      this.trigger();\r\n    else\r\n      console.log(\"Set the isManualTrigger property to true first.\");\r\n  }\r\n\r\n  triggerAnimationDynamic(settings: AnimateSettings) {\r\n    this.clearAnimateSettings();\r\n\r\n    this.animation = settings.animation;\r\n    this.isManualTrigger = true;\r\n    if (settings.delayInSeconds != undefined)\r\n      this.delayInSeconds = settings.delayInSeconds;    \r\n    if (settings.durationInSeconds != undefined)\r\n      this.durationInSeconds = settings.durationInSeconds;      \r\n    if (settings.iterationCount != undefined)\r\n      this.iterationCount = settings.iterationCount;\r\n    if (settings.onAnimationTriggered != undefined) {\r\n      this.onAnimationTriggered = settings.onAnimationTriggered;\r\n    }\r\n\r\n    this.setCSSVariables();\r\n\r\n    this.trigger();     \r\n  }\r\n\r\n  private setCSSVariables() {\r\n    this.durInSecs = this.durationInSeconds + \"s\";\r\n    this.delInSecs = this.delayInSeconds + \"s\";\r\n    this.renderer.setStyle(document.documentElement, `--durationInSeconds`, `${this.durInSecs}`, 2);\r\n    this.renderer.setStyle(document.documentElement, `--iterationCount`, `${this._iterationCount}`, 2);\r\n    this.renderer.setStyle(document.documentElement, `--delayInSeconds`, `${this.delInSecs}`, 2);\r\n  }\r\n\r\n  private clearAnimateSettings() {\r\n    this.animation = \"\";\r\n    this.delayInSeconds = 0;\r\n    this.durationInSeconds = 1;\r\n    this.isManualTrigger = false;\r\n    this.iterationCount = 1;\r\n    this._iterationCount = \"1\";\r\n  }\r\n\r\n  private removeAllClasses() {\r\n    this.myAnimationElement?.nativeElement.classList.forEach(cls => {\r\n      this.renderer['removeClass'](this.myAnimationElement?.nativeElement, cls);\r\n    });\r\n  }  \r\n\r\n  private trigger() {\r\n    this.removeAllClasses();\r\n    setTimeout(() => {\r\n      this.renderer['addClass'](this.myAnimationElement?.nativeElement, this.animation);\r\n      this.onAnimationTriggered?.emit();\r\n    }, 0);    \r\n  }\r\n}\r\n\r\nexport class AnimateSettings {\r\n  animation: string = \"\";\r\n  durationInSeconds?: number = 1;\r\n  delayInSeconds?: number = 0;\r\n  iterationCount?: number = 1;\r\n  onAnimationTriggered?: OutputEmitterRef<void>;\r\n}","<div class=\"animationContainer\">\r\n    <div id=\"{{id}}\" #myAnimationElement class=\"hidden\">\r\n        <div style=\"display: inline-block!important;\">\r\n            <ng-content></ng-content>\r\n        </div>      \r\n    </div>\r\n</div>","/*\r\n * Public API Surface of my-angular-animation\r\n */\r\n\r\nexport * from './lib/animate.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MASa,gBAAgB,CAAA;AA6CP,IAAA,QAAA;IA3CX,EAAE,GAAW,EAAE;IACf,SAAS,GAAW,EAAE;IACtB,iBAAiB,GAAW,CAAC;IAC7B,cAAc,GAAW,CAAC;IAC1B,eAAe,GAAY,KAAK;IAEzC,eAAe,GAAW,GAAG;AAE7B,IAAA,IAAI,cAAc,GAAA;AACd,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC;;IAEzC,IAAa,cAAc,CAAC,KAAa,EAAA;AACvC,QAAA,IAAI,KAAK,IAAI,CAAC,EAAE;AACd,YAAA,IAAI,CAAC,eAAe,GAAG,UAAU;;aAE9B,IAAI,KAAK,IAAI,SAAS;AACzB,YAAA,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;;AAE5D,YAAA,IAAI,CAAC,eAAe,GAAG,GAAG;;AAG9B,IAAA,SAAS,GAAG,IAAI,CAAC,iBAAiB,GAAG,GAAG;AACxC,IAAA,SAAS,GAAG,IAAI,CAAC,cAAc,GA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