mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Small chat scroll tweaks
This commit is contained in:
parent
e0266e309f
commit
1d7a595c6c
4 changed files with 7 additions and 5 deletions
|
@ -6,7 +6,7 @@ aside.chat(
|
||||||
infinite-scroll-disabled="chat.loading || chat.atEnd"
|
infinite-scroll-disabled="chat.loading || chat.atEnd"
|
||||||
infinite-scroll-initialize="ui.chatOpen"
|
infinite-scroll-initialize="ui.chatOpen"
|
||||||
infinite-scroll-upwards="true"
|
infinite-scroll-upwards="true"
|
||||||
update-scroll-bottom-on="messages:updated"
|
update-scroll-bottom-on="updateScrollPosition"
|
||||||
)
|
)
|
||||||
.infinite-scroll-inner
|
.infinite-scroll-inner
|
||||||
.loading(ng-show="chat.loading")
|
.loading(ng-show="chat.loading")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
define [
|
define [
|
||||||
"base"
|
"base"
|
||||||
], (App) ->
|
], (App) ->
|
||||||
App.directive "updateScrollBottomOn", ->
|
App.directive "updateScrollBottomOn", ($timeout) ->
|
||||||
return {
|
return {
|
||||||
restrict: "A"
|
restrict: "A"
|
||||||
link: (scope, element, attrs, ctrls) ->
|
link: (scope, element, attrs, ctrls) ->
|
||||||
|
@ -29,7 +29,7 @@ define [
|
||||||
scrollBottom = element[0].scrollHeight - element[0].scrollTop - element[0].clientHeight
|
scrollBottom = element[0].scrollHeight - element[0].scrollTop - element[0].clientHeight
|
||||||
|
|
||||||
scope.$on attrs.updateScrollBottomOn, () ->
|
scope.$on attrs.updateScrollBottomOn, () ->
|
||||||
setTimeout () ->
|
$timeout () ->
|
||||||
element.scrollTop(element[0].scrollHeight - element[0].clientHeight - scrollBottom)
|
element.scrollTop(element[0].scrollHeight - element[0].clientHeight - scrollBottom)
|
||||||
, 0
|
, 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,12 @@ define [
|
||||||
|
|
||||||
$scope.$watch "chat.messages", (messages) ->
|
$scope.$watch "chat.messages", (messages) ->
|
||||||
if messages?
|
if messages?
|
||||||
$scope.$emit "messages:updated"
|
$scope.$emit "updateScrollPosition"
|
||||||
, true # Deep watch
|
, true # Deep watch
|
||||||
|
|
||||||
|
$scope.$on "layout:chat:resize", () ->
|
||||||
|
$scope.$emit "updateScrollPosition"
|
||||||
|
|
||||||
$scope.sendMessage = ->
|
$scope.sendMessage = ->
|
||||||
chatMessages
|
chatMessages
|
||||||
.sendMessage $scope.newMessageContent
|
.sendMessage $scope.newMessageContent
|
||||||
|
|
|
@ -34,7 +34,6 @@ define [
|
||||||
messages.reverse()
|
messages.reverse()
|
||||||
prependMessages(messages)
|
prependMessages(messages)
|
||||||
chat.state.nextBeforeTimestamp = chat.state.messages[0]?.timestamp
|
chat.state.nextBeforeTimestamp = chat.state.messages[0]?.timestamp
|
||||||
console.log messages, chat.state
|
|
||||||
|
|
||||||
TIMESTAMP_GROUP_SIZE = 5 * 60 * 1000 # 5 minutes
|
TIMESTAMP_GROUP_SIZE = 5 * 60 * 1000 # 5 minutes
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue