react 可裁剪拖拽的热区组件

React Hot zone

react 热区resize组件

Installation

npm install hot-zone --save

Usage

import React from 'react'
import ReactDOM from 'react-dom'
import HotZoneWrap from 'hot-zone'
import img from './imgs/img.jpg'

class App extends React.Component {
  state = {
    coordinates: [],
  }

  changeCoordinate = (coordinate, index, coordinates) => {
    this.setState({
      coordinates,
    })
  }
  deleteCoordinate = (coordinate, index, coordinates) => {
    this.setState({
      coordinates,
    })
  }
  onDoubleClick = () => {
    console.log("双击事件")
  }
  render() {
    return
        <HotZoneWrap
          src={img}
          width={1000}
          coordinates={this.state.coordinates}
          onChange={this.changeCoordinate}
          onDelete={this.deleteCoordinate}
          onDoubleClick={this.onDoubleClick}
          hidden={false}
        />
      </div>
  }
}


ReactDOM.render(
  <div>
    <App />
  </div>,
  document.getElementById('root'),
)

Props

Prop Description Type Default
src 图片链接 string -
coordinates 热区拖拽信息 {id, x, y, width, height, urlLink}. array []
width 图片宽度 number(in pixel) -
clientWidth 拖拽窗口宽度(默认 320) B端配置区 number(in pixel) -
height 图片高度 number(in pixel) -
hidden 热区是否显性展示 bool
isMobile 是否支持手机端 默认false bool
onDraw 创建新热区 funtion(coordinate , index, coordinates) -
onDrag 拖拽事件 funtion(coordinate , index, coordinates) -
onResize Resize事件 funtion(coordinate , index, coordinates) -
onChange 热区变化事件 funtion(coordinate , index, coordinates) -
onDelete 热区删除事件 funtion(coordinate , index, coordinates) -
onDoubleClick 热区双击事件 (hiden为true时触发) onLoad(e) -

coordinate

Prop Description Type Default
id id string -
x X number(in pixel) -
y Y number(in pixel) -
width Width number(in pixel) -
height Height number(in pixel) -

—— 人生终极非名利,千年流芳唯正气。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、鼠标键盘 pyautogui官方文档 1、鼠标移动到屏幕正中间示例 2、常用操作 获取屏幕宽高 获取当前鼠标位...
    AncientMing阅读 1,401评论 0 1
  • Openlayers API整理 openlayers 发布于 2019-09-05 一、创建地图 1、地图Map...
    不玩了啊阅读 3,694评论 0 2
  • 无意间发现React的版本又更新到了0.51了。这又意味着某些群体面临的踩坑时节的到来。(啊哈哈哈!!想想就觉得特...
    wfunny阅读 8,768评论 7 6
  • 高性能的简单列表组件,支持下面这些常用的功能: 完全跨平台。 支持水平布局模式。 行组件显示或隐藏时可配置回调事件...
    慕久久阅读 2,100评论 0 0
  • FlatList是一个高性能的列表组件,它是ListView组件的升级版,性能方面有了很大的提升,当然也就建议大家...
    代码森林中的一只猫阅读 2,609评论 0 3