add tile merging
[2048.git] / js / html_actuator.js
blob:a/js/html_actuator.js -> blob:b/js/html_actuator.js
--- a/js/html_actuator.js
+++ b/js/html_actuator.js
@@ -36,16 +36,19 @@
 
   this.tileContainer.appendChild(element);
 
-
   if (tile.previousPosition) {
     window.requestAnimationFrame(function () {
       element.classList.remove(element.classList[2]);
       element.classList.add(self.positionClass({ x: tile.x, y: tile.y }));
     });
+  } else if (tile.mergedFrom) {
+    element.classList.add("tile-merged");
+    tile.mergedFrom.forEach(function (merged) {
+      self.addTile(merged);
+    });
   } else {
     element.classList.add("tile-new");
   }
-
 };
 
 HTMLActuator.prototype.normalizePosition = function (position) {

comments