From d5bf29f9c98f2b24c09b27dc597ffae624eb8937 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Mon, 12 Aug 2019 15:57:49 -0400 Subject: [PATCH 1/2] Added optional animation props for chat open/close --- LiveChat/Chat/Chat.js | 12 ++++++++---- README.md | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/LiveChat/Chat/Chat.js b/LiveChat/Chat/Chat.js index 3614d48..f276540 100644 --- a/LiveChat/Chat/Chat.js +++ b/LiveChat/Chat/Chat.js @@ -113,9 +113,13 @@ export default class Chat extends React.Component { }; closeChat = () => { - this.chat.lightSpeedOut(500).then(() => { - this.props.closeChat(); - }); + if (this.props.animateOnClose) { + this.chat.lightSpeedOut(500).then(() => { + this.props.closeChat(); + }); + } else { + this.props.closeChat(); + } }; renderFooter = () => { @@ -135,7 +139,7 @@ export default class Chat extends React.Component { if (this.props.isChatOn) { return ( { this.chat = ref; }} > diff --git a/README.md b/README.md index 25b15b5..c627c53 100644 --- a/README.md +++ b/README.md @@ -121,12 +121,32 @@ Let's say you want to close the current chat. You can do it in two ways: // is the same as: GLOBAL.visitorSDK.closeChat(); ``` +#### Props + +|Name|Type|Required|Note| +|---|---|---|---| +| animateOnOpen | Bool | No | Chat will open with an animation. | +| animateOnClose | Bool | No | Chat will close with an animation. | +| license | Int | Yes | License number for livechat. | +| group | Int | No | Description goes here. | +| movable | Bool | No | Description goes here. | +| bubble | Element | No | Description goes here. | +| bubbleColor | String | No | Description goes here. | +| bubbleLeft | Number | No | Description goes here. | +| bubbleTop | Number | No | Description goes here. | +| chatTitle | String | No | Description goes here. | +| greeting | String | No | Description goes here. | +| noAgents | String | No | Description goes here. | +| onLoaded | Func | No | Description goes here. | + + #### Available methods |Name|Note| |---|---| | closeChat | Closes the chat. | +| openChat | Opens the chat. | | sendMessage | Sends a message. More information about message format you can find [here](https://docs.livechatinc.com/visitor-sdk/#sendmessage). | | rateChat | Enables chat ratings. More info [here](https://docs.livechatinc.com/visitor-sdk/#ratechat). | |setSneakPeek | Enables sneak peeks to see what the visitor is typing in before they actually send the message. More info [here](https://docs.livechatinc.com/visitor-sdk/#setsneakpeek). | From f221030f1b019315cf9c4a900e4a184eb29df7f5 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Mon, 19 Aug 2019 18:06:57 -0700 Subject: [PATCH 2/2] Added the option to accept a different closeChat function via props --- LiveChat/LiveChat.js | 3 ++- README.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/LiveChat/LiveChat.js b/LiveChat/LiveChat.js index cf6a5ff..0c01339 100644 --- a/LiveChat/LiveChat.js +++ b/LiveChat/LiveChat.js @@ -67,7 +67,7 @@ export default class LiveChat extends Component { bubble={this.state.bubble} disabled={this.props.movable} /> - + ); } @@ -85,6 +85,7 @@ LiveChat.propTypes = { greeting: PropTypes.string, noAgents: PropTypes.string, onLoaded: PropTypes.func, + closeChat: PropTypes.func, }; LiveChat.defaultProps = { diff --git a/README.md b/README.md index c627c53..04e7d18 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ Let's say you want to close the current chat. You can do it in two ways: | greeting | String | No | Description goes here. | | noAgents | String | No | Description goes here. | | onLoaded | Func | No | Description goes here. | +| closeChat | Func | No | Overrides the default function to run when user clicks the "Back" button, closing the chat. |