我想拖动我的舞台,限制顶部,左侧,右侧,底部使用dragBounds,但它不起作用
var stage = new Kinetic.Stage({
container: 'container',
width: 578,
height: 363,
draggable: true,
dragBoundFunc: function(pos) {
var newY = pos.y < 50 ? 50 : pos.y;
return {
x: pos.x,
y: newY
};
},
dragBounds: { // it's not running
top: 10,
bottom: 300,
left: 0,
right: 500
}
});
答案 0 :(得分:4)
dragBounds
不在当前版本的KineticJS中...使用dragBoundFunc
请在此处查看示例:Kineticjs dragBoundFunc for a rect in a rect
以下是kineticJS网站的教程:http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-shapes-horizontally-or-vertically-tutorial/