Javascript Resizeable无法使用kinetic.js文件工作

Javascript Resizeable无法使用kinetic.js文件工作,javascript,jquery,kineticjs,Javascript,Jquery,Kineticjs,我在动态层的一个任务中工作,希望通过kinectic调整大小。图层功能 对于ex: 当我点击矩形按钮时,矩形将显示在画布上 而且它也在工作,事实上它也可以拖动。现在,问题来了,我想做一个可动态调整大小的矩形,但它不能根据kinectic.js函数工作 为了清楚起见,让我们看看图像 这是我的矩形代码 function addShape(w,h,c){ var layerRect = new Kinetic.Layer(); layerRect.add(new Kinetic.

我在动态层的一个任务中工作,希望通过kinectic调整大小。图层功能

对于ex:

当我点击矩形按钮时,矩形将显示在画布上

而且它也在工作,事实上它也可以拖动。现在,问题来了,我想做一个可动态调整大小的矩形,但它不能根据
kinectic.js
函数工作

为了清楚起见,让我们看看图像

这是我的矩形代码

function addShape(w,h,c){
    var layerRect = new Kinetic.Layer();
      layerRect.add(new Kinetic.Rect({
          x:0,
          y:0,
          width:w,
          height:h,
          fill: c,
          draggable: true
      }));
      stage.add(layerRect);

var kShaped;
var startRight=-1;
var startWidth=0;
var startHeight=0;

$(stage.getContent()).on('mousedown', function (event) {
  var pos=stage.getPointerPosition();
  var mouseX=parseInt(pos.x);
  var mouseY=parseInt(pos.y);
  var ipos=layerRect.position();
  var isize=layerRect.getSize();
  var right=ipos.x+isize.width;
  if(mouseX>right-10 && mouseX<right+10){
    startRight=mouseX;
    startWidth=isize.width;
    startHeight=isize.height;
  }
});

$(stage.getContent()).on('mouseup', function (event) {
  startRight=-1;
});

$(stage.getContent()).on('mousemove', function (event) {
  if(startRight>=0){
    var pos=stage.getPointerPosition();
    var mouseX=parseInt(pos.x);
    var mouseY=parseInt(pos.y);
    var dx=mouseX-startRight;
    var scaleFactor=(mouseX-(startRight-startWidth))/startWidth;
    layerRect.width(startWidth*scaleFactor);
    layerRect.height(startHeight*scaleFactor);
    layer.draw();
  }
});
}   

//This click function is for create rectangle shape
$("#textsubmitShape").live("click",function(){
    addShape(200,100,"Green");
});
函数addShape(w、h、c){
var layerRect=新的动能.Layer();
layerRect.add(新的Dynamic.Rect({
x:0,,
y:0,
宽度:w,
高度:h,,
填充:c,
德拉格布尔:是的
}));
阶段。添加(层更正);
var-k形;
var startRight=-1;
var startWidth=0;
var startHeight=0;
$(stage.getContent()).on('mousedown',函数(事件){
var pos=stage.getPointerPosition();
var mouseX=parseInt(位置x);
var mouseY=parseInt(位置y);
var ipos=layerRect.position();
var isize=layerRect.getSize();
var right=ipos.x+isize.width;
如果(mouseX>right-10&&mouseX=0){
var pos=stage.getPointerPosition();
var mouseX=parseInt(位置x);
var mouseY=parseInt(位置y);
var dx=mouseX startRight;
var scaleFactor=(mouseX-(startRight-startWidth))/startWidth;
图层正确宽度(起始宽度*缩放因子);
图层正确高度(起始光*比例因子);
layer.draw();
}
});
}   
//此单击功能用于创建矩形形状
$(“#textsubmitShape”).live(“单击”,函数(){
addShape(200100,“绿色”);
});