[英]kinetic.js drag and drop doesn't work unless I enable it for the entire stage
When setting draggable
to true
for the objects, they aren't draggable unless I also enable it for the stage. 将对象的
draggable
设置为true
,除非我也为舞台启用了它们,否则它们是不可拖动的。 This is however very undesired in my application; 但是,这在我的应用程序中是非常不希望的; i want only some particular objects to be draggable.
我只希望某些特定对象可拖动。
function initGUI()
{
stage = new Kinetic.Stage(
{
container: 'stage',
width: w.innerWidth,
height: w.innerHeight,
// draggable: true // Uncommenting this makes everything draggable
});
layer = new Kinetic.Layer();
stage.add(layer);
var debugRect = new Kinetic.Rect(
{
fill: 'green',
x: 0,
y: 0,
draggable: true, // This isn't draggable despite this line
width: 200,
height: 200
})
layer.add(debugRect);
}
HTML: HTML:
<body>
<div id="stage"></div>
</body>
I've used Kinetic for some applications before but never encountered this. 我以前曾将Kinetic用于某些应用程序,但从未遇到过。
Please have a look.Its Working! 请看一下。它正在工作! Demo
演示版
var stage = new Kinetic.Stage({
container: 'container',
width: 578,
height: 500
});
var layer = new Kinetic.Layer();
stage.add(layer);
var debugRect = new Kinetic.Rect(
{
fill: 'green',
x: 0,
y: 0,
draggable: true, // This isn't draggable despite this line
width: 200,
height: 200
})
layer.add(debugRect);
layer.draw();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.