javascript - Displaying value on KineticJs Text() -
i want change text in container kinetic js using keyup event in jquery doesn't display. tried getting value display on span element , works fine. here's code:
var stage = new kinetic.stage({ container: 'canvascontainer', width: 800, height: 800 }); var layer = new kinetic.layer(); var message = ''; $(function(){ $('#txtarea').change(function(){ message = $(this).val(); $('.output').text(message); var simpletext = new kinetic.text({ x: 0, y: 10, text: message, fontsize: 30, fontfamily: 'calibri', fill: 'blue' }); layer.add(simpletext); }).keyup(function(){ $(this).change(); }); }); stage.add(layer);
after add or change kinetic object, sure call layer.draw() cause drawing visible.
btw, instead of adding new simpletext each change, might want change text in existing text object
// declare simpletext before .change() var simpletext = new kinetic.text({ x: 0, y: 10, text: "", fontsize: 30, fontfamily: 'calibri', fill: 'blue' }); layer.add(simpletext); // inside .change() simpletext.settext(message); layer.draw();
Comments
Post a Comment