/**
 * only support click event
 */

const _events = []
export const addEventListener = (symbol, dimension, listener) => {
  _events[symbol] = {dimension, listener}
  return symbol
}
export const removeEventListener = (symbol) => {
  delete _events[symbol]
}
wx.onTouchStart((origin_e) => {
  try {
    //e.preventDefault()
    var x = origin_e.touches[0].clientX
    var y = origin_e.touches[0].clientY

  } catch (evt) {
    console.log(evt.message)
  }
  for (var e in _events) {
    var { dimension, listener } = e
    if (x >= dimension.startX
      && x <= dimension.endX
      && y >= dimension.startY
      && y <= dimension.endY) {
      try{
        listener()
      } catch (err) {
        console.warn(err, e)
      } 
    }
  }
})
