Skip to content

HackandCraft/Glutinum.Feliz.ReactIntersectionObserver

Repository files navigation

Glutinum.Feliz.ReactIntersectionObserver

Binding for react-intersection-observer

NuGet

Usage

Hooks

open Feliz
open Glutinum.Feliz.ReactIntersectionObserver
open type Glutinum.Feliz.ReactIntersectionObserver.Exports

[<ReactComponent>]
let IntersectionBlock () =
    let inViewInfo =
        useInView (
            IntersectionOptions(
                threshold = 0.25,
                onChange =
                    (fun inView _ ->
                        printfn "Is in view: %b" inView
                    )
            )
        )

    Html.div [
        prop.ref inViewInfo.ref
        prop.text "Intersection block"
    ]

Render Props

open Feliz
open Glutinum.Feliz.ReactIntersectionObserver
open type Glutinum.Feliz.ReactIntersectionObserver.Exports

InView [
    inView.threshold threshold
    inView.children (fun props ->
        Html.div [
            prop.ref props.ref_case1
            prop.text $"Intersection block (is in view: %b{props.inView})"
        ]
    )
]

Plain child

open Feliz
open Glutinum.Feliz.ReactIntersectionObserver
open type Glutinum.Feliz.ReactIntersectionObserver.Exports

InView [
    inView.``as`` ReactIntersectionObserverAs.div
    inView.threshold 0.25
    inView.onChange (
        fun inView _ ->
            printfn "Is in view: %b" inView
    )
    inView.children (
        Html.div [
            prop.text "Intersection block"
        ]
    )
]

About

No description, website, or topics provided.

Resources

License

Stars

4 stars

Watchers

3 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors