
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
@ultimate/ngx-pagevisibility
Advanced tools
🔭 @ultimate/ngx-pagevisibility Angular Directive that implements the <a href="https://developer.mozilla.or
Install via npm i @ultimate/ngx-pagevisibility
and register the NgxPageVisibilityModule
into an @NgModule
.
Check the StackBlitz demo and the example code.
Use the NgxPageVisibilityService
and subscribe to any of 3 Observable(s):
changes$
: Emits a NgxPageVisibilityState
object on every visibilitychange
eventvisible$
: Emits a NgxPageVisibilityState
object when the document is visiblehidden$
: Emits a NgxPageVisibilityState
object when the document is hiddenThe NgxPageVisibilityState
is a simple interface that describes the status of the document visibility:
export interface NgxPageVisibilityState {
visible: boolean
}
Inject the NgxPageVisibilityService
into a component and subscribe.
For the changes$
Observable it may be useful to use the state
to check if you are currently visible
or not.
The state
object is also passed on both visible$
and hidden$
for convenience.
import { NgxPageVisibilityService, NgxPageVisibilityState } from './ngx-pagevisibility.service';
@Component({...})
export class AppComponent implements OnInit {
constructor(private pageVisiblility: NgxPageVisibilityService) {}
ngOnInit() {
// fires on every `visibilitychange`
this.pageVisiblility.changes$
.subscribe((state: NgxPageVisibilityState) => console.log('Change', state.visible));
// fires each time the document is visible
this.pageVisiblility.visible$
.subscribe((state: NgxPageVisibilityState) => console.log('Visible', state.visible));
// fires each time the document is hidden
this.pageVisiblility.hidden$
.subscribe((state: NgxPageVisibilityState) => console.log('Hidden', state.visible));
}
}
Don't forget to unsubscribe
via ngOnDestroy
.
The NgxPageVisibilityDirective
can be declared on an element and listen to the same changes$
, visible$
and hidden$
events:
<div
ngxPageVisibility
(pageVisibilityChange)="onChange($event)"
(pageVisibilityVisible)="onVisible($event)"
(pageVisibilityHidden)="onHidden($event)">
</div>
You can also export the Directive and use the isVisible
boolean property:
<div
ngxPageVisibility
#pagevisibility="ngxPageVisibility">
{{ pagevisibility.isVisible ? 'Visible' : 'Hidden' }}
</div>
FAQs
🔭 @ultimate/ngx-pagevisibility Angular Directive that implements the <a href="https://developer.mozilla.or
We found that @ultimate/ngx-pagevisibility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.