1- import {
2- computed , contentChildren , ContentChildren , Directive ,
3- effect ,
4- ElementRef ,
5- inject ,
6- NgZone ,
7- PLATFORM_ID ,
8- QueryList ,
9- signal ,
10- Signal ,
11- WritableSignal
12- } from '@angular/core' ;
13- import { isPlatformBrowser } from '@angular/common' ;
14- import { ActivatedRoute } from '@angular/router' ;
15- import { Subscription } from 'rxjs' ;
1+ import { Directive , computed , contentChildren , Signal } from '@angular/core' ;
162import { ScrollAnchor } from './scroll-anchor.directive' ;
173
184@Directive ( {
@@ -21,51 +7,10 @@ import { ScrollAnchor } from './scroll-anchor.directive';
217} )
228export class ScrollContent {
239
24- // readonly isBrowser: boolean = isPlatformBrowser(inject(PLATFORM_ID));
25-
26- readonly nativeElement : HTMLElement = inject ( ElementRef ) . nativeElement ;
27-
28- // private activatedRoute: ActivatedRoute = inject(ActivatedRoute);
29-
30- // private zone: NgZone = inject(NgZone);
31-
32- // private fragmentSub$: Subscription;
33-
34- // activeId: WritableSignal<string> = signal('');
35-
3610 anchors : Signal < readonly ScrollAnchor [ ] > = contentChildren < ScrollAnchor > ( ScrollAnchor , { descendants : true } ) ;
3711
3812 anchorsTree : Signal < ScrollAnchor [ ] > = computed ( ( ) => {
3913 return this . anchors ( ) . filter ( ( anchor : ScrollAnchor ) => anchor . children . length ) ;
4014 } ) ;
4115
42- // constructor() {
43- // if (this.isBrowser) {
44- // this.zone.runOutsideAngular(() => {
45- // const intersectionObserver: IntersectionObserver = new IntersectionObserver((entries: IntersectionObserverEntry[]) => {
46- // console.log(entries)
47- // entries.forEach((entry: IntersectionObserverEntry) => {
48- // if (entry.intersectionRatio > 0) {
49- // this.zone.run(() => {
50- // this.activeId.set(entry.target.id);
51- // })
52- // }
53- // });
54- // }, {
55- // root: this.nativeElement,
56- // rootMargin: '-10% 0px -50% 0px',
57- // });
58-
59- // effect(() => {
60- // this.anchors().forEach((group: Group) => {
61- // console.log(group)
62- // intersectionObserver.observe(group.element);
63- // group.sections.forEach((section: Element) => {
64- // intersectionObserver.observe(section);
65- // });
66- // });
67- // });
68- // });
69- // }
70- // }
7116}
0 commit comments