2.0.1 • Published 2 years ago
@solid-primitives/visibility-observer v2.0.1
@solid-primitives/visibility-observer
createPageVisibility
- Creates a signal with a boolean value identifying the page visibility stateusePageVisibility
- A shared-root alternative.
Installation
npm install @solid-primitives/visibility-observer
# or
yarn add @solid-primitives/visibility-observer
createPageVisibility
Creates a signal with a boolean value identifying the page visibility state.
How to use it
import { createPageVisibility } from "@solid-primitives/visibility-observer";
const visible = createPageVisibility();
createEffect(() => {
visible(); // => boolean
});
usePageVisibility
usePageVisibility
is a shared root primitive. It is providing the same signal as createPageVisibility
, but the event-listener and the signal are shared between dependents, making it more optimized to use in multiple places at once.
How to use it
import { usePageVisibility } from "@solid-primitives/visibility-observer";
const visible = usePageVisibility();
createEffect(() => {
visible(); // => boolean
});
Changelog
1.0.0
Initial commit of the visibility observer.
2.0.0
Rename createPageVisibilityObserver
to createPageVisibility
(no longer exported as default)
Add usePageVisibility