module.exports = class Element extends require 'ecl/dist/evented'module.exports = class Element extends require 'ecl/dist/evented' constructor: ->
superCopy the element origin if it was set from named arguments
if @origin then @origin = x:(@origin.x or 0), y:(@origin.y or 0)Register validating listeners for each type from the list.
for type in ['mousemove', 'mousedown', 'mouseup']Localize the type variable.
do (type) =>Add capturing listener which will cancel and stop the event if the event type is not enabled.
@addListener type:type, capture:yes, listener: (event) ->
event.cancel().stop() unless @events?[type]Add normal listener which will cancel and stop the event if the event type is not enabled.
@addListener type:type, capture:no, listener: (event) ->
event.cancel().stop() unless @events?[type]Register extendable listeners for each type from the list.
for type in ['mousemove', 'mousedown', 'mouseup']Add capturing extendable listener
@addListener type, this["#{type}CaptureListener"], yesAdd normal extendable listener
@addListener type, this["#{type}Listener"], noHelper method, to localize event coordinates.
localizeEventCoordinates: (event) ->Proceed only for valid event
if eventIf event already has localized x, use it instead of absolute x
x = (if event.localX? then event.localX else event.x)
event.localX = x - (@origin?.x or 0)If event already has localized y, use it instead of absolute y
y = (if event.localY? then event.localY else event.y)
event.localY = y - (@origin?.y or 0)
return this mousemoveCaptureListener: (event) ->Proceed only for valid event
if eventStore the event in the runtime for later and localize event coordinates
@___runtime.mousemoveEvent = event
@localizeEventCoordinates event
return this mousedownCaptureListener: (event) ->Proceed only for valid event
if eventStore the event in the runtime for later and localize event coordinates
@___runtime.mousedownEvent = event
@localizeEventCoordinates event
return this mouseupCaptureListener: (event) ->Proceed only for valid event
if eventStore the event in the runtime for later and localize event coordinates
@___runtime.mouseupEvent = event
@localizeEventCoordinates event
return this mousemoveListener: -> this mousedownListener: -> this mouseupListener: -> this