(function($){

var ns = 'TouchScroll';

window[ns] = function ( wrap, handle ) {
  this.wrap   = $(wrap);
  this.handle = handle
  this.root   = $(handle);
  
  this.observe();
};

window[ns].prototype = {
  
  observe: function () {
    this.proxyStart = $.proxy( this.touchstart, this );
    this.proxyMove  = $.proxy( this.touchmove , this );
    this.proxyEnd   = $.proxy( this.touchend  , this );

    this.handle.addEventListener("touchstart", this.proxyStart, false );
    this.handle.addEventListener("touchmove" , this.proxyMove , false );
    this.handle.addEventListener("touchend"  , this.proxyEnd  , false );
    
  },
  
  touchstart: function ( event ) {
    var y = event.touches[0].pageY;
    this.oy = y;
    this.py = y;
  },
  
  touchmove: function ( event ) {
    this.y = event.touches[0].pageY;
    event.preventDefault();
    var offset = this.y - this.py;
    
    if ( offset < 0 ) { // move up
    } else if ( offset > 0 ) { // move down
    }
    
    this.wrap.scrollTop( this.wrap.scrollTop() - offset);
    this.py = this.y;
  },
  
  touchend: function ( event ) {
  },
  
  exit: function () {
    this.handle.removeEventListener("touchstart", this.proxyStart, false );
    this.handle.removeEventListener("touchmove" , this.proxyMove , false );
    this.handle.removeEventListener("touchend"  , this.proxyEnd  , false );
  }
}

})(jQuery);
