mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
autoscroll down(if the scroller was already at the bottom) when receiving member events
This commit is contained in:
parent
3a88808983
commit
12a23f01b4
@ -42,23 +42,24 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||||||
$scope.imageURLToSend = "";
|
$scope.imageURLToSend = "";
|
||||||
$scope.userIDToInvite = "";
|
$scope.userIDToInvite = "";
|
||||||
|
|
||||||
var scrollToBottom = function() {
|
var scrollToBottom = function(force) {
|
||||||
console.log("Scrolling to bottom");
|
console.log("Scrolling to bottom");
|
||||||
$timeout(function() {
|
|
||||||
|
// Do not autoscroll to the bottom to display the new event if the user is not at the bottom.
|
||||||
|
// Exception: in case where the event is from the user, we want to force scroll to the bottom
|
||||||
var objDiv = document.getElementById("messageTableWrapper");
|
var objDiv = document.getElementById("messageTableWrapper");
|
||||||
|
if ((objDiv.offsetHeight + objDiv.scrollTop >= objDiv.scrollHeight) || force) {
|
||||||
|
|
||||||
|
$timeout(function() {
|
||||||
objDiv.scrollTop = objDiv.scrollHeight;
|
objDiv.scrollTop = objDiv.scrollHeight;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) {
|
$scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) {
|
||||||
if (isLive && event.room_id === $scope.room_id) {
|
if (isLive && event.room_id === $scope.room_id) {
|
||||||
|
|
||||||
// Do not autoscroll to the bottom to display this new event if the user is not at the bottom.
|
|
||||||
// Exception: if the event is from the user, scroll to the bottom
|
|
||||||
var objDiv = document.getElementById("messageTableWrapper");
|
|
||||||
if ( (objDiv.offsetHeight + objDiv.scrollTop >= objDiv.scrollHeight) || event.user_id === $scope.state.user_id) {
|
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}
|
|
||||||
|
|
||||||
if (window.Notification) {
|
if (window.Notification) {
|
||||||
// Show notification when the user is idle
|
// Show notification when the user is idle
|
||||||
@ -80,6 +81,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||||||
|
|
||||||
$scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) {
|
$scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) {
|
||||||
if (isLive) {
|
if (isLive) {
|
||||||
|
scrollToBottom();
|
||||||
updateMemberList(event);
|
updateMemberList(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -288,6 +290,8 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToBottom(true);
|
||||||
|
|
||||||
var promise;
|
var promise;
|
||||||
var isCmd = false;
|
var isCmd = false;
|
||||||
|
|
||||||
@ -614,6 +618,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.sendImage = function(url, body) {
|
$scope.sendImage = function(url, body) {
|
||||||
|
scrollToBottom(true);
|
||||||
|
|
||||||
matrixService.sendImageMessage($scope.room_id, url, body).then(
|
matrixService.sendImageMessage($scope.room_id, url, body).then(
|
||||||
function() {
|
function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user