Animation needs to be stopped! Also fix some stray debugging code.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 14 Apr 2008 13:12:12 -0400
changeset 17 1115da66d337923f24189093db17c44e8fbe9414
parent 16 c428ff46384ed484dea0135bb9f3aa3f1a144628
child 18 d4ea0f486b60485e08715df03a1f5a9ed4988535
push id2
push userbsmedberg@mozilla.com
push dateMon, 14 Apr 2008 21:07:23 +0000
Animation needs to be stopped! Also fix some stray debugging code.
www/navigate.js
--- a/www/navigate.js
+++ b/www/navigate.js
@@ -1,43 +1,46 @@
 /* -*- Mode: Java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
 
-const BASEURL = 'http://hg.mozilla.org/%REPO%/index.cgi/';
+const BASEURL = '/hgwebdir.cgi/%REPO%/';
 const SVGNS = 'http://www.w3.org/2000/svg';
 
 const REVWIDTH = 254;
 const HSPACING = 40;
 const VSPACING = 30;
 const TEXTSTYLE = '12px sans-serif';
 
 const ANIMLENGTH = 500; /* milliseconds */
+const ANIMINTERVAL = 75;
 
 let gWidth, gHeight, gContext, gPendingRequest;
 let gAnimating = false;
 
 function startAnimating()
 {
   if (!gAnimating) {
     gAnimating = true;
-    setInterval(doAnimate, 50);
+    setTimeout(doAnimate, ANIMINTERVAL);
   }
 }
 
 function doAnimate()
 {
   redraw();
 
   let now = new Date().getTime();
 
   /* Clear our interval if there's nothing more to animate */
   for each (let rev in revs) {
-    if (rev._atime != null && rev._atime < now)
+    if (rev._atime != null && rev._atime + ANIMLENGTH > now) {
+      setTimeout(doAnimate, ANIMINTERVAL);
       return;
+    }
   }
-  clearInterval(doAnimate);
+  gAnimating = false;
 }
 
 function getCX()
 {
   let cx = $('#drawcanvas')[0].getContext('2d');
   cx.mozTextStyle = TEXTSTYLE;
   return cx;
 }
@@ -301,20 +304,16 @@ function doLayout()
     if (bottompositions[position]) {
       let p = bottompositions[position];
       let miny = p.y() + p.height() / 2 +
         rev.children[0].height() / 2 + VSPACING;
       if (y < miny)
         y = miny;
     }
 
-    if (isNaN(y)) {
-      throw ("y is NaN");
-    }
-    
     let rightEdge = gWidth; // XXX won't be true if we introduce scaling
 
     for each (let child in rev.children) {
       if (!child.gc) {
         child.gc = true;
         child.moveTo(x, y);
         y += child.height() + VSPACING;
         if (x < rightEdge) {
@@ -402,17 +401,16 @@ function doLayout()
       rev._x = null;
   }
   
   redraw();
 }
 
 function redraw()
 {
-  try {
   var cx = getCX();
 
   /**
    * Draw some text. Advance the translation down by 12px
    */
   function drawText(t, xoffset)
   {
     if (xoffset < 2)
@@ -484,20 +482,16 @@ function redraw()
       drawArrows(rev);
   }
   cx.restore();
 
   for each (let rev in revs) {
     if (rev.gc)
       drawRev(rev);
   }
-  }
-  catch (e) {
-    alert(e + "\nstack: " + e.stack);
-  }
 }
 
 function processContextData(data)
 {
   for each (var nodeObj in data.nodes) {
       getRevision(nodeObj.node).update(nodeObj);
   }