ash*_*hen 3 javascript drag-and-drop image html5-canvas kineticjs
我正在尝试使用html5 img标记将多个图像加载到画布上.
并且图像是可替换的.例如,有5个图像列表图像也是可拖动的,
并且特定图像的单击替换了来自同一列表的最后上载的图像,
我面临的问题是,当我上传新元素时它会出现其他的顶部.并点击底部元素,我希望它移动到顶部并拖动.我试图使用kineticjs函数调用移动到顶部但没有发生任何事情..我也检查了库,它很好......
我不能粘贴我的完整代码,因为它太大了.
这是我试图将移动添加到顶级功能的部分:
function drawImageOnLayer(layer, img) {
var x = stage.width / 2 - 100 ;
var y = stage.height / 2 - 200 ;
var width = 200;
var height = 400;
var kinecticImg = new Kinetic.Shape(function(){
var context = this.getContext();
context.drawImage(img, x, y, width, height);
// draw invisible detectable path for image
context.beginPath();
context.rect(x, y, width, height);
context.closePath();
});
// enable drag and drop
kinecticImg.draggable(true);
Run Code Online (Sandbox Code Playgroud)
这个功能不起作用
kinecticImg.on("mousedown", function(){
this.moveToTop();
layer.draw();
Run Code Online (Sandbox Code Playgroud)
结束
});
layer.clear();
layer.add(kinecticImg);
layer.draw();
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2643 次 |
最近记录: |