<commit_before>///<reference path="../../reference.ts" />

module Plottable {
export module Interaction {
  export class DragBox extends Drag {
    private static CLASS_DRAG_BOX = "drag-box";
    public dragBox: D3.Selection;
    public boxIsDrawn = false;
    public resizePadding = 10;
    /**
     * The currently selected area, which can be different from the are the user has dragged.
     */
    public selection: SelectionArea;
    /**
     * True if box is resizing on the X dimension.
     */
    public isResizingX = false;
    /**
     * True if box is resizing on the Y dimension.
     */
    public isResizingY = false;
    /**
     * True if box is resizing.
     */
    public isResizing = false;
    public _selectionOrigin: number[];
    private resizeEnabled = false;
    private resizeStartDiff: number[] = [];
    private lastCursorStyle = "";

    // Returns true if `val` is "close enough" to `position`.
    public _isCloseEnoughLeft(val: number, position: number, len: number): boolean {
      var leftPadding: number = this.resizePadding;
      var rightPadding: number = Math.min(this.resizePadding, len / 2);
      return position - leftPadding <= val && val <= position + rightPadding;
    }

    public _isCloseEnoughRight(val: number, position: number, len: number): boolean {
      var leftPadding = Math.min(this.resizePadding, len / 2);
      var rightPadding = this.resizePadding;
      return position - leftPadding <= val && val <= position + rightPadding;
    }

    /**
     * Gets whether resizing is enabled or not.
     *
     * @returns {boolean}
     */
    public resize(): boolean;
    /**
     * Enables or disables resizing.
     *
     * @param {boolean} enabled
     */
    public resize(enabled: boolean): DragBox;
    public resize(enabled?: boolean): any {
      if (enabled == null) {
        return this.resizeEnabled;
      } else {
        this.resizeEnabled = enabled;
        return this;
      }
    }

    public _isResizeStartAttr(isX: boolean): boolean {
      var i1: number, i2: number, positionAttr1: string, positionAttr2: string, lengthAttr1: string, lengthAttr2: string;
      if (isX) {
        i1 = 0;
        i2 = 1;
        positionAttr1 = "x";
        positionAttr2 = "y";
        lengthAttr1 = "width";
        lengthAttr2 = "height";
      } else {
        i1 = 1;
        i2 = 0;
        positionAttr1 = "y";
        positionAttr2 = "x";
        lengthAttr1 = "height";
        lengthAttr2 = "width";
      }
      var otherOrigin = this.origin[i2];
      var from = parseInt(this.dragBox.attr(positionAttr2), 10);
      var to = parseInt(this.dragBox.attr(lengthAttr2), 10) + to;
      if (otherOrigin < from || otherOrigin > to) {
        return false;
      }
      var attrOrigin = this.origin[i1];
      var leftPosition = parseInt(this.dragBox.attr(positionAttr1), 10);
      var len = parseInt(this.dragBox.attr(lengthAttr1), 10);
      var rightPosition = len + leftPosition;
      var leftResult = this._isCloseEnoughLeft(attrOrigin, leftPosition, len);
      if (leftResult) {
        this._selectionOrigin[i1] = rightPosition;
        this.resizeStartDiff[i1] = leftPosition - attrOrigin;
      }
      var rightResult = this._isCloseEnoughRight(attrOrigin, rightPosition, len);<commit_msg>consider `resizePadding` when checking resize domain<commit_after>///<reference path="../../reference.ts" />

module Plottable {
export module Interaction {
  export class DragBox extends Drag {
    private static CLASS_DRAG_BOX = "drag-box";
    public dragBox: D3.Selection;
    public boxIsDrawn = false;
    public resizePadding = 10;
    /**
     * The currently selected area, which can be different from the are the user has dragged.
     */
    public selection: SelectionArea;
    /**
     * True if box is resizing on the X dimension.
     */
    public isResizingX = false;
    /**
     * True if box is resizing on the Y dimension.
     */
    public isResizingY = false;
    /**
     * True if box is resizing.
     */
    public isResizing = false;
    public _selectionOrigin: number[];
    private resizeEnabled = false;
    private resizeStartDiff: number[] = [];
    private lastCursorStyle = "";

    // Returns true if `val` is "close enough" to `position`.
    public _isCloseEnoughLeft(val: number, position: number, len: number): boolean {
      var leftPadding: number = this.resizePadding;
      var rightPadding: number = Math.min(this.resizePadding, len / 2);
      return position - leftPadding <= val && val <= position + rightPadding;
    }

    public _isCloseEnoughRight(val: number, position: number, len: number): boolean {
      var leftPadding = Math.min(this.resizePadding, len / 2);
      var rightPadding = this.resizePadding;
      return position - leftPadding <= val && val <= position + rightPadding;
    }

    /**
     * Gets whether resizing is enabled or not.
     *
     * @returns {boolean}
     */
    public resize(): boolean;
    /**
     * Enables or disables resizing.
     *
     * @param {boolean} enabled
     */
    public resize(enabled: boolean): DragBox;
    public resize(enabled?: boolean): any {
      if (enabled == null) {
        return this.resizeEnabled;
      } else {
        this.resizeEnabled = enabled;
        return this;
      }
    }

    public _isResizeStartAttr(isX: boolean): boolean {
      var i1: number, i2: number, positionAttr1: string, positionAttr2: string, lengthAttr1: string, lengthAttr2: string;
      if (isX) {
        i1 = 0;
        i2 = 1;
        positionAttr1 = "x";
        positionAttr2 = "y";
        lengthAttr1 = "width";
        lengthAttr2 = "height";
      } else {
        i1 = 1;
        i2 = 0;
        positionAttr1 = "y";
        positionAttr2 = "x";
        lengthAttr1 = "height";
        lengthAttr2 = "width";
      }
      var otherOrigin = this.origin[i2];
      var from = parseInt(this.dragBox.attr(positionAttr2), 10);
      var to = parseInt(this.dragBox.attr(lengthAttr2), 10) + to;
      if (otherOrigin + this.resizePadding < from || otherOrigin - this.resizePadding > to) {
        return false;
      }
      var attrOrigin = this.origin[i1];
      var leftPosition = parseInt(this.dragBox.attr(positionAttr1), 10);
      var len = parseInt(this.dragBox.attr(lengthAttr1), 10);
      var rightPosition = len + leftPosition;
      var leftResult = this._isCloseEnoughLeft(attrOrigin, leftPosition, len);
      if (leftResult) {
        this._selectionOrigin[i1] = rightPosition;
        this.resizeStartDiff[i1] = leftPosition - attrOrigin;
      }
      var rightResult = this._isCloseEnoughRight(attrOrigin, rightPosition, len);
{'fraction_non_alphanumeric': 0.11062547098718915, 'fraction_numerical': 0.012961567445365486, 'mean_word_length': 2.5129698253043937, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, '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': '359602', 'n_tokens_mistral': 1955, 'n_tokens_neox': 1910, 'n_words': 556}