mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-09-30 06:43:02 -05:00
Fix chat memory leaks (#752)
This commit is contained in:
committed by
Guangcong Luo
parent
bba7941c68
commit
49fc9933a9
@@ -54,7 +54,6 @@
|
||||
top: position.top
|
||||
});
|
||||
|
||||
var isMouseDown = false;
|
||||
// Note: Origin starts from the top right instead of the top left here,
|
||||
// because when a battle room is opened, the left side moves but the right doesn't,
|
||||
// so we have to use the right side to keep the element in the same location.
|
||||
@@ -64,11 +63,8 @@
|
||||
$element.on('mousedown', function (e) {
|
||||
innerX = e.pageX + ($element.parent().width() - $element.width() - this.offsetLeft);
|
||||
innerY = e.pageY - this.offsetTop;
|
||||
isMouseDown = true;
|
||||
});
|
||||
|
||||
$(document).on('mousemove', function (e) {
|
||||
if (isMouseDown) {
|
||||
function mouseMoveCallback(e) {
|
||||
position.right = innerX - e.pageX;
|
||||
position.top = e.pageY - innerY;
|
||||
delete position.isDefault;
|
||||
@@ -78,8 +74,10 @@
|
||||
top: position.top
|
||||
});
|
||||
}
|
||||
}).on('mouseup', function () {
|
||||
isMouseDown = false;
|
||||
$(document).on('mousemove', mouseMoveCallback)
|
||||
.on('mouseup', function () {
|
||||
$(document).off('mousemove', mouseMoveCallback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -963,6 +963,10 @@
|
||||
if (autoscroll) {
|
||||
this.$chatFrame.scrollTop(this.$chat.height());
|
||||
}
|
||||
},
|
||||
destroy: function () {
|
||||
app.user.off('change', this.updateUser, this);
|
||||
Room.prototype.destroy.call(this);
|
||||
}
|
||||
}, {
|
||||
toggleFormatChar: function (textbox, formatChar) {
|
||||
@@ -1443,6 +1447,12 @@
|
||||
} else if (message.substr(0, 10) === '/announce ' || message.substr(0, 1) !== '/') {
|
||||
Storage.logChat(this.id, '' + name + ': ' + message);
|
||||
}
|
||||
},
|
||||
destroy: function () {
|
||||
if (this.tournamentBox) {
|
||||
app.user.off('saveteams', this.tournamentBox.updateTeams, this.tournamentBox);
|
||||
}
|
||||
ConsoleRoom.prototype.destroy.call(this);
|
||||
}
|
||||
}, {
|
||||
getTimestamp: function (section, msgTime) {
|
||||
|
||||
Reference in New Issue
Block a user