npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-draggable-and-droppable

v1.0.2

Published

react drag and drop component

Downloads

8

Readme

Drag and Drop

Install

npm install --save react-draggable-and-droppable

Drag拖拽对象

目前采用组件组合模式。此模式拖拽的源元素并不会移动。

example

import { Draggable } from 'react-draggable-and-droppable';

<Draggable 
    value={'jch'}
    onDrag={this.onDrag}>
    <div>
        <p>jch</p>
    </div>
</Draggable>

props

| Prop/Attr | Type | Default | isNeed | Description | | --------- | ---- | ------- | ------ | ----------- | | value | any | '' | yes | 拖拽过程触发的事件都会将该值返回,标记拖拽的元素。| | proxy | string | 'clone' | no | 拖拽时显示跟随鼠标的代理元素,默认为克隆自身元素DOM,可设为'', 不显示代理元素。 | | proxyClass | string | 'z-dragproxy' | no | 上面clone的代理元素,外层会默认加个'z-dragproxy' class,可自定义拖拽时代理元素样式,同时拖拽元素也有个'draggable-source',可自定义拖拽时元素的样式 | | disabled | boolean | false | no | 是否可拖拽 |

Event

  • onDragStart
  • onDrag
  • onDragEnd

目前提供这几个事件,param都会返回几个关键信息

  • origin: 拖拽源,React Componet。
  • value: 拖拽元素设置的props value的值。
  • pageX: 鼠标位置
  • pageY: 鼠标位置

Drop放置对象

example

import { Droppable } from 'react-draggable-and-droppable';

<Droppable onDrop={this.onDrop}>
    <div style={{width: '200px', height: '200px', background: 'red'}}>
        <p>放置拖拽元素区域</p>
    </div>
</Droppable>

Event

  • onDragEnter
  • onDragOver
  • onDragLeave
  • onDrop

目前提供这几个事件,param都会返回几个关键信息

  • origin: 拖拽源对象,React Component
  • target: 拖拽放置对象。React Component
  • value: 拖拽源的value值。
  • pageX: 放置时鼠标位置。
  • pageY: 放置时鼠标位置。