libs/upp-wdgt/src/directives/upp-visible.ts
Emits an event when the visibility state changes.
This directive is useful for optimizing performance by triggering events or computations only when the element is visible.
Example :```html
<div uppVisible (visibilityChange)="onVisibilityChange($event)">
Observed Content
</div>```typescript
onVisibilityChange(isVisible: boolean) {
console.log('Element is visible:', isVisible);
}
AfterViewInit
OnDestroy
| Selector | [uppVisible] |
Methods |
Inputs |
Outputs |
Accessors |
constructor(elementRef: ElementRef)
|
||||||||
|
Parameters :
|
| threshold |
Type : number
|
Default value : 0.1
|
| visibilityChange |
Type : EventEmitter<boolean>
|
| ngAfterViewInit |
ngAfterViewInit()
|
|
If the element is visible upon initialization, it updates the state accordingly.
Returns :
void
|
| ngOnDestroy |
ngOnDestroy()
|
|
Prevents memory leaks by ensuring the observer is properly disposed of.
Returns :
void
|
| isVisible |
getisVisible()
|
|
Returns :
boolean
|