1.0.9 • Published 3 years ago

react-sticky-puzzle v1.0.9

Weekly downloads
18
License
MIT
Repository
github
Last release
3 years ago

REACT-STICKY-PUZZLE

Library to place the items you want on top in a sticky sequential way.

Demo

Installation

$ npm i react-sticky-puzzle
$ yarn add react-sticky-puzzle

Overview code

An easy way to integrate.

import React from "react";
import ReactStickyPuzzle, { StickyPuzzleItem } from "react-sticky-puzzle";

function App() {
  return (
    <ReactStickyPuzzle>
      <StickyPuzzleItem styleSticky={{
        backgroundColor: "red"
      }}>
       ...
      </StickyPuzzleItem>
      <StickyPuzzleItem>
       ...
      </StickyPuzzleItem>
    </ReactStickyPuzzle>
  );
}

export default App;

Adapt component to scroll container

import ReactStickyPuzzle, { StickyPuzzleItem } from "react-sticky-puzzle";

function App() {
  return (
    <div style={{
        width:"300px",
        height:"400px",
        overflowY: "scroll",
        background:"rgba(200,200,255)",
        margin:"auto"
      }}>
      <ReactStickyPuzzle inElement>
        <StickyPuzzleItem>
        ...
        </StickyPuzzleItem>
        <StickyPuzzleItem>
        ...
        </StickyPuzzleItem>
      </ReactStickyPuzzle>
    </div>
  );
}

export default App;

ReactStickyPuzzle

This component is the main one to encapsulate all the child components. Components that are inside a StickyPuzzle component will be affected in order to have a position in the header.

propertydescriptiontype
onFixedEmit an event when an item is in fixed positionevent
inElementAdapt container to element with scrollboolean

StickyPuzzleItem

Component that will be affected by being inside the ReactStickyPuzzle component. These components will be positioned in the header firmly one below the other. You can customize the styles to your way when you are in fixed position on header.

propertydescriptiontype
styleStickySet style to component when the position is stickystyle
1.0.9

3 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago