问题
Could someone help me?
I have a stage and image and i want to change width and height from input. this is code and it does no work :/ help me.)
var stage = new Kinetic.Stage({ container: 'containerCreator', width: imageWidth, height: imageHeight });
var layer = new Kinetic.Layer();
var imageObj = new Image();
imageObj.onload = function(){
var yoda = new Kinetic.Image({
x: 0,
y: 0,
image: imageObj,
width: imageWidth,
height: imageHeight
});
layer.add(yoda);
layer.add(vrchnyText);
stage.add(layer);
};
imageObj.src = imageSource;
$('#vrchCreator').keyup(function(){
stage.width = $(this).val();
stage.height= $(this).val();
layer.add(yoda);
stage.add(layer);
});
回答1:
You want to change this to:
$('#vrchCreator').keyup(function()
{
stage.setWidth(parseInt($(this).val()));
stage.setHeight(parseInt($(this).val()));
layer.add(yoda);
stage.add(layer);
});
来源:https://stackoverflow.com/questions/14696875/change-width-stage-from-input