Skip to content

Instantly share code, notes, and snippets.

@romanejaquez
Created August 18, 2020 05:02
Show Gist options
  • Save romanejaquez/1e9b81349436d70073e54bb91a0bbfbc to your computer and use it in GitHub Desktop.
Save romanejaquez/1e9b81349436d70073e54bb91a0bbfbc to your computer and use it in GitHub Desktop.
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