1.3.4 ā€¢ Published 10 months ago

use-in-screen v1.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

use-in-screen

hook to know if a element is on the screen

    import useInScreen from "use-in-screen";


    const isInViewport = useInScreen(element);

With REACT āš› !!!

    import React, { useState, useRef } from "react"
    import useInScreen from "use-in-screen";

    function MyComponent() {

        const element = useRef(null)

        const isInViewport = useInScreen(element);

        return (
            <div ref={element}>
                this div {isInViewport ? "is" : "is not"} on screen
            </div>
        )

    }

Parameters

  • element could be ref or current (domHTML)
  • onlyOnce if only can happen once
  • dividend if you want it to come out with a few pixels before based on a parameter to divide the screen

šŸ™Œ Good luck out there my friend šŸ™Œ

1.3.4

10 months ago

1.2.4

10 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

1 year ago

1.1.1

1 year ago