1.5.5-beta • Published 3 years ago

react-dnz v1.5.5-beta

Weekly downloads
40
License
MIT
Repository
github
Last release
3 years ago

a drag and scale component for react

如何使用

首先,下载代码后进入项目根目录安装依赖包

$ cd <appName>
$ npm install

然后启动开发环境

$ npm start

打包编译

$ npm run build-es

Dragzoom

propsDescriptionTypeDefault
img背景图urlstring(svg格式的需要传入经过base64编码后的dataUrl)''
styledragzoom第一层div的样式HTMLStyleElement{}
maxZoom最大缩放层级number2
scaleable是否可以缩放booleantrue
draggable图层是否可以拖动booleantrue
onSizeChange图层大小变化时的回调(props, changed, all): voidNOOP
onDrag图层拖动时的回调(Position): void-
onDragStop图层拖动结束时的回调(Position): Object-
polygonDragDisabled禁用自定义图层的拖动booleantrue
onPolygonDragStop自定义图层停止拖动的回调(context:CanvasRenderingContext2D ,props:{id:string,path:Path}) => mixed-
controlPaint控制自定义图层的绘画(context:CanvasRenderingContext2D ,props:{id:string,path:Path}) => mixed-
dragControlPaint控制拖拽时自定义图层的绘画String-
getSVGSize获取svg格式的背景图的实际大小(size: { width: number, height: number }) => mixed-
allowAnyClickToDrag是否允许任意键拖动booleanfalse
fixContent(实例方法)自适应弹出框内容(x,y为左上角定位)(position: { x: number, y: number, width: number, height: number, offset: { top: number, left: number } }, placement: 'top' ¦ 'left' ¦ 'right' ¦ 'bottom' ¦ 'topLeft' ¦ 'topRight' ¦ 'bottomLeft' ¦ 'bottomRight' ¦ 'leftTop' ¦ 'leftBottom' ¦ 'rightTop' ¦ 'rightBottom')

DragzoomPolygon

propsDescriptionTypeDefault
capture是否捕获坐标booleanfalse
capturePosition捕获坐标函数(a:number,number) => mixed(a:number,number) => null
allowAnyClick是否响应右键或中键点击事件booleantrue
capturePosition捕获点击事件(position: { x: number, y: number }, event) => null() => null
startMove鼠标移动开始事件(position: { x: number, y: number }, event) => null() => null
stopMove鼠标移动结束事件(position: { x: number, y: number }, event) => null() => null

DragzoomPolygon.Polygon

propsDescriptionTypeDefault
path自定义图层的路径Array<number,number>[]
polygonDrag是否能拖动booleanfalse

DragzoomItems

propsDescriptionTypeDefault
pointsDisabled所有点位能否拖动booleanfalse
onDrag点位拖动时的回调(point: Point) => mixed(point: Point) => mixed
onDragStop点位拖动结束时的回调(point: Point) => mixed(point: Point) => mixed

DragzoomItem

propsDescriptionTypeDefault
id点位idbooleanfalse
children子项React.Nodenull
disabled是否禁用拖动booleanfalse
capture是否捕获坐标booleanfalse
allowAnyClickToDrag是否允许任意键拖动booleanfalse
capturePosition捕获坐标函数(a:number,number) => mixed(a:number,number) => null

#V2 import { V2 } from 'react-dnz';

DragZoom

propsDescriptionTypeDefault
img背景图urlstring''
style容器样式HTMLStyleElement{}
maxScale最大缩放层级number2
scalable是否可以缩放booleantrue
draggable图层是否可以拖动booleantrue
onSizeChange图层大小变化时的回调,包括图片路径变更(e:Event, position: {x: number, y: number }) => nullNOOP
onDragStop图层拖动结束时的回调(e:Event, position: {x: number, y: number }) => null-
allowAnyClick是否允许任意键拖动booleanfalse
fixContent(实例方法)自适应弹出框内容(x,y为左上角定位)(position: { x: number, y: number, width: number, height: number, offset: { top: number, left: number } }, placement: 'top' ¦ 'left' ¦ 'right' ¦ 'bottom' ¦ 'topLeft' ¦ 'topRight' ¦ 'bottomLeft' ¦ 'bottomRight' ¦ 'leftTop' ¦ 'leftBottom' ¦ 'rightTop' ¦ 'rightBottom')

DragZoomPolygon

(处于性能考虑,此处尽量统一样式,并且剥离绘制捕获内容至单独组件)

propsDescriptionTypeDefault
style容器样式HTMLStyleElement{}
controlPaint图层自定义绘制方法, 返回false则采用默认绘制方法(context:CanvasRenderingContext2D ,props:{id:string,path:Path,color:Object,shape:string}) => boolean() => false
pathStyle路径填充样式{ strokeStyle: string,fillStyle: string,lineWidth: string }{fillStyle: 'rgba(0, 132, 255, 0.2)',strokeStyle: '#4C98FF',lineWidth: 2,}
vertexStyle端点填充样式{ strokeStyle: string,fillStyle: string,lineWidth: string }{fillStyle: 'rgb(255,255,255)',strokeStyle: 'green',lineWidth: 3,}
polygons自定义图层Polygon[]

DragZoomPolygon.Polygon

propsDescriptionTypeDefault
path自定义图层的路径Array<number,number>[]
id唯一标识string''
color图层颜色Object{}
shape形状string''
custom是否自定义绘制booleanfalse
vertex是否绘制端点booleantrue
dash虚线分段数据,形如5,10, 代表虚线长度为5,间隔为10string''

DragZoomItems

propsDescriptionTypeDefault
style容器样式HTMLStyleElement{}
onDrag拖动时的回调(id: string, position: Position, e: Event) => null(point: Point) => mixed
onDragStop拖动结束时的回调(id: string, position: Position, e: Event) => null(point: Point) => mixed

DragZoomItem

propsDescriptionTypeDefault
id点位idbooleanfalse
children子项React.Nodenull
disabled是否禁用拖动booleantrue
position定位坐标{x: number, y: number}{x: 0, y: 0}
offset偏移量{ left: number, top: number }{left: 0, top: 0}

DragZoomCanvas(该组件用于绘制变化部分,所有路径都会被自定义绘制)

propsDescriptionTypeDefault
capture捕获坐标booleanfalse
onMouseMove鼠标移动(position: Position, e: Event) => nullf => f
onDoubleClick双击事件(position: Position, e: Event) => nullf => f
onClick单击事件(position: Position, e: Event) => nullf => f
controlPaint偏移量(context:CanvasRenderingContext2D ,props:{id:string,path:Path,color:string,shape:string}) => mixedf => f

DragZoomCanvas.Path

详见 DragZoomPolygon.Polygon

1.5.5-beta

3 years ago

1.5.4-beta

4 years ago

1.5.3-beta

4 years ago

1.5.2-beta

4 years ago

1.5.1-beta

5 years ago

1.5.0-beta

5 years ago

1.4.13-beta

5 years ago

1.4.12-beta

5 years ago

1.4.11-beta

5 years ago

1.4.10-beta

5 years ago

1.4.9-beta

5 years ago

1.4.8-beta

5 years ago

1.4.7-beta

5 years ago

1.4.6-beta

5 years ago

1.4.5-beta

5 years ago

1.4.4-beta

5 years ago

1.4.3-beta

5 years ago

1.4.2-beta

5 years ago

1.4.1-beta

5 years ago

1.4.0-beta

5 years ago

2.0.2-beta

5 years ago

2.0.1-beta

5 years ago

2.0.0-beta

5 years ago

2.0.0

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago