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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@badahertz52/draggable-ts

v0.1.0

Published

<img src="./draggable.gif" alt="draggable-sample" width="300px" >

Downloads

4

Readme

Draggable-ts

Draggable-ts는 React와 typescript 환경에서 아이템을 드래스해서 다른 위치로 이동시키고,버튼을 통해 아이템을 다른 아이템의 앞 또는 뒤로 보내는 기능을 제공합니다.

Getting started

Installation

  npm i @badahertz52/draggable-ts

Usage

Draggable props

type SaveDataParams = {
  id: string;
  x: number;
  y: number;
  zIndex: number;
};

type DraggableProps = {
  id: string;
  children: ReactNode;
  draggableGroupRef: RefObject<HTMLDivElement>;
  x: number;
  y: number;
  zIndex?: number;
  opacity?: number;
  isBtnChanger?: boolean;
  saveData?: (props: SaveDataParams) => void;
};

| prop | 설명 | | ----------------- | ---------------------------------------------------------------------------------------------------------------- | | id | Draggable 요소의 id | | children | Draggable을 적용시킬 React Node | | draggableGroupRef | draggableGroup 은 Draggable 요소들을 감싸는, Draggable의 부모 요소로, draggableGroup을 useRef로 지정한 RefObject | | x | children의 x 좌표 | | y | children의 y 좌표 | | zIndex | children의 zIndex, 기본값: 0 | | opacity | children의 opacity , 기본값:1 | | isBtnChanger | children의 zIndex를 변경시킬 버튼의 존재 유무 | | saveData | children의 위치나 zIndex가 변경될 때 변경 사항을 parameter로 받아서 활용할 수 있는 함수 |

Structure

 draggable-group
              L draggable
                    L draggable-children
                  ....
              L draggable

⚠️ 주의 사항

draggable-group (draggable 요소들을 감싸는 부모 요소)의 width,height를 지정해야 draggable이 정상적으로 작동합니다.

Example

const App = () => {
  //....
  const draggableGroupRef = useRef<HTMLDivElement>(null);
  const saveData = (params: SaveDataParams) => {
    console.log("draggable data", params);
  };
  const draggableGroupStyle = {
    width: "500px",
    height: "500px",
  };
  const sampleStyle = {
    width: "100px",
    height: "100px",
    backgroundColor: "#fff7a5",
    textAlign: "center",
    display: "flex",
    justifyContent: "center",
    alignItems: "center",
  };
  //...
  return (
    <div
      className="draggable-group"
      ref={draggableGroupRef}
      style={draggableGroupStyle}
    >
      <Draggable
        id="drag1"
        x={100}
        y={100}
        saveData={saveData}
        draggableGroupRef={draggableGroupRef}
      >
        <div className="sample1" style={sampleStyle}>
          <div>
            <p> sample1</p>
          </div>
        </div>
      </Draggable>
      <Draggable
        id="drag2"
        x={300}
        y={600}
        zIndex={3}
        draggableGroupRef={draggableGroupRef}
      >
        <div className="sample2" style={sampleStyle}>
          <div>
            <p> sample2</p>
          </div>
        </div>
      </Draggable>
    </div>
  );
};