diff --git a/.gitignore b/.gitignore index 2b9505b..28f0ad1 100755 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ docs/.vuepress/dist # Backups .BACKUP .STORAGE + +# npm related +package-lock.json diff --git a/README.md b/README.md index fc873d2..07a3a29 100755 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ List of available props to use in the component: | `bot-typing` | Boolean | false | If `true`, the bot typing indicator will show | | `input-disable` | Boolean | false | If `true`, message input will be disabled | | `is-open` | Boolean | false | If `true`, the board will open from init | - +| `open-delay` | Number | undefined | Delay before opening from init (in ms). Requires `is-open` to be `true` | ## Options diff --git a/src/App.vue b/src/App.vue index b4b4463..f542cb7 100755 --- a/src/App.vue +++ b/src/App.vue @@ -9,7 +9,8 @@ :messages="messageData", :bot-typing="botTyping", :input-disable="inputDisable", - :is-open="false", + :is-open="true", + :open-delay="2000" @init="botStart", @msg-send="msgSend", ) diff --git a/src/components/BotUI.vue b/src/components/BotUI.vue index e4cddc7..9d396bf 100644 --- a/src/components/BotUI.vue +++ b/src/components/BotUI.vue @@ -80,6 +80,10 @@ export default { isOpen: { type: Boolean, default: false + }, + + openDelay: { + type: Number } }, @@ -125,7 +129,11 @@ export default { created () { if (this.isOpen) { - this.botToggle() + if (this.openDelay) { + setTimeout(this.botOpen, this.openDelay) + } else { + this.botToggle() + } } EventBus.$on('select-button-option', this.selectOption) @@ -136,6 +144,12 @@ export default { }, methods: { + botOpen () { + if (!this.botActive) { + this.botToggle() + } + }, + botToggle () { this.botActive = !this.botActive