npm.io
2.0.1 • Published 4 years ago

@solid-primitives/visibility-observer

Licence
MIT
Version
2.0.1
Deps
1
Size
10 kB
Vulns
0
Weekly
0
Stars
1.6K
DeprecatedThis package is deprecated

Solid Primitives Visibility Observer

@solid-primitives/visibility-observer

lerna size size stage

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

Expand Changelog

1.0.0

Initial commit of the visibility observer.

2.0.0

Rename createPageVisibilityObserver to createPageVisibility (no longer exported as default)

Add usePageVisibility

Keywords