Skip to content
Narayana Swamy edited this page Apr 9, 2018 · 5 revisions

.on(eventType, eventHandler)

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.
             })

Drag

DragEvent API is used to perform drag actions on layer. Drag action is subdivided into 3 stages - "dragStart", "drag", "dragEnd"

dragObj.dragStart(function(){})

Callback gets triggered only once, when drag starts.

dragObj.drag(function(){})

Callback gets triggered after dragStart till dragEnd.

dragObj.dragEnd(function(){})

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){

	            })

Support

SVG Events

SVGrenderer supports all events supported by the Dom.

Canvas Events

CanvasRenderer as of now supports only below mentioned events. Will extend to support other Dom based events.

Mouse 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