ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 752 forks source link

Canvas not clearing before redraw #984

Open kenlimmj opened 10 years ago

kenlimmj commented 10 years ago

I'm having a similar problem as in #853, but that's closed so I'm reopening it with a bit more details. If I'm doing something wrong please forgive me and tell me how I can fix up my issue filing.

I have a Kinetic.Stage containing a single Kinetic.Layer, which in turn contains a Kinetic.Circle object.

The gist of the bug is that when I try to change the location of the circle by changing the x and y positions, then calling draw(), the position is changed correctly, but the old circle is not removed from the canvas. I've tried manually clearing the canvas (using clear()) before calling the draw operation, and I've tried everything from using setAbsolutePosition to setting it directly using x() and y() -- no luck.

So before this I was running everything off a local server at localhost:8080. The moment I switched to 127.0.0.1:8080, all the problems disappeared and everything works exactly as expected.

I've done my best to verify that I'm not running anything fancy that could be messing with the canvas depending on whether I'm passing in a direct IP address or if I'm using a string address. If it helps, I'm running Chrome 36 on OS X.

Would appreciate if anyone had any ideas!

lavrton commented 10 years ago

Can you provide jsfiddle? If you are calling draw on any node (except Layer and Stage) it will not remove "old" node from canvas. Just draw new on top of canvas.