Created
August 18, 2020 05:02
-
-
Save romanejaquez/1e9b81349436d70073e54bb91a0bbfbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, Input } from "@angular/core"; | |
import { SplashAnimationType } from "./splash-animation-type"; | |
@Component({ | |
selector: "splash-screen", | |
templateUrl: "./splash-screen.component.html", | |
styleUrls: ["./splash-screen.component.css"] | |
}) | |
export class SplashScreenComponent implements OnInit { | |
windowWidth: string; | |
splashTransition: string; | |
opacityChange: number = 1; | |
showSplash = true; | |
@Input() animationDuration: number = 0.5; | |
@Input() duration: number = 3; | |
@Input() animationType: SplashAnimationType = SplashAnimationType.SlideLeft; | |
ngOnInit(): void { | |
setTimeout(() => { | |
let transitionStyle = ""; | |
switch (this.animationType) { | |
case SplashAnimationType.SlideLeft: | |
this.windowWidth = "-" + window.innerWidth + "px"; | |
transitionStyle = "left " + this.animationDuration + "s"; | |
break; | |
case SplashAnimationType.SlideRight: | |
this.windowWidth = window.innerWidth + "px"; | |
transitionStyle = "left " + this.animationDuration + "s"; | |
break; | |
case SplashAnimationType.FadeOut: | |
transitionStyle = "opacity " + this.animationDuration + "s"; | |
this.opacityChange = 0; | |
} | |
this.splashTransition = transitionStyle; | |
setTimeout(() => { | |
this.showSplash = !this.showSplash; | |
}, this.animationDuration * 1000); | |
}, this.duration * 1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment