Deleting a scene in KineticJS

How to remove KineticJS Stage ?

Problem: stage.removeChildren() successfully removes its children, e.g. layers . However, stage.remove() does not delete the scene, as shown in jsfiddle below, where console.log(stage) after deletion still shows that the stage has not been deleted !!!

The .kineticjs-content div, created with Kinetic.Stage , also remained after .remove() executed.

jsfiddle: http://jsfiddle.net/jfaUg/

+4
source share
2 answers

The step cannot be deleted because the delete function is not applicable according to the current state of KineticJS. Function

  .remove () 
which you are trying to use is applicable for children of the "Container" class ( documentation ), and not the container object itself (Stage extends Container) i.e. say layer.remove() works, but stage.remove() will not
+1
source

You can always add:

 stage=null; document.getElementById("canvas").innerHTML = ''; 

http://jsfiddle.net/jfaUg/1/

0
source

All Articles