Reputation: 4676
I have a working script to apply transformations to SVG so that the image is draggable. The script works when I use the attributes of the html element.
<g id="all" onmousedown="startMove(evt)" onmousemove="moveIt(evt)" onmouseup="endMove(evt)">
However I would like to bind the events with Jquery something like below and wonder where I am going wrong with the code below
$('svg > g').mousedown(startMove(evt));
$('svg > g').mousemove(moveIt(evt));
$('svg > g').mouseup(endMove(evt));
Upvotes: 0
Views: 710
Reputation: 35194
Try this:
$('svg > g').mousedown(function(evt){
//do stuff
});
or even
$('svg > g').mousedown(startMove);
function startMove(evt){
//do stuff
}
startMove
references the actual function, while startMove()
uses it's return value.
Upvotes: 1
Reputation: 10469
I believe you have to do it like so:
$('svg > g').mousedown(function(evt){
startMove(evt);
});
Upvotes: 0