Git Product home page Git Product logo

react-rnd-dargline's Introduction

react-rnd-dragline

这是一个基于 react-rnd 实现的拖拽组件,在rnd的功能基础上增加了拖拽时显示辅助线及吸附的功能。

安装

$ npm i react-rnd-dragline

or

$ yarn add react-rnd-dragline

使用

属性

  • DragArea

    • bounds: RndProps['bounds']

      默认值为空 ""

      拖拽边界,应用到所有DragItem上,也可以单独在DragItem上使用

    • guidelineColor: string

      辅助线颜色,默认值:'#448ef7'

    • guidelineWidth: number

      辅助线宽度,默认值:1

    • onAdsorb: boolean

      是否开启吸附效果,默认值:ture

    • adsorbThreshold: number

      吸附阈值,onAdsorb为ture时生效,默认值为:5

  • DragItem 继承 react-rnd的所有属性,更多属性请参考 react-rnd

注: DragItem的Children样式有padding时,需要设置box-sizing为border-box

使用方法示例

import { DragArea, DragItem } from 'react-rnd-dragline';
import './index.less';

export default function IndexPage() {
  return (
    <DragArea
        bounds="body"
        guidelineColor="red"
        onAdsorb={true}
        adsorbThreshold={5}
      >
        <DragItem>
          <div className="t t1">a</div>
        </DragItem>
        <DragItem>
          <div className="t t1">b</div>
        </DragItem>
        <DragItem>
          <div className="t t2">c</div>
        </DragItem>
        <DragItem>
          <div className="t t3">d</div>
        </DragItem>
      </DragArea>
  );
}

react-rnd-dargline's People

Contributors

ectimi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.