code: function () {
        var _this = this;
  
        this._onMouseDown = function (e) {
          _this.__onMouseDown(e);
  
          addListener(fabric.document, 'mouseup', _this._onMouseUp);
          fabric.isTouchSupported && addListener(fabric.document, 'touchend', _this._onMouseUp);
  
          addListener(fabric.document, 'mousemove', _this._onMouseMove);
          fabric.isTouchSupported && addListener(fabric.document, 'touchmove', _this._onMouseMove);
  
          removeListener(_this.upperCanvasEl, 'mousemove', _this._onMouseMove);
          fabric.isTouchSupported && removeListener(_this.upperCanvasEl, 'touchmove', _this._onMouseMove);
        };
  
        this._onMouseUp = function (e) {
          _this.__onMouseUp(e);
  
          removeListener(fabric.document, 'mouseup', _this._onMouseUp);
          fabric.isTouchSupported && removeListener(fabric.document, 'touchend', _this._onMouseUp);
  
          removeListener(fabric.document, 'mousemove', _this._onMouseMove);
          fabric.isTouchSupported && removeListener(fabric.document, 'touchmove', _this._onMouseMove);
  
          addListener(_this.upperCanvasEl, 'mousemove', _this._onMouseMove);
          fabric.isTouchSupported && addListener(_this.upperCanvasEl, 'touchmove', _this._onMouseMove);
        };
  
        this._onMouseMove = function (e) {
          e.preventDefault && e.preventDefault();
          _this.__onMouseMove(e);
        };
  
        this._onResize = function (e) {
          _this.calcOffset();
        };
  
  
        addListener(fabric.window, 'resize', this._onResize);
  
        if (fabric.isTouchSupported) {
          addListener(this.upperCanvasEl, 'touchstart', this._onMouseDown);
          addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
        }
        else {
          addListener(this.upperCanvasEl, 'mousedown', this._onMouseDown);
          addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
        }
      }
docs: Adds mouse listeners to  canvas
  @method _initEvents
  @private
  See configuration documentation for more details.