javascript - kinetic js - how do I modify attributes dynamically (onmouseover) -
i have following code, position doesn't vary mouseover - missing?
function drawoverlay() { var stage = new kinetic.stage({container: 'overlay'}); var layer = new kinetic.layer(); var rect = new kinetic.rect({ x: 239, y: 75, width: 100, height: 50, fill: 'green', stroke: 'black', strokewidth: 4 }); rect.on('mouseover', function(e) {rect.setposition({x: 50, y: 5 0});}); layer.add(rect); stage.add(layer); }
two problems here:
- your y value has space in it: "5 0" vs. "50", causes javascript parsing error.
- you need redraw layer after changing position of node.
so try this:
rect.on('mouseover', function(e) { rect.setposition({x: 50, y: 50}); layer.draw(); });
Comments
Post a Comment