client/js/podium.js
changeset 13 e42d9f11f6e2
parent 10 dd7d86fbee70
child 44 02971f8dcaa5
--- a/client/js/podium.js	Mon Feb 20 17:44:20 2012 +0100
+++ b/client/js/podium.js	Tue Feb 21 11:48:06 2012 +0100
@@ -25,8 +25,8 @@
 }
 
 Btv_Podium.prototype.update = function(data, noAnimate) {
-    var _data = data || [];
-    var i = 0;
+    var _data = data || [],
+        _oldcount = this._$.children().length;
     while (_data.length > this._$.children().length) {
         var _newCol = document.createElement("div");
         this.$(_newCol).css({
@@ -38,10 +38,6 @@
             "margin-left": 0
         });
         this._$.append(_newCol);
-        i++;
-        if (i > 10) {
-            break;
-        }
     }
     while (_data.length < this._$.children().length) {
         this._$.children().last().detach();
@@ -55,13 +51,16 @@
             _width = Math.floor(( this.options.width - (_data.length - 1) * _spacing) / _data.length),
             _this = this;
         this._$.children().each(function(_i, _e) {
-            var _height = _scale * _data[_i] + _this.options.minHeight,
-                _css = {
-                    "margin-top": _this.options.height - _height,
-                    "height": _height,
-                    "width": _width,
-                    "margin-left": (_i ? _spacing : 0)
-                }
+            var _height = Math.floor(_scale * _data[_i] + _this.options.minHeight),
+                _css = {};
+            if (_height != _this.$(_e).height()) {
+                _css["margin-top"] = _this.options.height - _height,
+                _css["height"] = _height
+            }
+            if (_data.length != _oldcount) {
+                _css["width"] = _width;
+                _css["margin-left"] = (_i ? _spacing : 0);
+            }
             if (noAnimate) {
                 _this.$(_e).css(_css); 
             } else {