diff --git a/game/static/game/js/level_editor.js b/game/static/game/js/level_editor.js index 7a60e90b7..bb161f7ee 100644 --- a/game/static/game/js/level_editor.js +++ b/game/static/game/js/level_editor.js @@ -1231,37 +1231,42 @@ ocargo.LevelEditor = function() { /* Trashcan */ /************/ - function setupTrashcan() { - - var trashcan = $('#trashcanHolder'); - + function placeTrashcan(trashcan) { // Iffy way of making sure the trashcan stays inside the grid // when window bigger than grid - $(window).resize(function() { - var windowWidth = $(window).width(); - var windowHeight = $(window).height(); + var windowWidth = $(window).width(); + var windowHeight = $(window).height(); - var paperRightEdge = PAPER_WIDTH + $('#tools').width(); - var paperBottomEdge = PAPER_HEIGHT; + var paperRightEdge = PAPER_WIDTH + $('#tools').width(); + var paperBottomEdge = PAPER_HEIGHT; - var bottom = 50; - if(windowHeight > paperBottomEdge) { - bottom += windowHeight - paperBottomEdge - } + var bottom = 50; + if(windowHeight > paperBottomEdge) { + bottom += windowHeight - paperBottomEdge + } - var right = 50; - if(windowWidth > paperRightEdge) { - right += windowWidth - paperRightEdge; - } + var right = 50; + if(windowWidth > paperRightEdge) { + right += windowWidth - paperRightEdge; + } + + trashcan.css('right', right); + trashcan.css('bottom', bottom); + + var trashcanOffset = trashcan.offset(); + var paperOffset = paper.offset(); + trashcanAbsolutePaperX = trashcanOffset.left - paperOffset.left; + trashcanAbsolutePaperY = trashcanOffset.top - paperOffset.top; + } - trashcan.css('right', right); - trashcan.css('bottom', bottom); + function setupTrashcan() { + + var trashcan = $('#trashcanHolder'); + placeTrashcan(trashcan); - var trashcanOffset = trashcan.offset(); - var paperOffset = paper.offset(); - trashcanAbsolutePaperX = trashcanOffset.left - paperOffset.left; - trashcanAbsolutePaperY = trashcanOffset.top - paperOffset.top; + $(window).resize(function() { + placeTrashcan(trashcan); }); addReleaseListeners(trashcan[0]);