2.0.1 • Published 2 years ago

@solid-primitives/visibility-observer v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@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

1.0.0

Initial commit of the visibility observer.

2.0.0

Rename createPageVisibilityObserver to createPageVisibility (no longer exported as default)

Add usePageVisibility