Well, i decided to do it in a diferent way, which i think is more
accurate.
I still want to do the same as before but let me explain in more
detail what i wantto do:
1.Explanation:
On page load an object instance is created. This instance dynamically
creates a canvas tag, draws some grid lines and then appends it to the
DOM. Then the user should be able to select a zoom view and the
drawing should be redrawn with a diferent scale.
2.The code
The code bellow should clear the drawing, scale it, and redraw it
again thus making a zoom effect.
function scaleStage() {
// clear canvas
this.canvasStage_ctx.clearRect(0, 0, this.getCurrentStageDim().width,
this.getCurrentStageDim().height);
// define new scale
this.canvasStage_ctx.scale(this.currentZoom[0],this.currentZoom[0]);
// draw vertical lines
var sumWidth = this.stageGridWidth; // first x position
while (sumWidth <= this.getCurrentStageDim().width)
{
this.canvasStage_ctx.moveTo(sumWidth,0);
this.canvasStage_ctx.lineTo(sumWidth,this.getCurrentStageDim().height);
sumWidth += this.stageGridWidth;
}
this.canvasStage_ctx.stroke();
//draw horizontal lines
var sumHeight = this.stageGridHeight; // first y position
while (sumHeight <= this.getCurrentStageDim().height)
{
this.canvasStage_ctx.moveTo(0,sumHeight);
this.canvasStage_ctx.lineTo(this.getCurrentStageDim().width,sumHeight);
sumHeight += this.stageGridHeight;
}
this.canvasStage_ctx.stroke();
}
3. The problem
In IE works fine.
In FF it does not.
What happens is that the new drawing is made with the new scale, but
the clearRect method doesn't seem to be working because the initial
drawing is still there.
Howerver, if scaleStage only calls clearRect (and don't draw anything)
the drawing is actually cleared.
Any ideas?