嗨,我有两个重叠的形状(在 KineticJs 中的实现)。如果鼠标悬停在它们上方,我想更改这些形状的颜色。如果鼠标悬停在重叠(交叉)区域上方,我希望两个形状都改变颜色。然而,只有最上面的形状会改变颜色。
http://jsfiddle.net/sandeepy02/NST8C/的示例,如果我将鼠标悬停在 pverlapped 区域上,我希望两个矩形的颜色都是黑色的。
stage = new Kinetic.Stage({
container: "container",
width: 320,
height: 320
});
layer = new Kinetic.Layer();
elemOne = new Kinetic.Rect({
x: 100,
y: 100,
width: 100,
height: 100,
fill: 'red',
stroke: 'black',
strokeWidth: 0,
draggable: false
});
elemOne.on('mousemove', function() {
this.setFill("black");
this.setZIndex(10);
layer.draw();
});
elemOne.on('mouseout', function() {
this.setFill("red");
this.setZIndex(1);
layer.draw();
});
elemTwo = new Kinetic.Rect({
x: 150,
y: 150,
width: 100,
height: 100,
fill: 'green',
stroke: 'black',
strokeWidth: 0,
draggable: false
});
elemTwo.on('mousemove', function() {
this.setFill("black");
this.setZIndex(10);
layer.draw();
});
elemTwo.on('mouseout', function() {
this.setFill("green");
this.setZIndex(1);
layer.draw();
});
layer.add(elemOne);
layer.add(elemTwo);
stage.add(layer);