Sha256: 50cc58d20a31460050985a01cc0dcf58ea8a7f475227f31a6dd5efe589b0f0da

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

(function($) {

  $.fn.centerPoint = function()
  {
    return {
      x: this.position().left + (this.outerWidth(true) / 2),
      y: this.position().top + (this.outerHeight(true) / 2)
    };
  };

  $.fn.containsPoint = function(point)
  {
    var position = this.position(),
        left     = position.left,
        top      = position.top,
        width    = this.outerWidth(true),
        height   = this.outerHeight(true);

    return (point.x >= left &&
      point.x <= (left + width) &&
      point.y >= top &&
      point.y <= (top + height));
  };

  $.fn.overlapped = function(x, y, width, height)
  {
    var left   = $(this).position().left,
        top    = $(this).position().top,
        right  = left + $(this).outerWidth(),
        bottom = top + $(this).outerHeight();

    return (((x >= left && x <= right) ||
      (x + width >= left && x + width <= right) ||
      (left >= x && left <= x + width)) &&
      ((y >= top && y <= bottom) ||
      (y + height >= top && y + height <= bottom) ||
      (top >= y && top <= y + height)));
  };

})(jQuery);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cartilage-0.1.2 vendor/assets/javascripts/jquery-points.js