@aaronhayes/react-scroll-hook 中文文档教程

发布于 5年前 浏览 23 项目主页 更新于 3年前

React Scroll Hook

npm (scoped)Bundle SizeLicense

使用 React Scroll

Install

$ npm install --save @aaronhayes/react-scroll-hook
$ yarn add @aaronhayes/react-scroll-hook

Usage

import { Link, Element , Events, animateScroll as scroll, scrollSpy, scroller } from 'react-scroll'


import useScrollSpy from '@aaronhayes/react-scroll-hook';

const MyScrollWatchingComponent = () => {
    const location = useScrollSpy();
    console.log(location);
    // Location will either be undefined or the current element scrolled to.

    return (
        <div>
            <h1>
                You are currently scrolled to: {location}
            </h1>
        </div>
    )
}

See Also

React Scroll Hook

npm (scoped)Bundle SizeLicense

Hook for watching vertical scrolling location when using React Scroll

Install

$ npm install --save @aaronhayes/react-scroll-hook
$ yarn add @aaronhayes/react-scroll-hook

Usage

import { Link, Element , Events, animateScroll as scroll, scrollSpy, scroller } from 'react-scroll'


import useScrollSpy from '@aaronhayes/react-scroll-hook';

const MyScrollWatchingComponent = () => {
    const location = useScrollSpy();
    console.log(location);
    // Location will either be undefined or the current element scrolled to.

    return (
        <div>
            <h1>
                You are currently scrolled to: {location}
            </h1>
        </div>
    )
}

See Also

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文