igniteui-react-grids
Version:
Ignite UI React grid components.
187 lines (186 loc) • 6.13 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, INotifyPropertyChanged_$type, PropertyChangedEventArgs, Point_$type, markType } from "igniteui-react-core";
import { IDragger_$type } from "./IDragger";
import { DraggerView } from "./DraggerView";
import { DragSelectEventArgs } from "./DragSelectEventArgs";
import { NativeUI } from "igniteui-react-core";
/**
* @hidden
*/
export let Dragger = /*@__PURE__*/ (() => {
class Dragger extends Base {
constructor() {
super(...arguments);
this.q = null;
this.d = false;
this.h = 0;
this.i = 0;
this.c = null;
this.b = 4;
this.e = false;
this.a = null;
this.j = null;
this.g = 0;
this.f = 0;
this.onDrag = null;
this.onDragEnd = null;
this.propertyChanged = null;
}
get view() {
if (this.c == null) {
this.c = new DraggerView(this);
}
return this.c;
}
set view(a) {
this.c = a;
}
get dragType() {
return this.b;
}
get isDragActive() {
return this.e;
}
get cellPath() {
return this.a;
}
get cloneCell() {
return this.j;
}
set cloneCell(a) {
let b = this.j;
this.j = a;
if (b != this.j) {
this.o("CloneCell", b, this.j);
}
}
get viewportWidth() {
return this.g;
}
set viewportWidth(a) {
let b = this.g;
this.g = a;
if (b != this.g) {
this.o("ViewportWidth", b, this.g);
}
}
get viewportHeight() {
return this.f;
}
set viewportHeight(a) {
let b = this.f;
this.f = a;
if (b != this.f) {
this.o("ViewportHeight", b, this.f);
}
}
o(a, b, c) {
if (this.propertyChanged != null) {
this.propertyChanged(this, new PropertyChangedEventArgs(a));
}
this.p(a, b, c);
}
onDetachedFromUI() {
this.view.onDetachedFromUI();
}
onAttachedToUI() {
this.view.onAttachedToUI();
}
provideContainer(a) {
this.view.provideContainer(a);
}
onMouseMove(a, b) {
if (this.e) {
if (this.onDrag != null) {
this.onDrag(this, ((() => {
let $ret = new DragSelectEventArgs();
$ret.startX = this.q.x;
$ret.startY = this.q.y;
$ret.currentX = a;
$ret.currentY = b;
$ret.controlPressed = this.d;
return $ret;
})()));
}
if (this.cloneCell != null) {
let c = this.i;
let d = this.h;
let e = this.view.getWindowScrollPos();
c += e[0];
d += e[1];
NativeUI.v(this.cloneCell, a + d);
NativeUI.ae(this.cloneCell, b + c);
}
}
}
onMouseUp(a, b) {
if (this.e) {
this.view.releaseMouse();
this.e = false;
if (this.onDragEnd != null) {
this.onDragEnd(this, new DragSelectEventArgs());
}
this.b = 4;
if (this.cloneCell != null) {
this.view.removeCloneCellFromDom();
this.cloneCell = null;
}
}
}
dragStart(a, b, c, d, e, f, g) {
if (!this.e) {
this.q = this.view.transformPoint(a, b);
this.q = { $type: Point_$type, x: this.q.x + c, y: this.q.y + d };
this.e = true;
this.d = g;
this.b = e;
this.a = f;
this.view.captureMouse();
if (this.cloneCell != null) {
let h = this.i;
let i = this.h;
let j = this.view.getWindowScrollPos();
h += j[0];
i += j[1];
NativeUI.v(this.cloneCell, a + i);
NativeUI.ae(this.cloneCell, b + h);
}
}
}
cancel() {
this.e = false;
this.b = 4;
}
n() {
if (this.cloneCell != null) {
let a = new Array(2);
a[0] = 0;
a[1] = 0;
a = this.view.getTopAndLeft();
let b = NativeUI.d(this.cloneCell) / 2;
this.i = a[0] - b;
let c = NativeUI.k(this.cloneCell) / 2;
this.h = a[1] - c;
}
}
p(a, b, c) {
switch (a) {
case "ViewportWidth":
case "ViewportHeight":
this.view.onViewportSizeChanged(this.g, this.f);
break;
case "CloneCell":
this.view.addCloneCellToDom();
this.n();
break;
}
}
}
Dragger.$t = /*@__PURE__*/ markType(Dragger, 'Dragger', Base.$, [IDragger_$type, INotifyPropertyChanged_$type]);
return Dragger;
})();