# @embedpdf/angular — ./anchored AnchorTarget [InterfaceDeclaration] (from packages/framework/web/src/anchored-position.ts): export interface AnchorTarget{ page: PageRef; bounds: AnchoredRect; boundsIn?: (view: PageViewEnv) => AnchoredRect | null; avoid?: AnchoredPoint[]; } AnchoredPlacement [TypeAliasDeclaration] (from packages/framework/web/src/anchored-position.ts): export type AnchoredPlacement = AnchoredSide | `${ AnchoredSide} -${ 'start' | 'end'} `; AnchoredSide [TypeAliasDeclaration] (from packages/framework/web/src/anchored-position.ts): export type AnchoredSide = 'top' | 'right' | 'bottom' | 'left'; EPDF_PROJECTOR [VariableDeclaration] (from packages/framework/angular/anchored/src/anchored.ts): EPDF_PROJECTOR = new InjectionToken('EPDF_PROJECTOR') EpdfAnchor [TypeAliasDeclaration] (from packages/framework/angular/anchored/src/anchored.ts): export type EpdfAnchor = Omit &{ bounds?: AnchoredRect | null} ; EpdfAnchored [ClassDeclaration] (from packages/framework/angular/anchored/src/anchored.ts): @Component({ selector: 'epdf-anchored', changeDetection: ChangeDetectionStrategy.OnPush, host:{ style: 'display: contents'} , template: ` @if (position(); as position){
} `, } ) export class EpdfAnchored{ readonly anchor = input(null); readonly placement = input('top'); readonly gap = input(8); readonly pinned = input(false, { transform: booleanAttribute} ); private readonly binding: EpdfProjectorBinding; private readonly fit = signal(null); private readonly moved = signal(0); private readonly box = viewChild>('box'); protected readonly space = computed(() => this.binding.projector()?.space ?? 'overlay'); private readonly onShownPage = computed(() =>{ const anchor = this.anchor(); if (!anchor?.bounds) return false; const shown = this.binding.shownPages(); return !shown || shown.has(anchor.page.objectNumber); } ); protected readonly position = computed(() =>{ if (!this.onShownPage()) return null; this.binding.revision(); this.moved(); const projector = this.binding.projector(); const anchor = this.anchor(); if (!projector || !anchor?.bounds) return null; return projectAnchoredTarget( projector, { ...anchor, bounds: anchor.bounds} , { placement: this.placement(), gap: this.gap(), pinned: this.pinned()} , this.fit(), ); } ); constructor(){ const binding = inject(EPDF_PROJECTOR, { optional: true} ); if (!binding) throw outsideStageError(''); this.binding = binding; const injector = inject(Injector); if (binding.subscribe){ const subscribe = binding.subscribe; effect((onCleanup) =>{ if (!this.onShownPage()) return; onCleanup(subscribe(() => this.moved.update((count) => count + 1))); } ); } effect(() =>{ if (this.space() !== 'client' || !this.anchor()) return; afterNextRender(() => this.moved.update((count) => count + 1), { injector} ); } ); effect((onCleanup) =>{ const element = this.box()?.nativeElement; if (!element) return; const space = this.space(); onCleanup( observeAnchoredFit(element, space, (next) =>{ if (!sameAnchoredFit(untracked(this.fit), next)) this.fit.set(next); } ), ); } ); } } EpdfProjectorBinding [InterfaceDeclaration] (from packages/framework/angular/anchored/src/anchored.ts): export interface EpdfProjectorBinding{ readonly projector: Signal; readonly revision: Signal; readonly shownPages: Signal | null>; readonly subscribe?: (callback: () => void) => () => void; } PageViewEnv [InterfaceDeclaration] (from packages/framework/web/src/anchored-position.ts): export interface PageViewEnv{ scale: number; rotation: 0 | 90 | 180 | 270; zoom: number; } ViewProjector [InterfaceDeclaration] (from packages/framework/web/src/anchored-position.ts): export interface ViewProjector{ space: 'overlay' | 'client'; toScreen(page: PageRef, rect: AnchoredRect): AnchoredRect | null; toScreenPoint(page: PageRef, at: AnchoredPoint): AnchoredPoint | null; viewEnv(page: PageRef): PageViewEnv | null; view(): AnchoredRect | null; }