【问题标题】:kineticjs dragable limit with dragBounds - not runningDynamicjs 可拖动限制与拖动边界 - 未运行
【发布时间】:2013-03-29 16:39:03
【问题描述】:

我想用 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   
    }
});

这是我的代码http://jsfiddle.net/kien16/aUWY2/

【问题讨论】:

    标签: javascript canvas html5-canvas kineticjs


    【解决方案1】:

    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/

    【讨论】:

    • +1 删除了dragBounds 属性以支持dragBoundFunc,它可以实现无限的拖放行为
    猜你喜欢
    • 2010-12-05
    • 1970-01-01
    • 1970-01-01
    • 2012-06-18
    • 2014-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多