Closed 348339749 closed 4 years ago
@348339749 You must call drawLayers() after calling removeLayer() to redraw the canvas. So your modified example would become:
$("canvas").drawPolygon({
fillStyle: "#6c3",
x: 100, y: 100,
radius: 50, sides: 5,
layer:true,
click:function(layer){
$("canvas").removeLayer(layer).drawLayers();
}
});
The reason your code works when you mouse out of the canvas is because jCanvas automatically redraws the canvas upon mouseout. But in this particular instance, you must redraw the canvas manually after removing the layer.
jcanvas21.0.1 in fireFox(70.0.1 ) when i use removeLayer() or removeLayers(),i have to move mouse out of canvas, or double click on layer to delete this layer . this is my code: $("canvas").drawPolygon({ fillStyle: "#6c3", x: 100, y: 100, radius: 50, sides: 5, layer:true, click:function(layer){ $("canvas").removeLayer(layer); } });
first click (mousedown,mouseup) nothing change,move out or click again ,the layer will remove.