sparklier sparkles

This commit is contained in:
Mononaut 2024-08-11 20:52:26 +00:00
parent b8cfeb579b
commit 021f0b32a1
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E

View File

@ -41,23 +41,25 @@ export class AccelerationSparklesComponent implements OnChanges {
doSparkle(): void { doSparkle(): void {
if (this.run) { if (this.run) {
const now = performance.now(); const now = performance.now();
if (now - this.lastSparkle > 30) { if (now - this.lastSparkle > 20) {
this.lastSparkle = now; this.lastSparkle = now;
if (this.arrow?.nativeElement && this.sparkleAnchor?.nativeElement) { if (this.arrow?.nativeElement && this.sparkleAnchor?.nativeElement) {
const anchor = this.sparkleAnchor.nativeElement.getBoundingClientRect().right; const anchor = this.sparkleAnchor.nativeElement.getBoundingClientRect().right;
const right = this.arrow.nativeElement.getBoundingClientRect().right; const right = this.arrow.nativeElement.getBoundingClientRect().right;
const dx = (anchor - right) + 37.5; const dx = (anchor - right) + 30;
this.sparkles.push({ const numSparkles = Math.ceil(Math.random() * 3);
style: { for (let i = 0; i < numSparkles; i++) {
right: dx + 'px', this.sparkles.push({
top: (Math.random() * 30) + 'px', style: {
animationDelay: (Math.random() * 50) + 'ms', right: (dx + (Math.random() * 10)) + 'px',
}, top: (15 + (Math.random() * 30)) + 'px',
rotation: { },
transform: `rotate(${Math.random() * 360}deg)`, rotation: {
} transform: `rotate(${Math.random() * 360}deg)`,
}); }
while (this.sparkles.length > 100) { });
}
while (this.sparkles.length > 200) {
this.sparkles.shift(); this.sparkles.shift();
} }
this.cd.markForCheck(); this.cd.markForCheck();