Skip to main content
cngx-src documentation

CngxMeasure

DirectivePrimaryv0.1.0

projects/common/data/recycler/measure.directive.ts

Import#

import { CngxMeasure } from '@cngx/common/data'

Description#

Atom directive that measures the host element's height and reports it to the recycler via recycler.measure(index, element).

Uses ResizeObserver to detect height changes (e.g. content expansion, font loading). Cleanup is automatic via DestroyRef.

Also sets data-cngx-recycle-index on the host element for focus tracking.

@for (item of visibleItems(); track item.id; let i = $index) {
  <div [cngxMeasure]="recycler" [cngxMeasureIndex]="recycler.start() + i">
    {{ item.content }}
  </div>
}

https://cngxjs.github.io/cngx/examples/#/common/data/recycler/basic-list-fixed-item-height https://cngxjs.github.io/cngx/examples/#/common/data/recycler/content-visibility-css-only https://cngxjs.github.io/cngx/examples/#/common/data/recycler/infinite-scroll-recycler https://cngxjs.github.io/cngx/examples/#/common/data/recycler/scrolltoindex-deep-link https://cngxjs.github.io/cngx/examples/#/common/data/recycler/variable-heights-cngxmeasure https://cngxjs.github.io/cngx/examples/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load

Metadata#

Host#

Index#

Inputs#

cngxMeasure#CngxRecycler
input()Required

The recycler instance to report measurements to.

cngxMeasureIndex#number
input()Required

The absolute index of this item in the full dataset.

HostBindings#

BindingExpression
[attr.data-cngx-recycle-index]cngxMeasureIndex()