Skip to content

Commit

Permalink
add callback. Fix unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Brzek committed Oct 1, 2015
1 parent cf7e753 commit c37f84a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.DS_Store
npm-debug.log
node_modules/
index.js
4 changes: 4 additions & 0 deletions demo/index.coffee
Expand Up @@ -15,6 +15,9 @@ App = React.createClass
document.title = 'testing'
console.log 'root'

_handleOnDrag: (state) ->
console.log state

componentDidMount: ->
document.body.classList.add('loaded')

Expand All @@ -30,6 +33,7 @@ App = React.createClass
Dragarea
ref: 'dragarea'
draggingClassName: 'dragging'
onDrag: @_handleOnDrag
onDrop: @_onRootDrop,

div className: 'container',
Expand Down
26 changes: 16 additions & 10 deletions index.coffee
Expand Up @@ -12,6 +12,7 @@ Droparea = React.createClass
propTypes:
disableClick: React.PropTypes.bool
onDragActive: React.PropTypes.func
onDrag: React.PropTypes.func
dropEffect: React.PropTypes.string
onDrop: React.PropTypes.func.isRequired
className: React.PropTypes.string
Expand Down Expand Up @@ -73,12 +74,12 @@ Droparea = React.createClass
_onChildDragLeave: ->
unless @state.shouldComponentBeActive
@setState dropActive: true
@_handleOnDropActive(true)
@_handleOnDragActive(true)

_onChildDragEnter: ->
unless @state.shouldComponentBeActive
@setState dropActive: false
@_handleOnDropActive(false)
@_handleOnDragActive(false)

_onDragLeave: (e) ->
e.stopPropagation()
Expand All @@ -93,7 +94,8 @@ Droparea = React.createClass
dropActive: false
dragging: false

@_handleOnDropActive(false)
@_handleOnDrag(false)
@_handleOnDragActive(false)

_onDragEnter: (e) ->
e.stopPropagation()
Expand All @@ -109,14 +111,12 @@ Droparea = React.createClass
unless @props.shouldParentBeActiveWhenHovering
@_customEventFactory('dragarea:dragenter')

if @props.draggingClassName
@setState()

@setState
dropActive: true
dragging: true

@_handleOnDropActive(true)
@_handleOnDrag(true)
@_handleOnDragActive(true)

_filterFiles: (files) ->
regex = new RegExp("^.*\\.(#{@props.supportedFormats.join('|')})$")
Expand All @@ -130,7 +130,8 @@ Droparea = React.createClass
dropActive: false
dragging: false

@_handleOnDropActive(false)
@_handleOnDrag(false)
@_handleOnDragActive(false)

files = @_getFilesFromEvent(e)

Expand All @@ -150,19 +151,24 @@ Droparea = React.createClass
dropActive: false
dragging: false

@_handleOnDropActive(false)
@_handleOnDrag(false)
@_handleOnDragActive(false)

_onClick: (e) ->
unless @props.disableClick
e.stopPropagation()
@refs.fileInput.getDOMNode().click()

_handleOnDropActive: (state) ->
_handleOnDragActive: (state) ->
if @props.onDragActive?
if state
return setTimeout => @props.onDragActive(state)
@props.onDragActive(state)

_handleOnDrag: (state) ->
if @props.onDrag?
@props.onDrag(state)

_getFilesFromEvent: (e) ->
e = e.detail if e.detail

Expand Down
4 changes: 1 addition & 3 deletions package.json
Expand Up @@ -7,9 +7,7 @@
"scripts": {
"start": "webpack-dev-server --hot --progress --colors --port 3000",
"test": "./test/setup.sh",
"prepublish": "coffee -o ./ index.coffee",
"postpublish": "git clean -f -d",
"postinstall": "git clean -f -d"
"prepublish": "coffee -o ./ index.coffee"
},
"keywords": [
"react",
Expand Down

0 comments on commit c37f84a

Please sign in to comment.