npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cbcruk/is-overflowing

v0.1.0

Published

엘리먼트 내용의 가로/세로 오버플로우 감지 훅

Readme

@cbcruk/is-overflowing

엘리먼트의 내용이 가로·세로로 넘치는지 감지하는 React 훅입니다.

말줄임(truncate) 처리된 텍스트에 툴팁을 붙일지처럼 "내용이 잘렸는지" 알아야 할 때 씁니다.

설치

pnpm add @cbcruk/is-overflowing react

브라우저 전용입니다. 크기와 내용 변화 감지에 ResizeObserver와 MutationObserver를 사용합니다.

사용법

import { useOverflowDetection } from '@cbcruk/is-overflowing'

function Title({ text }: { text: string }) {
  const { ref, hasHorizontalOverflow } = useOverflowDetection<HTMLDivElement>()

  return (
    <div
      ref={ref}
      className="truncate"
      title={hasHorizontalOverflow ? text : undefined}
    >
      {text}
    </div>
  )
}

API

useOverflowDetection<T extends HTMLElement = HTMLDivElement>()

OverflowDetection<T>를 반환합니다.

| Field | Type | Description | | ----------------------- | ---------------------- | ----------------------------- | | ref | RefObject<T \| null> | 감지할 엘리먼트에 연결할 ref | | hasHorizontalOverflow | boolean | scrollWidth > clientWidth | | hasVerticalOverflow | boolean | scrollHeight > clientHeight |

OverflowDetection<T>

위 반환값의 타입입니다. T의 기본값은 훅과 같은 HTMLDivElement입니다.

동작 방식

값은 렌더링 중이 아니라 커밋 직후(useLayoutEffect, 페인트 전)에 대상 엘리먼트의 scroll* / client* 크기를 측정해 state로 보관합니다. 이후 다음 경우에 다시 측정하며, 결과가 달라졌을 때만 리렌더합니다.

  • 대상 엘리먼트나 직계 자식의 크기가 바뀔 때 (ResizeObserver)
  • 대상 안의 자식 노드나 텍스트가 바뀔 때 (MutationObserver, 하위 트리 전체)
  • ref가 다른 엘리먼트에 연결되거나 해제된 뒤 리렌더될 때

제약

  • 첫 렌더링 결과는 두 값 모두 false이고, 페인트 전에 측정값으로 한 번 더 렌더링됩니다.
  • 손자 이하 노드의 크기만 바뀌고 직계 자식 크기와 DOM 내용은 그대로인 경우(스타일만 바뀌는 경우 등)는 감지하지 못할 수 있습니다.
  • ResizeObserver가 없는 환경에서는 내용 변화와 리렌더 시점에만 측정합니다.