Browse files

Bug 736329: Fix window resize bug

  • Loading branch information...
1 parent db02ded commit e5009154c311b25900d85e3c841990c37327dcab @glecollinet glecollinet committed Mar 20, 2012
Showing with 22 additions and 11 deletions.
  1. +7 −0 client/css/main.css
  2. +2 −0 client/index.html
  3. +8 −0 client/js/app.js
  4. +1 −3 client/js/game.js
  5. +4 −8 client/js/main.js
View
7 client/css/main.css
@@ -247,6 +247,8 @@ footer, header, hgroup, menu, nav, section {
#instructions, #achievements, #lists, #about, #credits, .ribbon, .play, .play div, .barbutton {-webkit-tap-highlight-color:transparent;}
#nameinput::-webkit-input-placeholder {color:#fff;}
+ #resize-check {position:absolute;height:0;top:0;left:0;-moz-transition:0.001s height ease;-webkit-transition:0.001s height ease;-o-transition:0.001s height ease;-ms-transition:0.001s height ease;transition:0.001s height ease;}
+
/* Magic Parchment */
.parchment-left {position:absolute;top:0;left:0%;}
@@ -568,6 +570,7 @@ footer, header, hgroup, menu, nav, section {
.game.credits .parchment-middle, .game.death .parchment-middle, .game.about .parchment-middle {width:1038px;margin-left:-519px;background-position: -114px -882px;}
footer {font-size:20px;}
+ #resize-check {height:3px;}
}
@media screen and (max-width: 1500px) {
@@ -727,6 +730,7 @@ footer, header, hgroup, menu, nav, section {
.game.credits .parchment-middle, .game.death .parchment-middle, .game.about .parchment-middle {width:692px;margin-left:-346px;background-position: -76px -588px;}
footer {font-size:16px;}
+ #resize-check {height:2px;}
}
@media screen and (max-height: 850px) {
@@ -885,6 +889,7 @@ footer, header, hgroup, menu, nav, section {
.game.credits .parchment-middle, .game.death .parchment-middle, .game.about .parchment-middle {width:692px;margin-left:-346px;background-position: -76px -588px;}
footer {font-size:16px;}
+ #resize-check {height:2px;}
}
@media screen and (max-width: 1000px) {
@@ -1041,6 +1046,7 @@ footer, header, hgroup, menu, nav, section {
.game .parchment-middle {background-position: -211px -294px;}
.game.credits .parchment-middle, .game.death .parchment-middle, .game.about .parchment-middle {width:346px;margin-left:-173px;background-position: -38px -294px;}
+ #resize-check {height:1px;}
}
@media screen and (max-width: 800px) {
@@ -1088,6 +1094,7 @@ footer, header, hgroup, menu, nav, section {
#chatbox {height:32px;width:480px;background-size:960px;background-position:0 -64px;margin-left:-240px;bottom:2px;}
#chatbox.active {bottom:34px;}
#chatbox input {font-size:20px;color:#eee;background:none;width:90%;border:0;margin-left:2%;padding:7px 0;}
+ #resize-check {height:1px;}
}
@media screen and (max-width: 600px) {
View
2 client/index.html
@@ -322,6 +322,8 @@ <h1 id="logo">
</ul>
<img src="img/common/thingy.png" alt="" class="preload">
+
+ <div id="resize-check"></div>
<script type="text/javascript">
var ctx = document.querySelector('canvas').getContext('2d'),
View
8 client/js/app.js
@@ -513,6 +513,14 @@ define(['jquery', 'storage'], function($, Storage) {
resetMessageTimer: function() {
clearTimeout(this.messageTimer);
+ },
+
+ resizeUi: function() {
+ if(this.game && this.game.started) {
+ this.game.resize();
+ this.initHealthBar();
+ this.game.updateBars();
+ }
}
});
View
4 client/js/game.js
@@ -2244,14 +2244,12 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
y = this.camera.y,
currentScale = this.renderer.scale,
newScale = this.renderer.getScaleFactor();
-
- if(currentScale !== newScale || this.renderer.mobile) {
+
this.renderer.rescale(newScale);
this.camera = this.renderer.camera;
this.camera.setPosition(x, y);
this.renderer.renderStaticCanvases();
- }
},
updateBars: function() {
View
12 client/js/main.js
@@ -148,6 +148,10 @@ define(['jquery', 'app'], function($, App) {
});
document.addEventListener("touchstart", function() {},false);
+
+ $('#resize-check').bind("transitionend", app.resizeUi.bind(app));
+ $('#resize-check').bind("webkitTransitionEnd", app.resizeUi.bind(app));
+ $('#resize-check').bind("oTransitionEnd", app.resizeUi.bind(app));
log.info("App initialized.");
@@ -390,14 +394,6 @@ define(['jquery', 'app'], function($, App) {
}
});
- $(window).resize(function() {
- if(game && game.started) {
- game.resize();
- app.initHealthBar();
- game.updateBars();
- }
- });
-
if(game.renderer.tablet) {
$('body').addClass('tablet');
}

0 comments on commit e500915

Please sign in to comment.