reactjs-s4y
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

reactjs-s4y

npm version npm npm All Contributors

Installation

NPM

To install the latest stable version:

npm install --save reactjs-s4y

Basic usage:

import React, { Component } from 'react';
import Sticky from 'reactjs-s4y';

export default const App {

  return <Sticky
          containerSelectorFocus=".App"
          stickyEnableRange={[768, Infinity]}
        >
      <img
        src="https://images.unsplash.com/photo-1673169128434-90faeb36aaa3?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80"
        alt=""
    />
  </Sticky>;
}

Nextjs

  • Need to reset state and event when change page
import React, { Component } from 'react';
import Sticky from 'reactjs-s4y';
import { Router } from 'next/router';

export default const App {
  const refSticky = useRef();

  useEffect(() => {
    Router.events.on('routeChangeStart', () => {
      if (refSticky.current?.resetState) {
        refSticky.current.resetState();
      }
    });
  }, []);

  return <Sticky
          containerSelectorFocus=".App"
          stickyEnableRange={[768, Infinity]}
          ref={refSticky}
        >
      <img
        src="https://images.unsplash.com/photo-1673169128434-90faeb36aaa3?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80"
        alt=""
    />
  </Sticky>;
}

/reactjs-s4y/

    Package Sidebar

    Install

    npm i reactjs-s4y

    Weekly Downloads

    16

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    53.7 kB

    Total Files

    12

    Last publish

    Collaborators

    • hunghg255