New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-es-drager

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-es-drager

A draggable, resizable, rotatable component based on react

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

Rect Es Drager 拖拽组件

Rect Es Drager
DraggableResizableRotatable

🌈介绍

基于 react18 + typescript + vite 的可拖拽、缩放、旋转的组件

  • 拖拽&区域拖拽
  • 支持缩放
  • 旋转
  • 网格拖拽缩放
  • 拖拽编辑器

运行项目

# 拉取项目
git clone https://github.com/kakajun/react-es-drager.git

# 安装依赖
pnpm install

# 运行项目
pnpm dev

# 打包drager组件
pnpm build

# 打包文档
pnpm build:demo

主要目录介绍

目录功能说明
packages/docs项目示例文档、编辑器展示
packages/editor编辑器核心代码
packages/drageres-drager组件

综合案例

下面是基于 react-es-drager 实现的一个简单可视化拖拽编辑器

ES Drager Editor

相关文章

可拖拽、缩放、旋转组件实现细节

网格效果及使用方法

辅助线和撤销回退

元素组合与拆分

菜单操作栏、json数据导入导出

⚡ 使用说明

安装依赖

npm i react-es-drager -D

组件中直接使用

import Drager from 'react-es-drager'
const dragList = []
const BasicComponent = () => {
  return (
    <>
      {dragList.map((list, index) =>
        list.map((item, index2) => (
          <Drager
            key={`${index}-${index2}`}
            width={100}
            height={100}
            left={index2 * 150 + 30}
            top={index * 150 + 30}
            {...item}
            style={{ color: item.color }}
          >
            {item.text}
          </Drager>
        ))
      )}
    </>
  )
}

export default BasicComponent

Drager API

Drager 属性

属性名说明类型默认
tagcomponent组件的标签属性^[string]div
type类型,rect, text, image^[string]rect
defaultSize默认值object{width: 100, height: 100, left: 0, top: 0, angle: 0 }
size外部传入属性值object(内部属性同上)-
color颜色^[string]#3a7afe
resizable是否可缩放^[boolean]true
rotatable是否可旋转^[boolean]-
boundary是否判断边界(最近定位父节点,考虑性能谨慎使用)^[boolean]-
disabled是否禁用^[boolean]-
minWidth最小宽度^[number]1
minHeight最小高度^[number]1
maxWidth最大宽度^[number]9999
maxHeight最大高度^[number]9999
selected控制是否选中^[boolean]-
checkCollision是否开启碰撞检测^[boolean]-
snapToGrid开启网格^[boolean]-
gridX网格X大小^[number]50
gridY网格Y大小^[number]50
snap开启吸附^[boolean]-
snapThreshold吸附阈值^[number]10
markline辅助线[可自定义](demo markline)^[boolean]^[Function]-
extraLines添加除了es-drager元素以外的对齐线,例如添加中心点对齐([可参考](demo markline))^[Function]
scaleRatio缩放比^[number]1
disabledKeyEvent禁用方向键移动^[boolean]-
border是否显示边框^[boolean]true
aspectRatio宽高缩放比^[number]-
equalProportion宽高等比缩放(该属性和aspectRatio互斥,同时使用会存在问题)^[boolean]-
resizeList显示的缩放handle列表,top, bottom, left, right, top-left, top-right, bottom-left, bottom-right^[string[]]-

Drager 事件

事件名说明类型
onChange位置、大小改变^[Function](dragData) => void
onDrag拖拽中^[Function](dragData) => void
onDragStart拖拽开始^[Function](dragData) => void
onDragEnd拖拽结束^[Function](dragData) => void
onResize缩放中^[Function](dragData) => void
onResizeStart缩放开始^[Function](dragData) => void
onResizeEnd缩放结束^[Function](dragData) => void
onRotate旋转中^[Function](dragData) => void
onRotateStart旋转开始^[Function](dragData) => void
onRotateEnd旋转结束^[Function](dragData) => void
onFocus获取焦点/选中^[Function](selected) => void
onBlur失去焦点/非选中^[Function](selected) => void
  • dragData 类型
export type DragData = {
  width: number
  height: number
  left: number
  top: number
  angle: number
}

Drager 插槽

插槽名说明
default自定义默认内容
resize缩放handle
rotate旋转handle

引用

本工程属于经原创同意,vue转react项目, 引用自es-drager, 本项目将会长期更新, 欢迎issue和pr

Keywords

drag

FAQs

Package last updated on 13 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts