How to hide all group children using kineticjs?

by ryan.murray , in category: Javascript , a month ago

How to hide all group children using kineticjs?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by kadin , a month ago

@ryan.murray 

You can hide all group children in KineticJS by setting the opacity of the group to 0. Here is an example code snippet:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
var stage = new Kinetic.Stage({
  container: 'container',
  width: 500,
  height: 500
});

var layer = new Kinetic.Layer();
stage.add(layer);

var group = new Kinetic.Group();

// Add children to group here

layer.add(group);
layer.draw();

// Hide all group children
group.setOpacity(0);
layer.draw();


This code creates a group and adds it to a layer on the stage. To hide all children in the group, you simply set the opacity of the group to 0. This will make all children inside the group invisible. Remember to redraw the layer after making the changes.