谁能告诉我如何使用kinetic.js隐藏 Canvas 中的 anchor 并在单击图像时显示 anchor 。 例如check this link我们可以隐藏 anchor 。 我已经完成了应用程序,因为我需要在单击 Canvas 后隐藏 anchor ,我可以拍摄大量图像,并且可以拖放、调整大小并将它们另存为图像。 我试图隐藏 anchor ,但没有成功,任何人都可以指导我,提前致谢。
最佳答案
这不是一个完整的解决方案,但请看一下:http://jsfiddle.net/n9FLA/1/
您想要做的是附加事件处理程序,以便在组中添加或删除 anchor 。查看您提供的链接,您应该进行如下更改:
yodaGroup.on('mouseover', function(){
addAnchor(yodaGroup, yodaImg.getX(), yodaImg.getY(), 'topLeft');
addAnchor(yodaGroup, yodaImg.getX()+yodaImg.getWidth(), yodaImg.getY(), 'topRight');
addAnchor(yodaGroup, yodaImg.getX()+yodaImg.getWidth(), yodaImg.getY()+yodaImg.getHeight(), 'bottomRight');
addAnchor(yodaGroup, yodaImg.getX(), yodaImg.getY()+yodaImg.getHeight(), 'bottomLeft');
layer.draw();
});
yodaGroup.on('mouseout', function(){
var yodaKids = yodaGroup.getChildren();
for(var i=1; i<yodaKids.length; i++)
yodaKids[i].hide(); // .remove() would also work, or .destroy()
layer.draw();
});
您必须构建逻辑并选择您想要的事件,但这就是您可以做到的方式。
关于html5-canvas - 如何隐藏 anchor 并在点击图像时显示 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14830879/