Hide a single element in a layer - Kineticjs -
this code uses kineticjs. using mouseover , mouseout events 1 of images. layer has 2 images. want hide 1 of them. need create separate layer each image?
img.onload = function(){ var image = new kinetic.image({ image: img, name:'iconimage', width: 50, height: 50, //draggable: true, //visible:true, listening:true }); var image2 = new kinetic.image({ x:100, y:100, image: img, name:'iconimage', width: 50, height: 50, //draggable: true, //visible:true, listening:true }); iconlayer.add(image).add(image2); stage.add(iconlayer); //stage.draw(); image.on('mouseover',function(){ image.hide(); iconlayer.clear(); //iconlayer.draw(); }); image.on('mouseout',function(){ //iconlayer.clear(); //image.show(); //iconlayer.draw(); image.show(); iconlayer.draw(); //stage.draw(); }); }
which best way use hide() , show() functions?
you don't need separate layer.
just use myshape.hide() , myshape.show()
Comments
Post a Comment