0.2.4 • Published 8 months ago

@dims/react-hooks v0.2.4

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months 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

8 months ago

0.2.0

8 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.2.4

8 months ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago