Events
Narayana Swamy edited this page Apr 9, 2018
·
5 revisions
Accepts eventType and eventHandler as an arguments. Eventhandler receives data object, if there is any data binded, and/or event object.
element.on('click',function(data, event){ // if no data binded, then only event object.
this //this refers to the element context.
})
DragEvent API is used to perform drag actions on layer. Drag action is subdivided into 3 stages - "dragStart", "drag", "dragEnd"
Callback gets triggered only once, when drag starts.
Callback gets triggered after dragStart till dragEnd.
Callback gets triggered once drag action Ends.
dragEvent = i2d.dragEvent()
dragEvent.dragStart(function(event, e){
})
.drag(function(event, e){
var currTranslate = g.getAttr('transform').translate
g.translate([currTranslate[0]+e.dx,currTranslate[1]+e.dy])
})
.dragEnd(function(event, e){
})
SVGrenderer supports all events supported by the Dom.
CanvasRenderer as of now supports only below mentioned events. Will extend to support other Dom based events.
- click - To handle click events
- dblclick - To handle double click events
- mouseover - To handle mouseover events
- mouseout - To handle mouseout events
- mousemove - To handle mousemove events
- mousedown - To handle mousedown events
- mouseup - To handle mouseup events
Documentation