mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-18 10:22:31 +08:00
Merge pull request #101 from anubisthejackle/fix-memory-usage
Fixed a memory usage issue when using system over long periods or with l...
This commit is contained in:
+22
-2
@@ -43,9 +43,29 @@ var Notifications = {
|
|||||||
Engine.saveGame();
|
Engine.saveGame();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearHidden: function() {
|
||||||
|
|
||||||
|
// To fix some memory usage issues, we clear notifications that have been hidden.
|
||||||
|
|
||||||
|
// We use position().top here, because we know that the parent will be the same, so the position will be the same.
|
||||||
|
var bottom = $('#notifyGradient').position().top + $('#notifyGradient').outerHeight(true);
|
||||||
|
|
||||||
|
$('.notification').each(function() {
|
||||||
|
|
||||||
|
if($(this).position().top > bottom){
|
||||||
|
$(this).remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
printMessage: function(t) {
|
printMessage: function(t) {
|
||||||
var text = $('<div>').addClass('notification').css('opacity', '0').text(t).prependTo('div#notifications');
|
var text = $('<div>').addClass('notification').css('opacity', '0').text(t).prependTo('div#notifications');
|
||||||
text.animate({opacity: 1}, 500, 'linear');
|
text.animate({opacity: 1}, 500, 'linear', function() {
|
||||||
|
// Do this every time we add a new message, this way we never have a large backlog to iterate through. Keeps things faster.
|
||||||
|
Notifications.clearHidden();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
printQueue: function(module) {
|
printQueue: function(module) {
|
||||||
@@ -55,4 +75,4 @@ var Notifications = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user