chore: copia de libs/shared con prefijo Pi y APIs de terceros actualizadas

This commit is contained in:
2026-07-27 21:14:48 +02:00
parent 0758b00d54
commit 771d83c0aa
672 changed files with 47352 additions and 4692 deletions

View File

@@ -0,0 +1,5 @@
export * from './scroll-to.module';
export * from './scroll-to.directive';
export * from './scroll-to.service';

View File

@@ -0,0 +1,15 @@
import {
Directive,
HostBinding
} from '@angular/core';
@Directive({
standalone: false,
selector: '[pi-scroll-to-element]',
})
export class PiScrollToElementDirective {
@HostBinding('class') get classes(): string {
return 'pi-scroll-to pi-scroll-to__element';
}
}

View File

@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PiScrollToElementDirective } from './scroll-to.directive';
import { PiSharedUtilScrollService } from './scroll-to.service';
@NgModule({
imports: [CommonModule],
declarations: [PiScrollToElementDirective],
exports: [PiScrollToElementDirective],
providers: [PiSharedUtilScrollService],
})
export class PiSharedUtilScrollToModule {}

View File

@@ -0,0 +1,43 @@
import { ElementRef, Injectable, QueryList } from '@angular/core';
@Injectable()
export class PiSharedUtilScrollService {
scrollToNextElement(elements: QueryList<ElementRef>): void {
for (let i = 0; i <= elements.length; i++) {
const element: ElementRef = elements.toArray()[i];
if (this.isScrolledToBottom()) {
this.scrollToTop();
break;
}
if (i === elements.length) {
this.scrollToBottom();
break;
}
if (this.isElementInView(element.nativeElement)) {
element.nativeElement.scrollIntoView({ behavior: 'smooth' });
break;
}
this.scrollToTop();
}
}
isElementInView(element: Element): boolean {
const rect = element.getBoundingClientRect();
return rect.top > 40;
}
scrollToTop(): void {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
scrollToBottom(): void {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
}
isScrolledToBottom(): boolean {
const documentHeight = document.body.scrollHeight;
const currentScroll = window.scrollY + window.innerHeight;
return documentHeight <= currentScroll;
}
}