All Projects → lessp → bs-react-is-visible

lessp / bs-react-is-visible

Licence: MIT License
A small library that lets you know whether a component is visible on screen or not.

Programming Languages

reason
219 projects

Projects that are alternatives of or similar to bs-react-is-visible

reason-hooks-testing-library
ReasonML bindings for react-hooks-testing-library
Stars: ✭ 24 (+60%)
Mutual labels:  reasonml, reason-react
LifeTime
LifeTime app
Stars: ✭ 35 (+133.33%)
Mutual labels:  reasonml, reason-react
react-intersection-observer-hook
React hook to use IntersectionObserver declaratively
Stars: ✭ 58 (+286.67%)
Mutual labels:  visibility, intersection-observer
react-multiversal
React components that works everywhere (iOS, Android, Web, Node)
Stars: ✭ 43 (+186.67%)
Mutual labels:  reasonml, reason-react
qnd
Quick and Dirty development builds
Stars: ✭ 19 (+26.67%)
Mutual labels:  reasonml, reason-react
re-use
⚛️ 🎣 A collection of hooks for ReasonReact
Stars: ✭ 27 (+80%)
Mutual labels:  reasonml, reason-react
reason-react-lazy-loading
Example project to show how to use components lazy loading in ReasonReact
Stars: ✭ 41 (+173.33%)
Mutual labels:  reasonml, reason-react
Reason Graphql Fullstack
Fullstack Reason + GraphQL Todo List App
Stars: ✭ 246 (+1540%)
Mutual labels:  reasonml, reason-react
onetricks.net
(WIP) kayn-powered (typescript node.js) ReasonReact app presenting you a dashboard of high ELO one trick ponies in League of Legends
Stars: ✭ 13 (-13.33%)
Mutual labels:  reasonml, reason-react
reason-catstagram
🐈 Catstagram made with ReasonReact!
Stars: ✭ 31 (+106.67%)
Mutual labels:  reasonml, reason-react
bs-rsuite-ui-react
Reason bindings for React Suite UI library
Stars: ✭ 26 (+73.33%)
Mutual labels:  reasonml, reason-react
timerlab
⏰ A simple and customizable timer
Stars: ✭ 94 (+526.67%)
Mutual labels:  reasonml, reason-react
app-template-rescript-react
Adding ReScript with rescript-react on top of @snowpack/app-template-react
Stars: ✭ 44 (+193.33%)
Mutual labels:  reasonml, reason-react
re-typescript
An opinionated attempt at finally solving typescript interop for ReasonML / OCaml.
Stars: ✭ 68 (+353.33%)
Mutual labels:  reasonml, reason-react
React Intersection Observer
React implementation of the Intersection Observer API to tell you when an element enters or leaves the viewport.
Stars: ✭ 2,689 (+17826.67%)
Mutual labels:  visibility, intersection-observer
re-cite
Manage citations from your colleagues , friends, movies, your cat or even yourself.
Stars: ✭ 20 (+33.33%)
Mutual labels:  reasonml, reason-react
Bs Material Ui
ReScript bindings for material-ui
Stars: ✭ 185 (+1133.33%)
Mutual labels:  reasonml, reason-react
Rescript Relay
Use Relay with ReasonML.
Stars: ✭ 214 (+1326.67%)
Mutual labels:  reasonml, reason-react
Reason-react-hooks
🧶 Some hooks in ReasonML for reason-react that can be useful
Stars: ✭ 14 (-6.67%)
Mutual labels:  reasonml, reason-react
dokusho
Simple Japanese reading stats tracker
Stars: ✭ 12 (-20%)
Mutual labels:  reasonml, reason-react

React Is Visible for ReasonReact

Actions Status npm version

A small library that lets you know whether a component is visible on screen or not.

Uses the IntersectionObserver API which you may want to polyfill.

This is a semi-port of my React-library react-is-visible for ReasonReact.

Live Examples

https://lessp.github.io/bs-react-is-visible/

Installation

npm install bs-react-is-visible

Add bs-react-is-visible to bs-dependencies in bsconfig.json

Usage

Basic

[@react.component]
let make = () => {
  let (isVisible, ref) = ReactIsVisible.useIsVisible();

  <h1 ref>
    {(isVisible ? "I'm visible!" : "I'm not visible") |> React.string}
  </h1>;
};

With options

[@react.component]
let make = () => {
  let (isVisible, ref) = ReactIsVisible.useIsVisible(~options={once: true}, ());

  <h1 ref>
    {(isVisible ? "I'm triggered as visible once!" : "I'm not visible") |> React.string}
  </h1>;
};

Polyfill

Browser compatibility.

In order to polyfill, install the polyfill from W3C

npm install intersection-observer --save

... and import it somewhere before using ReactIsVisible

The easiest way would be by doing something like:

// App.re
[%bs.raw {| require("intersection-observer") |}];

[@react.component]
// ...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].