-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,206 additions
and
1,182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,83 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import {Events} from 'uploadcore'; | ||
import util from "./util"; | ||
import FileList from "./FileList"; | ||
import Picker from "./Picker"; | ||
import { Events } from 'uploadcore'; | ||
import util from './util'; | ||
import FileList from './FileList'; | ||
import Picker from './Picker'; | ||
|
||
export default class Dropzoom extends React.Component { | ||
static displayName = "Dropzoom"; | ||
static displayName = 'Dropzoom'; | ||
|
||
constructor(props) { | ||
super(props); | ||
constructor(props) { | ||
super(props); | ||
|
||
this.core = util.getCoreInstance(props); | ||
this.core = util.getCoreInstance(props); | ||
|
||
this.state = { | ||
blink: 0, | ||
highlight: 0, | ||
total: this.core.getTotal() | ||
}; | ||
this.state = { | ||
blink: 0, | ||
highlight: 0, | ||
total: this.core.getTotal(), | ||
}; | ||
|
||
const statchange = (stat) => { | ||
const total = stat.getTotal(); | ||
if (total !== this.state.total) { | ||
this.setState({total:total}); | ||
} | ||
}; | ||
this.core.on(Events.QUEUE_STAT_CHANGE, statchange); | ||
this.stopListen = () => { | ||
this.core.off(Events.QUEUE_STAT_CHANGE, statchange); | ||
}; | ||
} | ||
const statchange = (stat) => { | ||
const total = stat.getTotal(); | ||
if (total !== this.state.total) { | ||
this.setState({ total }); | ||
} | ||
}; | ||
this.core.on(Events.QUEUE_STAT_CHANGE, statchange); | ||
this.stopListen = () => { | ||
this.core.off(Events.QUEUE_STAT_CHANGE, statchange); | ||
}; | ||
} | ||
|
||
reset() { | ||
this.core.getFiles().forEach((file) => { | ||
file.cancel(); | ||
}); | ||
} | ||
reset() { | ||
this.core.getFiles().forEach((file) => { | ||
file.cancel(); | ||
}); | ||
} | ||
|
||
componentDidMount() { | ||
const areaNode = ReactDOM.findDOMNode(this); | ||
componentDidMount() { | ||
const areaNode = ReactDOM.findDOMNode(this); | ||
|
||
const dndArea = this.core.getDndCollector().addArea(areaNode); | ||
dndArea.on('start', () => { | ||
this.setState({blink:1}) | ||
}).on('response', (e) => { | ||
if (areaNode.contains(e.target)) { | ||
this.setState({highlight:1}); | ||
} else { | ||
this.setState({highlight:0}); | ||
} | ||
}).on('end', () => { | ||
this.setState({blink:0,highlight:0}); | ||
}); | ||
this.dndArea = dndArea; | ||
const dndArea = this.core.getDndCollector().addArea(areaNode); | ||
dndArea.on('start', () => { | ||
this.setState({ blink: 1 }); | ||
}).on('response', (e) => { | ||
if (areaNode.contains(e.target)) { | ||
this.setState({ highlight: 1 }); | ||
} else { | ||
this.setState({ highlight: 0 }); | ||
} | ||
}).on('end', () => { | ||
this.setState({ blink: 0, highlight: 0 }); | ||
}); | ||
this.dndArea = dndArea; | ||
} | ||
componentWillUnmount() { | ||
this.dndArea && this.dndArea.destroy(); | ||
this.stopListen && this.stopListen(); | ||
} | ||
render() { | ||
let className = 'kuma-uploader kuma-upload-dropzoom'; | ||
if (this.props.className) { | ||
className += ` ${this.props.className}`; | ||
} | ||
componentWillUnmount() { | ||
this.dndArea && this.dndArea.destroy(); | ||
this.stopListen && this.stopListen(); | ||
if (this.state.blink) { | ||
className += ' blink'; | ||
} | ||
render() { | ||
let className = "kuma-uploader kuma-upload-dropzoom"; | ||
if (this.props.className) { | ||
className += ' ' + this.props.className; | ||
} | ||
if (this.state.blink) { | ||
className += ' blink'; | ||
} | ||
if (this.state.highlight) { | ||
className += ' enter'; | ||
} | ||
let children = this.props.children; | ||
if (!children || children.length < 1) { | ||
children = <i className="kuma-icon kuma-icon-add" />; | ||
} | ||
return <div className={className}> | ||
{this.state.total > 0 | ||
? <FileList locale={this.props.locale} core={this.core} mode="nw" fileList={this.props.fileList}/> | ||
: <Picker core={this.core}>{children}</Picker>} | ||
<div className="kuma-upload-responser" /> | ||
</div>; | ||
if (this.state.highlight) { | ||
className += ' enter'; | ||
} | ||
let children = this.props.children; | ||
if (!children || children.length < 1) { | ||
children = <i className="kuma-icon kuma-icon-add" />; | ||
} | ||
return (<div className={className}> | ||
{this.state.total > 0 | ||
? <FileList locale={this.props.locale} core={this.core} mode="nw" fileList={this.props.fileList} /> | ||
: <Picker core={this.core}>{children}</Picker>} | ||
<div className="kuma-upload-responser" /> | ||
</div>); | ||
} | ||
} |
Oops, something went wrong.