igniteui-react-core
Version:
Ignite UI React Core.
294 lines (293 loc) • 9.54 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { Base, markType } from "./type";
/**
* @hidden
*/
export let CollisionRect = /*@__PURE__*/ (() => {
class CollisionRect extends Base {
constructor(a, ..._rest) {
super();
this.u = 0;
this.v = 0;
this.t = 0;
this.p = 0;
this.s = 0;
this.q = 0;
this.r = 0;
this.o = 0;
a = (a == void 0) ? 0 : a;
switch (a) {
case 0:
{
let c = _rest[0];
this.left = c.left;
this.top = c.top;
this.width = c.width;
this.height = c.height;
}
break;
case 1:
{
let c = _rest[0];
let d = _rest[1];
let e = _rest[2];
let f = _rest[3];
this.top = d;
this.left = c;
this.width = e;
this.height = f;
}
break;
case 2:
{
let c = _rest[0];
let d = _rest[1];
let e = _rest[2];
this.top = d;
this.left = c;
this.width = e.width;
this.height = e.height;
}
break;
case 3:
{
let c = _rest[0];
let d = _rest[1];
this.top = Math.min(c.y, d.y);
this.left = Math.min(c.x, d.x);
this.width = Math.max(Math.max(c.x, d.x) - this.left, 0);
this.height = Math.max(Math.max(c.y, d.y) - this.top, 0);
}
break;
case 4:
{
let c = _rest[0];
let d = _rest[1];
this.top = c.y;
this.left = c.x;
this.width = d.width;
this.height = d.height;
}
break;
case 5:
{
this.top = 0;
this.left = 0;
this.width = 0;
this.height = 0;
}
break;
}
}
get x() {
return this.u;
}
set x(a) {
this.u = a;
this.q = this.u;
this.r = this.q + this.t;
}
get y() {
return this.v;
}
set y(a) {
this.v = a;
this.s = this.v;
this.o = this.s + this.p;
}
get width() {
return this.t;
}
set width(a) {
this.t = a;
this.r = this.q + this.t;
}
get height() {
return this.p;
}
set height(a) {
this.p = a;
this.o = this.s + this.p;
}
get top() {
return this.s;
}
set top(a) {
this.s = a;
this.y = this.s;
}
get left() {
return this.q;
}
set left(a) {
this.q = a;
this.x = this.q;
}
get right() {
return this.r;
}
set right(a) {
this.r = a;
this.t = this.r - this.q;
}
get bottom() {
return this.o;
}
set bottom(a) {
this.o = a;
this.p = this.o - this.s;
}
get isEmpty() {
return this.t < 0;
}
static get empty() {
return new CollisionRect(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
}
equals(a) {
if (CollisionRect.l_op_Equality(a, null)) {
return false;
}
if (a.x == this.x && a.y == this.y && a.width == this.width && a.height == this.height) {
return true;
}
return false;
}
f(a, b) {
return a >= this.u && a - this.t <= this.u && b >= this.v && b - this.p <= this.v;
}
containsLocation(a, b) {
return !this.isEmpty && this.f(a, b);
}
containsPoint(a) {
return this.containsLocation(a.x, a.y);
}
containsRect(a) {
return !this.isEmpty && !a.isEmpty && (this.u <= a.u && this.v <= a.v && this.u + this.t >= a.u + a.t) && this.v + this.p >= a.v + a.p;
}
inflate(a, b) {
this.x -= a;
this.y -= b;
this.width += a * 2;
this.height += b * 2;
if (this.t < 0 || this.p < 0) {
this.ah();
}
}
ah() {
this.top = Number.POSITIVE_INFINITY;
this.left = Number.POSITIVE_INFINITY;
this.width = Number.NEGATIVE_INFINITY;
this.height = Number.NEGATIVE_INFINITY;
}
intersectsWith(a) {
if (this.isEmpty || a.isEmpty) {
return false;
}
return a.left < this.right && this.left < a.right && a.top < this.bottom && this.top < a.bottom;
}
intersect(a) {
if (!this.intersectsWith(a)) {
this.ah();
}
else {
let b = Math.max(this.x, a.x);
let c = Math.max(this.y, a.y);
let d = Math.min(this.x + this.width, a.x + a.width) - b;
let e = Math.min(this.y + this.height, a.y + a.height) - c;
if (d < 0) {
d = 0;
}
if (e < 0) {
e = 0;
}
this.t = d;
this.p = e;
this.u = b;
this.v = c;
this.q = this.u;
this.s = this.v;
this.r = this.q + this.t;
this.o = this.s + this.p;
}
}
union(a) {
if (this.isEmpty) {
this.u = a.x;
this.v = a.y;
this.t = a.width;
this.p = a.height;
this.q = this.u;
this.s = this.v;
this.r = this.q + this.t;
this.o = this.s + this.p;
return;
}
if (!a.isEmpty) {
let b = Math.min(this.x, a.x);
let c = Math.min(this.y, a.y);
let d = this.width;
let e = this.height;
if (a.width == Number.POSITIVE_INFINITY || this.width == Number.POSITIVE_INFINITY) {
d = Number.POSITIVE_INFINITY;
}
else {
let f = Math.max(this.right, a.right);
d = f - b;
}
if (a.height == Number.POSITIVE_INFINITY || this.height == Number.POSITIVE_INFINITY) {
e = Number.POSITIVE_INFINITY;
}
else {
let g = Math.max(this.bottom, a.bottom);
e = g - c;
}
this.u = b;
this.v = c;
this.t = d;
this.p = e;
this.q = this.u;
this.s = this.v;
this.r = this.q + this.t;
this.o = this.s + this.p;
}
}
equals1(a) {
if (a == null) {
return super.equals(a);
}
let b = a;
return b.left == this.left && b.top == this.top && b.width == this.width && b.height == this.height;
}
getHashCode() {
return (this.u) ^ (this.v) ^ (this.t) ^ (this.p);
}
copy() {
return new CollisionRect(1, this.x, this.y, this.width, this.height);
}
static l_op_Equality(a, b) {
if (a == null) {
return b == null;
}
else if (b == null) {
return false;
}
return a.u == b.u && a.v == b.v && a.t == b.t && a.p == b.p;
}
static l_op_Inequality(a, b) {
if (a == null) {
return b != null;
}
else if (b == null) {
return true;
}
return a.u != b.u || a.v != b.v || a.t != b.t || a.p != b.p;
}
}
CollisionRect.$t = /*@__PURE__*/ markType(CollisionRect, 'CollisionRect');
return CollisionRect;
})();