summaryrefslogtreecommitdiffstats
path: root/src/angular/animations
diff options
context:
space:
mode:
authorIsrael Lavi <israel.lavi@intl.att.com>2018-05-21 17:42:00 +0300
committerIsrael Lavi <il0695@att.com>2018-05-21 17:52:01 +0300
commit1994c98063c27a41797dec01f2ca9fcbe33ceab0 (patch)
treef30beeaf15a8358f6da78fdd74bcbda74bd334f8 /src/angular/animations
parent4749f4631426fcbe29ed98cef8f24cab18b501d0 (diff)
init commit onap ui
Change-Id: I1dace78817dbba752c550c182dfea118b4a38646 Issue-ID: SDC-1350 Signed-off-by: Israel Lavi <il0695@att.com>
Diffstat (limited to 'src/angular/animations')
-rw-r--r--src/angular/animations/animation-directives.module.ts19
-rw-r--r--src/angular/animations/ripple-click.animation.directive.ts47
2 files changed, 66 insertions, 0 deletions
diff --git a/src/angular/animations/animation-directives.module.ts b/src/angular/animations/animation-directives.module.ts
new file mode 100644
index 0000000..c6a8203
--- /dev/null
+++ b/src/angular/animations/animation-directives.module.ts
@@ -0,0 +1,19 @@
+import { NgModule } from "@angular/core";
+import { RippleClickAnimationDirective } from "./ripple-click.animation.directive";
+import { CommonModule } from "@angular/common";
+
+@NgModule({
+ declarations: [
+ RippleClickAnimationDirective
+ ],
+ imports: [
+ CommonModule
+ ],
+ exports: [
+ RippleClickAnimationDirective
+
+ ],
+})
+export class AnimationDirectivesModule {
+
+}
diff --git a/src/angular/animations/ripple-click.animation.directive.ts b/src/angular/animations/ripple-click.animation.directive.ts
new file mode 100644
index 0000000..7b9ed55
--- /dev/null
+++ b/src/angular/animations/ripple-click.animation.directive.ts
@@ -0,0 +1,47 @@
+import { Directive, Input, HostBinding, HostListener } from "@angular/core";
+
+export enum RippleAnimationAction {
+ CLICK = 0,
+ MOUSE_ENTER = 1
+};
+
+@Directive({
+ selector: `[SdcRippleClickAnimation]`
+})
+export class RippleClickAnimationDirective {
+ private animated: boolean;
+
+ @Input() rippleClickDisabled: boolean;
+ @Input() rippleOnAction:RippleAnimationAction = RippleAnimationAction.CLICK;
+
+ @HostBinding('class.sdc-ripple-click__animated') animationClass: string;
+
+ @HostListener('click') onClick() {
+ if(this.rippleOnAction === RippleAnimationAction.CLICK){
+ this.animateStart();
+ }
+ }
+
+ @HostListener('mouseenter') onMouseEnter() {
+ //console.log("Mouseenter!", this.rippleOnAction);
+ if(this.rippleOnAction === RippleAnimationAction.MOUSE_ENTER){
+ this.animateStart();
+ }
+ }
+
+ private animateStart():void{
+ if (!this.rippleClickDisabled) {
+ this.animated = true;
+ this.animationClass = 'sdc-ripple-click__animated';
+ }
+ }
+ @HostListener('animationend') onAnimationComplete() {
+ this.animated = false;
+ this.animationClass = '';
+ }
+
+ constructor() {
+ this.rippleClickDisabled = false;
+ this.animated = false;
+ }
+}