<commit_before>Style = require './style'
Event = require './event'

module.exports = class Component extends require './shape'
<commit_msg>component functionality added<commit_after>Event = require './event'

module.exports = class Component extends require './shape'
  constructor: (args = {}) ->
    super
    for name in ['grab', 'release', 'drag']
      do (name) =>
        @addListener name, ((e) -> e.stop() unless @events?[name]), yes
        @addListener name, ((e) -> e.stop() unless @events?[name]), no

    for name in ['grab', 'release', 'drag']
      @addListener name, this["#{name}CaptureListener"], yes

  mousemoveListener: (event) ->
    super
    $ = @___runtime
    if $.grab
      @broadcastEvent $.dragEvent = new Event type:'drag',
        x:event.x, y:event.y, target:this
        offsetX: x - ($.dragEvent?.x or $.grabEvent?.x or 0)
        offsetY: y - ($.dragEvent?.y or $.grabEvent?.y or 0)
    return this

  mousedownListener: (event) ->
    super
    ($ = @___runtime).grab = true
    if @state is 'active'
      @broadcastEvent $.grabEvent = new Event type:'grab',
        x:event.x, y:event.y, target:this
    return this

  mouseupListener: (event) ->
    super
    ($ = @___runtime).grab = false
    @broadcastEvent $.grabEvent = new Event type:'release',
      x:event.x, y:event.y, target:this
    return this

  dragCaptureListener: (event) ->
    @___runtime.dragEvent = event
    localizeEventCoordinates event, @origin
    return this

  grabCaptureListener: (event) ->
    @___runtime.grabEvent = event
    localizeEventCoordinates event, @origin
    return this

  releaseCaptureListener: (event) ->
    @___runtime.releaseEvent = event
    localizeEventCoordinates event, @origin
    return this

  dragListener: -> this

  grabListener: -> this

  releaseListener: -> this

{'fraction_non_alphanumeric': 0.13853765805387575, 'fraction_numerical': 0.0010995052226498076, 'mean_word_length': 3.0534521158129175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7120975', 'n_tokens_mistral': 563, 'n_tokens_neox': 553, 'n_words': 155}