1.3.1 • Published 6 years ago

image-drag v1.3.1

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

image-drag

图片拖拽缩放组件

NPM

NPM

Example

import React from 'react';
import ImageDrag from 'image-drag';

class Image extends React.Component {
  state = {
    isShow: false,
    isUse: true,
  }
  render() {
    const { isShow, isUse } = this.state;
    const dragProps = {
      width: 600, // can only receive number
      image: 'https://image.xx.jpg' || 'file',
      toolBar: {
        isShow,
        isUse
      }
    }
    return (<ImageDrag {...dragProps} />);
  }
}
export default Image;

CODE

API

nametypedescotherversion
widthnumber图片区域宽度默认600v 1.0.0
heightnumber图片区域高度默认400v 1.0.0
imagefile or url图片*v 1.0.0
childrendom元素图片*, 如果image也存在,此属性(children)优先v 1.0.0
imgStyleobject图片样式属性*v 1.0.0
toolBarobject工具栏配置*v 1.0.0
dragPointobject拖拽点配置*v 1.0.0
tabIndexstring设置 tabIndex 属性*v 1.2.0
onClickImagefunction点击图片function(toolInfo)v 1.0.0
onDragStartfunction拖拽开始function(toolInfo, event, clientX, clientY)v 1.1.0
onDraggingfunction拖拽中function(imageDragStyle)v 1.1.0
onDragEndfunction拖拽结束function(toolInfo, event, clientX, clientY)v 1.1.0
onFocusImagefunction获取图片焦点事件function(toolInfo)v 1.2.1
onBlurImagefunction失去图片焦点事件function(toolInfo)v 1.2.1
renderToolfunction自定义工具栏显示形式function(toolInfo),接收一个Dom元素v 1.0.0

renderTool中传入的参数为 toolBar 中的信息, 同时会多传递一个刷新图片尺寸的函数

v 1.2.x 及以上版本中 function(toolInfo) 传递的 toolInfo 为只读属性

toolBar

nametypedescotherversion
topnumber位置属性0v 1.0.0
bottomnumber位置属性0v 1.0.0
leftnumber位置属性0v 1.0.0
rightnumber位置属性0v 1.0.0
widthnumber拖拽后图片区域宽度*v 1.0.0
heightnumber拖拽后图片区域高度*v 1.0.0
classNamestringtoolBar样式*v 1.0.0
isUseboolean是否使用toolBartruev 1.0.0
isShowboolean是否接管显示toolBar,会覆盖掉内置显示属性falsev 1.0.0
isBlockboolean是否进行块状化布局*v 1.0.0

dragPoint

nametypedescotherversion
topLeftPointobject左上角拖拽点样式{}v 1.0.0
topRightPointobject右上角拖拽点样式{}v 1.0.0
bottomLeftPointobject左下角拖拽点样式{}v 1.0.0
bottomRightPointobject右下角拖拽点样式{}v 1.0.0
styleobject拖拽点公共样式*v 1.0.0
1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago