I have the following html:
JavaScript
x
6
1
<svg:g *ngFor='let knob of knobs' >
2
<svg:path id="arc1" fill="blue" stroke="#446688" stroke-width="1"
3
fill-rule="nonzero" draggable="true" [attr.d]="knob"
4
(drag)="dragKnob(event)" class="draggable"/>
5
</svg:g>
6
And the script:
JavaScript
1
4
1
dragKnob(event: Event): void {
2
console.log(event);
3
}
4
The result is it doesn’t execute dragKnob. If I instead use (click) it works as expected.
Any ideas?
Advertisement
Answer
Drag events are not supported on SVG Elements:
http://www.w3.org/TR/SVG/svgdom.html#RelationshipWithDOM2Events.
if you want to do something while the object is dragged use (mousemove) instead.
JavaScript
1
2
1
(mousemove)="dragKnob(event)"
2
And this should write to console:
JavaScript
1
4
1
dragKnob(event: Event): void {
2
console.log(event);
3
}
4