2.0.2 • Published 8 years ago

react-announce-draggable v2.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

Reactive Announce Draggable

Build Status npm

A simple react-announce extension that helps in consolidating the drag and drop events.

Installation

npm i react-announce-draggable --save

Example Usage

Auto fires three types of custom events — DRAG_START, DRAG_OVER and DROP, on the component stream.

import {draggable, droppable, consolidate}  from 'react-announce-draggable'
import {asStream} from 'react-announce'
import rx from 'rx'

const bus = new rx.Subject()

@draggable
@asStream(bus)
class Apple extends Component {
  render () {
    return (
      <div draggable="true">
        APPLE
      <div>
    )
  }
}

@droppable
@asStream(bus)
class Basket extends Component {
  render () {
    return (
      <div>
        Fruit Basket
      <div>
    )
  }
}

consolidate(bus).subscribe(x => console.log(x))

/** OUTPUT:
{picked: {component: Apple}, type: 'PICKED'}
{over: {component: Basket}, picked: {component: Apple}, type: 'DRAG'}
{over: {component: Basket}, picked: {component: Apple}, type: 'DRAG'}
{over: {component: Basket}, picked: {component: Apple}, type: 'DROP'}
**/

API

  • @draggable — Dispatches DRAG_START event on the component's stream.
  • @droppable — Dispatches DRAG_OVER and DROP event on the component's stream.
  • consolidate(observer) — Takes input as the observer and returns a consolidated stream which contains information about what has been picked and where it has been dropped.
2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.0-0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago

1.0.0

8 years ago