Search code examples
javascriptmouseeventkineticjs

mouse event using id in kineticjs


I want to add dragmove event to a particular image using id of image.It's not woring.

        $("#image1").on('dragmove', function(evt) {
            var shape = evt.targetNode;
            alert('you clicked on \"' + shape.getPosition().x + '\"');
        });

Solution

  • You can use find(id) or findOne(id) to get image instance on stage.

    stage.findOne('#image1').on('dragmove', function() {
        // here this refers to image instance
    });