0.2.4 • Published 2 years ago

@dims/react-hooks v0.2.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

React Hooks

Just another hooks collection.

Hooks

useWindowResize

Simple addEventListener('resize') hook.

function MyComponent() {
  useWindowResize(
    () => {
      console.log("resized");
    },
    true,
    50,
  );
}

useSmoothScroll

Cross-browser smooth scrolling.

function MyComponent() {
  const smooth = useSmoothScroll();

  return (
    <button
      onClick={() => {
        smooth.scrollTo(0, 200, () => {
          console.log("end");
        });
      }}
    >
      Scroll down 200px
    </button>
  );
}

useTruncateLines

Truncated text to specific number of lines.

function MyComponent() {
  const truncate = useTruncateLines({ lines: 2 });

  return (
    <div
      ref={(node) => {
        truncate(node, "Some very long text...");
      }}
    />
  );
}
0.2.1

2 years ago

0.2.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.4

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago