libs/upp-wdgt/src/components/upp-visible/upp-visible.ts
A wrapper component that utilizes the VisibleDirective to detect and manage visibility changes.
It optimizes performance by detaching and reattaching Angular's change detection mechanism
based on the component's visibility.
```html
<upp-visible-control (visibilityChange)="onVisibilityChange($event)">
<p>Content inside this component will only update when visible.</p>
</upp-visible-control>```typescript
onVisibilityChange(isVisible: boolean) {
console.log('Component is visible:', isVisible);
}
AfterViewInit
| changeDetection | ChangeDetectionStrategy.OnPush |
| selector | upp-visible-control |
| templateUrl | ./upp-visible.html |
Properties |
Methods |
Outputs |
constructor(change: ChangeDetectorRef)
|
||||||||
|
Parameters :
|
| visibilityChange |
Type : EventEmitter<boolean>
|
|
Emits a boolean value whenever the component's visibility changes.
|
| ngAfterViewInit |
ngAfterViewInit()
|
|
Lifecycle hook that runs after Angular has initialized the view. It checks if the component is initially visible and detaches change detection if it is not.
Returns :
void
|
| onVisibilityChange | ||||||||
onVisibilityChange(isVisible: boolean)
|
||||||||
|
Handles visibility changes detected by the
Parameters :
Returns :
void
|
| _directive |
Type : VisibleDirective | undefined
|
Decorators :
@ViewChild(VisibleDirective)
|
<div uppVisible style="display: contents;" (visibilityChange)="onVisibilityChange($event)">
<ng-content></ng-content>
</div>