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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@h_tudou/test-tudou

v1.0.1

Published

A lightweight SVG component with drag and resize functionality

Readme

SVG Draggable Component

一个轻量级的 SVG 拖拽和调整大小组件,无需任何依赖。

A lightweight SVG component with drag and resize functionality, zero dependencies.

特性 Features

  • ✨ 可拖拽 SVG 元素 / Draggable SVG elements
  • 🔧 可调整大小 / Resizable functionality
  • 🎯 零依赖 / Zero dependencies
  • 📦 轻量级 / Lightweight
  • 🚀 易于使用 / Easy to use

安装 Installation

npm install @yourname/testTudou

或者使用 yarn / Or use yarn:

yarn add @yourname/testTudou

使用方法 Usage

基本使用 Basic Usage

import SvgDraggableComponent from "@yourname/testTudou";

// 创建实例 / Create instance
const component = new SvgDraggableComponent();

// 挂载到DOM / Mount to DOM
component.mount("#app");

使用 HTML

<!DOCTYPE html>
<html>
  <head>
    <title>SVG Draggable Component Demo</title>
  </head>
  <body>
    <div id="app"></div>

    <script type="module">
      import SvgDraggableComponent from "./node_modules/@yourname/testTudou/src/index.js";

      const component = new SvgDraggableComponent({
        width: 800,
        height: 600,
        rectFill: "lightblue",
      });

      component.mount("#app");
    </script>
  </body>
</html>

CommonJS

const SvgDraggableComponent = require("@yourname/testTudou");

const component = new SvgDraggableComponent();
component.mount(document.body);

配置选项 Options

const component = new SvgDraggableComponent({
  width: 800, // SVG宽度 / SVG width
  height: 600, // SVG高度 / SVG height
  rectX: 10, // 矩形X坐标 / Rectangle X position
  rectY: 10, // 矩形Y坐标 / Rectangle Y position
  rectWidth: 200, // 矩形宽度 / Rectangle width
  rectHeight: 100, // 矩形高度 / Rectangle height
  rectFill: "yellow", // 矩形填充色 / Rectangle fill color
  rectStroke: "black", // 矩形边框色 / Rectangle stroke color
  compX: 100, // 组件X坐标 / Component X position
  compY: 100, // 组件Y坐标 / Component Y position
  showBorder: true, // 显示边框 / Show border
});

API

constructor(options)

创建一个新的 SVG 可拖拽组件实例。

Create a new SVG draggable component instance.

参数 Parameters:

  • options (Object): 配置选项 / Configuration options

mount(container)

将组件挂载到指定容器。

Mount the component to a container.

参数 Parameters:

  • container (HTMLElement | string): DOM 元素或选择器字符串 / DOM element or selector string

示例 Example:

component.mount("#app");
// or
component.mount(document.getElementById("app"));

destroy()

销毁组件并清理事件监听器。

Destroy the component and cleanup event listeners.

示例 Example:

component.destroy();

浏览器支持 Browser Support

支持所有现代浏览器 / Supports all modern browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

开发 Development

# 克隆仓库 / Clone repository
git clone https://github.com/yourname/svg-draggable-component.git

# 安装依赖 / Install dependencies
cd svg-draggable-component
npm install

# 构建 / Build
npm run build

示例 Examples

查看 example.html 文件获取完整示例。

See example.html for a complete example.

许可证 License

MIT

作者 Author

Your Name

贡献 Contributing

欢迎提交 Issue 和 Pull Request!

Issues and Pull Requests are welcome!