mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
improve close
method
This commit is contained in:
parent
6b13136fa6
commit
b5d529a374
@ -132,22 +132,32 @@ export class Drawer extends React.Component {
|
|||||||
return await this.setState({ locked: false })
|
return await this.setState({ locked: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
close = () => {
|
close = async ({
|
||||||
if (this.state.locked) {
|
unlock = false
|
||||||
return console.warn("Cannot close a locked drawer")
|
} = {}) => {
|
||||||
}
|
return new Promise(async (resolve) => {
|
||||||
|
if (unlock) {
|
||||||
this.toggleVisibility(false)
|
await this.setState({ locked: false })
|
||||||
|
|
||||||
this.events.emit("beforeClose")
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
if (typeof this.options.onClose === "function") {
|
|
||||||
this.options.onClose()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.controller.close(this.props.id)
|
if (this.state.locked && !unlock) {
|
||||||
}, 500)
|
return console.warn("Cannot close a locked drawer")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toggleVisibility(false)
|
||||||
|
|
||||||
|
this.events.emit("beforeClose")
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (typeof this.options.onClose === "function") {
|
||||||
|
this.options.onClose()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.controller.close(this.props.id)
|
||||||
|
|
||||||
|
resolve()
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEvent = (...context) => {
|
sendEvent = (...context) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user