customer chat: only show hint on new message
This commit is contained in:
parent
74b9e60ad6
commit
b403a621a3
1 changed files with 11 additions and 5 deletions
|
@ -372,7 +372,7 @@ class ChatWindow extends App.Controller
|
||||||
@chat = App.Chat.find(@session.chat_id)
|
@chat = App.Chat.find(@session.chat_id)
|
||||||
@name = "#{@chat.displayName()} ##{@session.id}"
|
@name = "#{@chat.displayName()} ##{@session.id}"
|
||||||
|
|
||||||
@on 'layout-change', @scrollToBottom
|
@on 'layout-change', @onLayoutChange
|
||||||
|
|
||||||
@bind('chat_session_typing', (data) =>
|
@bind('chat_session_typing', (data) =>
|
||||||
return if data.session_id isnt @session.session_id
|
return if data.session_id isnt @session.session_id
|
||||||
|
@ -406,6 +406,9 @@ class ChatWindow extends App.Controller
|
||||||
@focus()
|
@focus()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
onLayoutChange: =>
|
||||||
|
@scrollToBottom()
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
@html App.view('customer_chat/chat_window')
|
@html App.view('customer_chat/chat_window')
|
||||||
name: @name
|
name: @name
|
||||||
|
@ -609,7 +612,7 @@ class ChatWindow extends App.Controller
|
||||||
isNew: isNew
|
isNew: isNew
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
|
|
||||||
@scrollToBottom()
|
@scrollToBottom showHint: true
|
||||||
|
|
||||||
showWritingLoader: =>
|
showWritingLoader: =>
|
||||||
if !@isTyping
|
if !@isTyping
|
||||||
|
@ -685,16 +688,19 @@ class ChatWindow extends App.Controller
|
||||||
scrollBottom = @scrollHolder.scrollTop() + @scrollHolder.height()
|
scrollBottom = @scrollHolder.scrollTop() + @scrollHolder.height()
|
||||||
@scrolledToBottom = Math.abs(scrollBottom - @scrollHolder.prop('scrollHeight')) <= @scrollSnapTolerance
|
@scrolledToBottom = Math.abs(scrollBottom - @scrollHolder.prop('scrollHeight')) <= @scrollSnapTolerance
|
||||||
|
|
||||||
|
showScrollHint: ->
|
||||||
|
@scrollHint.removeClass('is-hidden')
|
||||||
|
|
||||||
onScrollHintClick: ->
|
onScrollHintClick: ->
|
||||||
# animate scroll
|
# animate scroll
|
||||||
@scrollHolder.animate({scrollTop: @scrollHolder.prop('scrollHeight')}, 300)
|
@scrollHolder.animate({scrollTop: @scrollHolder.prop('scrollHeight')}, 300)
|
||||||
@scrollHint.addClass('is-hidden')
|
@scrollHint.addClass('is-hidden')
|
||||||
|
|
||||||
scrollToBottom: ->
|
scrollToBottom: ({ showHint } = { showHint: false }) ->
|
||||||
if @scrolledToBottom
|
if @scrolledToBottom
|
||||||
@scrollHolder.scrollTop(@scrollHolder.prop('scrollHeight'))
|
@scrollHolder.scrollTop(@scrollHolder.prop('scrollHeight'))
|
||||||
else
|
else if showHint
|
||||||
@scrollHint.removeClass('is-hidden')
|
@showScrollHint()
|
||||||
|
|
||||||
class Setting extends App.ControllerModal
|
class Setting extends App.ControllerModal
|
||||||
buttonClose: true
|
buttonClose: true
|
||||||
|
|
Loading…
Reference in a new issue