开发者

How to have 2 or more canvas in the same page.. not as layers

开发者 https://www.devze.com 2023-02-13 04:48 出处:网络
I have a page where I\'ve 2 canvas. One for tracking mouse position and another for simple drawing. Both the code are working but not as expected.

I have a page where I've 2 canvas. One for tracking mouse position and another for simple drawing. Both the code are working but not as expected.

  1. Both the canvas got pushed down..
  2. Displays both the canvas but
  3. Uses only one o开发者_开发技巧f the canvas to display the results

. Why?? Here is the link to my page Canvas, Expected Output


You were appending both canvas elements each time. Heres the area of code that does it, and a quick check i put in place.

if(flag ===1){
    canvasDiv1.appendChild(canvas);
}else{
    canvasDiv2.appendChild(canvas);
}

Here is a link to the full code, and what I assume you were going for.

http://jsfiddle.net/loktar/R3hyg/

0

精彩评论

暂无评论...
验证码 换一张
取 消