MCPcopy Create free account
hub / github.com/angular/angular / ɵɵdeferOnViewport

Function ɵɵdeferOnViewport

packages/core/src/defer/instructions.ts:761–801  ·  view source on GitHub ↗
(
  triggerIndex: number,
  walkUpTimes?: number | null,
  options?: IntersectionObserverInit,
)

Source from the content-addressed store, hash-verified

759 * @codeGenApi
760 */
761export function ɵɵdeferOnViewport(
762 triggerIndex: number,
763 walkUpTimes?: number | null,
764 options?: IntersectionObserverInit,
765) {
766 const lView = getLView();
767 const tNode = getCurrentTNode()!;
768
769 if (ngDevMode) {
770 const args: string[] = [];
771 if (walkUpTimes !== undefined && walkUpTimes !== -1) {
772 args.push('<target>');
773 }
774 if (options) {
775 args.push(JSON.stringify(options));
776 }
777 trackTriggerForDebugging(
778 lView[TVIEW],
779 tNode,
780 `on viewport${args.length === 0 ? '' : `(${args.join(', ')})`}`,
781 );
782 }
783
784 if (!shouldAttachTrigger(TriggerType.Regular, lView, tNode)) return;
785
786 renderPlaceholder(lView, tNode);
787
788 // Avoid adding event listeners when this instruction is invoked on the server.
789 if (!(typeof ngServerMode !== 'undefined' && ngServerMode)) {
790 registerDomTrigger(
791 lView,
792 tNode,
793 triggerIndex,
794 walkUpTimes,
795 onViewportWrapper,
796 () => triggerDeferBlock(TriggerType.Regular, lView, tNode),
797 TriggerType.Regular,
798 options,
799 );
800 }
801}
802
803/**
804 * Creates runtime data structures for the `prefetch on viewport` deferred trigger.

Callers

nothing calls this directly

Calls 9

getLViewFunction · 0.90
getCurrentTNodeFunction · 0.90
trackTriggerForDebuggingFunction · 0.90
shouldAttachTriggerFunction · 0.90
renderPlaceholderFunction · 0.90
registerDomTriggerFunction · 0.90
triggerDeferBlockFunction · 0.90
joinMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected