<commit_before>{settings} = require '../package.json'
module.exports =
class Guesture
  space: 20
  minActivate: 40
  move :
    left : {}
    right : {}
  on : {}

  #@on.left =  (event) ->
  #@on.right
  #same for right
  constructor: (options) ->
    {@on,@space,@minActivate} = options
    @addEventListener()

  addEventListener: ->
    addEventListener = document.body.addEventListener
    addEventListener 'mousedown', (e) => @fortifyEvent e,@mouseDown
    addEventListener 'mousemove', (e) => @fortifyEvent e,@mouseMove
    addEventListener 'mouseup', (e) => @fortifyEvent e,@mouseUp

  fortifyEvent: (event,callFunction) ->
    event.left = event.clientX
    event.winWidth = window.innerWidth
    event.right = event.winWidth-event.left
    event.diff = {} =
      left : if @move.left.start? then (event.left-@move.left.start) else undefined
      right : if @move.right.start? then (event.right-@move.right.start) else undefined
    callFunction event

  mouseDown: (e) =>
    @checkDown 'left', e
    @checkDown 'right', e
    # if event.left <= @space and @on.left?
    #   @move.left.start = event.left
    # else if event.right <= @space and @on.right?
    #   @move.right.start = event.right
  checkDown: (direction,event) ->
    if event[direction] <= @space and @on[direction]?
      @move[direction].start = event[direction]
  mouseMove: (e) =>
    @checkMove 'left', e
    @checkMove 'right', e
    # @move.left.activate = true if event.diff.left >= @minActivate
    # @move.right.activate = true if event.diff.right >= @minActivate
    # if @on.left? and @move.left.activate?
    #   @on.left event
    # else if @on.left? and @move.right.activate?
    #   @on.right event
  checkMove: (direction,event) ->
    @move[direction].activate = true if event.diff[direction] >= @minActivate
    if @on[direction]? and @move[direction].activate?
      @on[direction] event
  mouseUp: (e) =>
    e.end = true
    @checkUp 'left', e
    @checkUp 'right', e
    # if @move.left.activate
    #   @on.left event
    #   @stopMove 'left'
    # if @move.right.activate
    #   @on.right event
    #   @stopMove 'right'
  checkUp: (direction,event) ->
    if @move[direction].activate
      @on[direction] event
      @move[direction] = {}

  stopMove: (name) ->
    @move[name] = {}<commit_msg>pretify Guesture<commit_after>{settings} = require '../package.json'
module.exports =
class Guesture
  space: 20
  minActivate: 40
  move :
    left : {}
    right : {}
  on : {}

  constructor: (options) ->
    {@on,@space,@minActivate} = options
    @addEventListener()

  addEventListener: ->
    addEventListener = document.body.addEventListener
    addEventListener 'mousedown', (e) => @fortifyEvent e,@mouseDown
    addEventListener 'mousemove', (e) => @fortifyEvent e,@mouseMove
    addEventListener 'mouseup', (e) => @fortifyEvent e,@mouseUp

  fortifyEvent: (event,callFunction) ->
    event.left = event.clientX
    event.winWidth = window.innerWidth
    event.right = event.winWidth-event.left
    event.diff = {} =
      left : if @move.left.start? then (event.left-@move.left.start) else undefined
      right : if @move.right.start? then (event.right-@move.right.start) else undefined
    callFunction event

  mouseDown: (e) =>
    @checkDown 'left', e
    @checkDown 'right', e
  checkDown: (direction,event) ->
    if event[direction] <= @space and @on[direction]?
      @move[direction].start = event[direction]

  mouseMove: (e) =>
    @checkMove 'left', e
    @checkMove 'right', e
  checkMove: (direction,event) ->
    @move[direction].activate = true if event.diff[direction] >= @minActivate
    if @on[direction]? and @move[direction].activate?
      @on[direction] event

  mouseUp: (e) =>
    e.end = true
    @checkUp 'left', e
    @checkUp 'right', e
  checkUp: (direction,event) ->
    if @move[direction].activate
      @on[direction] event
      @move[direction] = {}
{'fraction_non_alphanumeric': 0.15003847140292384, 'fraction_numerical': 0.0020518081559374197, 'mean_word_length': 3.1755888650963597, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '3555032', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1263, 'n_words': 294}