Elhellawy / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

endles-loop when DIV is hidden ( #349

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. set the style of the DIV containing a timeplot (or any predecessor of
this DIV) to 'display:none'
2. try to load the containing page

What is the expected output? What do you see instead?
The script seems to run in an endless-loop when trying to draw a
timeplot-diagramm, google chrome and IE8 exit with an error, Firefox does
not respond.

What version of the product are you using? On what browser and what
operating system?
timeplot 1.1; tested with FF, IE and Chrome, Windows Vista

Original issue reported on code.google.com by tobias.m...@gmail.com on 10 Feb 2010 at 4:47

GoogleCodeExporter commented 8 years ago
Hi,

I found the same problem in chrome. After some research I found the cause:

   In method _prepareCanvas the canvas height is set according to the container's div height minus the paddingY

   canvas.height=this.getHeight()-(this._paddingY*2);

   According to the HTML5 reference (http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html) the canvas element can't have a negative height. So when this.getHeight() is 0 (because the div is hidden) canvas.height must be 0 not -(this._paddingY*2).

   But chrome allows a negative value for canvas height, so when you reach the function _calculateGrid, you'll be stuck in a loop:

   _calculateGrid : function(){
    //code code
    //this.toScreen(..) will return a negative value
    var dy = this.toScreen(this._minValue + inc);
        // dy is negative and it's value will increase towards a bigger negative value
    while (dy < this._gridSpacing) {
      inc = new Number(inc).add(unit);
          dy = this.toScreen(this._minValue + inc);
    }

    //code code
   }

   The quickÇ/easy fix is to add an extra check at the beggining of _calculateGrid():

   if (!this._canvas || this._valueRange == 0 || this._canvas.height <= 0) return grid;

Original comment by madtr...@gmail.com on 8 Nov 2010 at 8:47

GoogleCodeExporter commented 8 years ago

Original comment by ryan...@csail.mit.edu on 23 Jun 2011 at 10:23