Skip to content

Commit 9acd070

Browse files
committed
Fixed socket set wrong cursor data on receive, prevent buildCursor execute on view mode
1 parent f8b029b commit 9acd070

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

public/js/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ socket.on('cursor focus', function (data) {
11261126
console.debug(data);
11271127
for (var i = 0; i < onlineUsers.length; i++) {
11281128
if (onlineUsers[i].id == data.id) {
1129-
onlineUsers[i].cursor = data;
1129+
onlineUsers[i].cursor = data.cursor;
11301130
}
11311131
}
11321132
if (data.id != socket.id)
@@ -1142,7 +1142,7 @@ socket.on('cursor activity', function (data) {
11421142
console.debug(data);
11431143
for (var i = 0; i < onlineUsers.length; i++) {
11441144
if (onlineUsers[i].id == data.id) {
1145-
onlineUsers[i].cursor = data;
1145+
onlineUsers[i].cursor = data.cursor;
11461146
}
11471147
}
11481148
if (data.id != socket.id)
@@ -1384,6 +1384,7 @@ function checkCursorTag(coord, ele) {
13841384
}
13851385

13861386
function buildCursor(user) {
1387+
if (currentMode == modeType.view) return;
13871388
if (!user.cursor) return;
13881389
var coord = editor.charCoords(user.cursor, 'windows');
13891390
coord.left = coord.left < 4 ? 4 : coord.left;
@@ -1497,6 +1498,9 @@ function buildCursor(user) {
14971498
cursortag.find('i').removeClass().addClass('fa').addClass(iconClass);
14981499
cursortag.find(".name").text(user.name);
14991500

1501+
cursor[0].style.left = coord.left + 'px';
1502+
cursor[0].style.top = coord.top + 'px';
1503+
/*
15001504
if (cursor.css('display') === 'none') {
15011505
cursor[0].style.left = coord.left + 'px';
15021506
cursor[0].style.top = coord.top + 'px';
@@ -1509,6 +1513,7 @@ function buildCursor(user) {
15091513
queue: false
15101514
});
15111515
}
1516+
*/
15121517

15131518
if (user.idle && cursor.css('display') !== 'none')
15141519
cursor.stop(true).fadeOut();

0 commit comments

Comments
 (0)