@omnedia/ngx-starry-sky
Version:
A simple component library to create a container with an animated background.
77 lines (73 loc) • 2.66 kB
TypeScript
import * as i0 from '@angular/core';
import { AfterViewInit, OnDestroy, ElementRef } from '@angular/core';
type StarProps = {
x: number;
y: number;
radius: number;
opacity: number;
twinkleSpeed: number | null;
};
type StarBackgroundProps = {
starDensity?: number;
allStarsTwinkle?: boolean;
twinkleProbability?: number;
minTwinkleSpeed?: number;
maxTwinkleSpeed?: number;
};
type ShootingStar = {
id: number;
x: number;
y: number;
angle: number;
scale: number;
speed: number;
distance: number;
};
type ShootingStarsProps = {
minSpeed?: number;
maxSpeed?: number;
minDelay?: number;
maxDelay?: number;
starColor?: string;
trailColor?: string;
starWidth?: number;
starHeight?: number;
};
declare class NgxStarrySkyComponent implements AfterViewInit, OnDestroy {
private platformId;
canvasRef: ElementRef<HTMLCanvasElement>;
svgRef: ElementRef<HTMLOrSVGElement>;
wrapperRef: ElementRef<HTMLElement>;
styleClass?: string;
disableShootingStars: boolean;
set skyColor(color: string);
set starsBackgroundPropsValue(props: StarBackgroundProps);
private starsBackgroundProps;
set shootingStarsPropsValue(props: ShootingStarsProps);
shootingStarsProps: ShootingStarsProps;
shootingStar: i0.WritableSignal<ShootingStar | undefined>;
style: any;
private stars;
private isInView;
private isAnimating;
private animationFrameIdSky?;
private animationFrameIdShootingStar?;
private intersectionObserver?;
constructor(platformId: object);
ngAfterViewInit(): void;
ngOnDestroy(): void;
renderContents(isIntersecting: boolean): void;
private initStarSky;
private initShootingStars;
private renderStarSky;
private updateStars;
private generateStars;
private setCanvasSize;
private createShootingStar;
private moveShootingStar;
private getRandomStartPoint;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxStarrySkyComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxStarrySkyComponent, "om-starry-sky", never, { "styleClass": { "alias": "styleClass"; "required": false; }; "disableShootingStars": { "alias": "disableShootingStars"; "required": false; }; "skyColor": { "alias": "skyColor"; "required": false; }; "starsBackgroundPropsValue": { "alias": "starsBackgroundConfig"; "required": false; }; "shootingStarsPropsValue": { "alias": "shootingStarsConfig"; "required": false; }; }, {}, never, ["*"], true, never>;
}
export { NgxStarrySkyComponent };
export type { ShootingStar, ShootingStarsProps, StarBackgroundProps, StarProps };