@tft/interact 12.4.0 → 12.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/tft-interact.umd.js +147 -104
- package/bundles/tft-interact.umd.js.map +1 -1
- package/esm2015/lib/directives/account-for-scale.directive.js +4 -17
- package/esm2015/lib/directives/account-for-scale.directive.js.map +1 -1
- package/esm2015/lib/directives/account-for-scale.directive.metadata.json +1 -1
- package/esm2015/lib/directives/apply-scale.directive.js +26 -0
- package/esm2015/lib/directives/apply-scale.directive.js.map +1 -0
- package/esm2015/lib/directives/apply-scale.directive.metadata.json +1 -0
- package/esm2015/lib/directives/drag-root.directive.js +8 -11
- package/esm2015/lib/directives/drag-root.directive.js.map +1 -1
- package/esm2015/lib/directives/drag-root.directive.metadata.json +1 -1
- package/esm2015/lib/directives/draggable.directive.js +12 -12
- package/esm2015/lib/directives/draggable.directive.js.map +1 -1
- package/esm2015/lib/directives/draggable.directive.metadata.json +1 -1
- package/esm2015/lib/directives/dropzone.directive.js +9 -5
- package/esm2015/lib/directives/dropzone.directive.js.map +1 -1
- package/esm2015/lib/directives/dropzone.directive.metadata.json +1 -1
- package/esm2015/lib/directives/index.js +1 -0
- package/esm2015/lib/directives/index.js.map +1 -1
- package/esm2015/lib/directives/index.metadata.json +1 -1
- package/esm2015/lib/directives/resizable.directive.js +1 -1
- package/esm2015/lib/directives/resizable.directive.js.map +1 -1
- package/esm2015/lib/interact.module.js +15 -1
- package/esm2015/lib/interact.module.js.map +1 -1
- package/esm2015/lib/interact.module.metadata.json +1 -1
- package/esm2015/lib/models/interact.js +2 -0
- package/esm2015/lib/models/interact.js.map +1 -1
- package/esm2015/lib/models/interact.metadata.json +1 -1
- package/esm2015/lib/services/interact.service.js +39 -24
- package/esm2015/lib/services/interact.service.js.map +1 -1
- package/esm2015/lib/services/interact.service.metadata.json +1 -1
- package/esm2015/tft-interact.js +2 -2
- package/esm2015/tft-interact.js.map +1 -1
- package/esm2015/tft-interact.metadata.json +1 -1
- package/fesm2015/tft-interact.js +128 -89
- package/fesm2015/tft-interact.js.map +1 -1
- package/lib/directives/account-for-scale.directive.d.ts +3 -7
- package/lib/directives/apply-scale.directive.d.ts +8 -0
- package/lib/directives/drag-root.directive.d.ts +2 -1
- package/lib/directives/draggable.directive.d.ts +2 -1
- package/lib/directives/dropzone.directive.d.ts +7 -5
- package/lib/directives/index.d.ts +1 -0
- package/lib/interact.module.d.ts +3 -0
- package/lib/models/interact.d.ts +6 -0
- package/lib/services/interact.service.d.ts +4 -2
- package/package.json +1 -1
- package/tft-interact-12.5.0.tgz +0 -0
- package/tft-interact.d.ts +2 -2
- package/tft-interact.metadata.json +1 -1
- package/tft-interact-12.4.0.tgz +0 -0
|
@@ -361,6 +361,7 @@
|
|
|
361
361
|
},] }
|
|
362
362
|
];
|
|
363
363
|
|
|
364
|
+
var INTERACT_ROOT_CONFIG = new i0.InjectionToken('INTERACT_ROOT_CONFIG_PARAMS');
|
|
364
365
|
var DEFAULT_REGISTRY_ID = 'DEFAULT';
|
|
365
366
|
/**
|
|
366
367
|
* Default initial value for Delta BehaviorSubject
|
|
@@ -388,14 +389,17 @@
|
|
|
388
389
|
};
|
|
389
390
|
|
|
390
391
|
var InteractService = /** @class */ (function () {
|
|
391
|
-
function InteractService(rendererFactory, ngZone) {
|
|
392
|
+
function InteractService(rendererFactory, ngZone, rootConfig) {
|
|
392
393
|
this.rendererFactory = rendererFactory;
|
|
393
394
|
this.ngZone = ngZone;
|
|
395
|
+
this.rootConfig = rootConfig;
|
|
394
396
|
this._interactableIndex = 0;
|
|
395
397
|
this._dropzoneIndex = 0;
|
|
396
398
|
// TODO: consider using Map here
|
|
397
399
|
this.dragRegistrySystem = {};
|
|
400
|
+
this.cssUnit = 'px';
|
|
398
401
|
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
402
|
+
this.cssUnit = (rootConfig === null || rootConfig === void 0 ? void 0 : rootConfig.cssDimensionUnit) || 'px';
|
|
399
403
|
}
|
|
400
404
|
InteractService.prototype.addDeltaToPosition = function (delta, position) {
|
|
401
405
|
return {
|
|
@@ -446,8 +450,8 @@
|
|
|
446
450
|
// startWith({...initialSize, ...initialDelta}),
|
|
447
451
|
operators.shareReplay(1),
|
|
448
452
|
// filter(resizeEvent => !!resizeEvent.targetElement),
|
|
449
|
-
operators.tap(function (
|
|
450
|
-
var deltaX =
|
|
453
|
+
operators.tap(function (_c) {
|
|
454
|
+
var deltaX = _c.deltaX, deltaY = _c.deltaY, width = _c.width, height = _c.height, targetElement = _c.targetElement;
|
|
451
455
|
_this.ngZone.runOutsideAngular(function () {
|
|
452
456
|
_this.setElementSize(width, height, targetElement);
|
|
453
457
|
});
|
|
@@ -466,8 +470,8 @@
|
|
|
466
470
|
_this.setElementTransform(position.x, position.y, position);
|
|
467
471
|
});
|
|
468
472
|
}))
|
|
469
|
-
]).pipe(operators.shareReplay(1), operators.map(function (
|
|
470
|
-
var
|
|
473
|
+
]).pipe(operators.shareReplay(1), operators.map(function (_c) {
|
|
474
|
+
var _d = __read(_c, 3), size = _d[0], deltas = _d[1], position = _d[2];
|
|
471
475
|
return {
|
|
472
476
|
x: position.x,
|
|
473
477
|
y: position.y,
|
|
@@ -497,28 +501,28 @@
|
|
|
497
501
|
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
498
502
|
return this.dragRegistrySystem[registryId][interactableId].interactable$;
|
|
499
503
|
};
|
|
500
|
-
InteractService.prototype.updateDeltas = function (interactId, registryId,
|
|
501
|
-
var deltaX =
|
|
504
|
+
InteractService.prototype.updateDeltas = function (interactId, registryId, _c, targetElement) {
|
|
505
|
+
var deltaX = _c.deltaX, deltaY = _c.deltaY;
|
|
502
506
|
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
503
507
|
return;
|
|
504
508
|
this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX: deltaX, deltaY: deltaY, targetElement: targetElement });
|
|
505
509
|
};
|
|
506
|
-
InteractService.prototype.updatePosition = function (interactId, registryId,
|
|
507
|
-
var x =
|
|
510
|
+
InteractService.prototype.updatePosition = function (interactId, registryId, _c, targetElement) {
|
|
511
|
+
var x = _c.x, y = _c.y;
|
|
508
512
|
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
509
513
|
return;
|
|
510
514
|
this.dragRegistrySystem[registryId][interactId].position$.next({ x: x, y: y, targetElement: targetElement });
|
|
511
515
|
};
|
|
512
|
-
InteractService.prototype.updateSize = function (interactId, registryId,
|
|
513
|
-
var deltaX =
|
|
516
|
+
InteractService.prototype.updateSize = function (interactId, registryId, _c, targetElement) {
|
|
517
|
+
var deltaX = _c.deltaX, deltaY = _c.deltaY, width = _c.width, height = _c.height;
|
|
514
518
|
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
515
519
|
return;
|
|
516
520
|
this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX: deltaX, deltaY: deltaY, width: width, height: height, targetElement: targetElement });
|
|
517
521
|
};
|
|
518
522
|
InteractService.prototype.interactableExistOnRegistry = function (interactId, registryId) {
|
|
519
523
|
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
520
|
-
|
|
521
|
-
|
|
524
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
525
|
+
return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
|
|
522
526
|
};
|
|
523
527
|
/**
|
|
524
528
|
* Uses renderer to set width and height of angular component
|
|
@@ -532,14 +536,16 @@
|
|
|
532
536
|
return;
|
|
533
537
|
var accountForScaleDirective = (_a = target.resizeRef) === null || _a === void 0 ? void 0 : _a.account_for_scale_dir;
|
|
534
538
|
if (accountForScaleDirective) {
|
|
535
|
-
var
|
|
536
|
-
var scaledWidth = width /
|
|
537
|
-
var scaledHeight = height /
|
|
538
|
-
this.renderer.setStyle(target, 'width', scaledWidth +
|
|
539
|
-
this.renderer.setStyle(target, 'height', scaledHeight +
|
|
539
|
+
var scale = accountForScaleDirective.scale;
|
|
540
|
+
var scaledWidth = width / scale;
|
|
541
|
+
var scaledHeight = height / scale;
|
|
542
|
+
this.renderer.setStyle(target, 'width', "" + scaledWidth + this.cssUnit);
|
|
543
|
+
this.renderer.setStyle(target, 'height', "" + scaledHeight + this.cssUnit);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
this.renderer.setStyle(target, 'width', "" + width + this.cssUnit);
|
|
547
|
+
this.renderer.setStyle(target, 'height', "" + height + this.cssUnit);
|
|
540
548
|
}
|
|
541
|
-
this.renderer.setStyle(target, 'width', width + "px");
|
|
542
|
-
this.renderer.setStyle(target, 'height', height + "px");
|
|
543
549
|
};
|
|
544
550
|
/**
|
|
545
551
|
* Uses renderer to set position of angular component
|
|
@@ -548,17 +554,19 @@
|
|
|
548
554
|
* @param target the element to transform
|
|
549
555
|
*/
|
|
550
556
|
InteractService.prototype.setElementTransform = function (x, y, position) {
|
|
551
|
-
var _a, _b
|
|
557
|
+
var _a, _b;
|
|
552
558
|
if (!(position === null || position === void 0 ? void 0 : position.targetElement))
|
|
553
559
|
return;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
560
|
+
var dragRef = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef;
|
|
561
|
+
var accountForScaleDirective = (dragRef === null || dragRef === void 0 ? void 0 : dragRef.account_for_scale_dir) || ((_b = dragRef === null || dragRef === void 0 ? void 0 : dragRef.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir);
|
|
562
|
+
if (accountForScaleDirective) {
|
|
563
|
+
var scale = accountForScaleDirective.scale;
|
|
564
|
+
this.renderer.setStyle(position.targetElement, 'left', "" + x / scale + this.cssUnit);
|
|
565
|
+
this.renderer.setStyle(position.targetElement, 'top', "" + y / scale + this.cssUnit);
|
|
558
566
|
}
|
|
559
567
|
else {
|
|
560
|
-
this.renderer.setStyle(position.targetElement, 'left', x +
|
|
561
|
-
this.renderer.setStyle(position.targetElement, 'top', y +
|
|
568
|
+
this.renderer.setStyle(position.targetElement, 'left', "" + x + this.cssUnit);
|
|
569
|
+
this.renderer.setStyle(position.targetElement, 'top', "" + y + this.cssUnit);
|
|
562
570
|
}
|
|
563
571
|
};
|
|
564
572
|
/**
|
|
@@ -568,33 +576,67 @@
|
|
|
568
576
|
* @param y the position along the y axis
|
|
569
577
|
*/
|
|
570
578
|
InteractService.prototype.createTransformString = function (x, y) {
|
|
571
|
-
return "translate3d(" + x + "
|
|
579
|
+
return "translate3d(" + x + this.cssUnit + ", " + y + this.cssUnit + ", 0)";
|
|
572
580
|
};
|
|
573
|
-
InteractService.prototype.calculatePositionInElement = function (zoneElement, dragElement) {
|
|
581
|
+
InteractService.prototype.calculatePositionInElement = function (zoneElement, dragElement, scale) {
|
|
574
582
|
// TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
|
|
575
583
|
var zoneRect = zoneElement.getBoundingClientRect();
|
|
576
584
|
var dragRect = dragElement.getBoundingClientRect();
|
|
577
|
-
|
|
585
|
+
var position = scale
|
|
586
|
+
? {
|
|
587
|
+
x: (dragRect.left - zoneRect.left) / scale || 1,
|
|
588
|
+
y: (dragRect.top - zoneRect.top) / scale || 1
|
|
589
|
+
} : {
|
|
578
590
|
x: dragRect.left - zoneRect.left,
|
|
579
591
|
y: dragRect.top - zoneRect.top
|
|
580
592
|
};
|
|
593
|
+
// console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
|
|
594
|
+
return position;
|
|
581
595
|
};
|
|
582
596
|
return InteractService;
|
|
583
597
|
}());
|
|
584
|
-
InteractService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0__namespace.ɵɵinject(i0__namespace.RendererFactory2), i0__namespace.ɵɵinject(i0__namespace.NgZone)); }, token: InteractService, providedIn: "root" });
|
|
598
|
+
InteractService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0__namespace.ɵɵinject(i0__namespace.RendererFactory2), i0__namespace.ɵɵinject(i0__namespace.NgZone), i0__namespace.ɵɵinject(INTERACT_ROOT_CONFIG, 8)); }, token: InteractService, providedIn: "root" });
|
|
585
599
|
InteractService.decorators = [
|
|
586
600
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
587
601
|
];
|
|
588
602
|
InteractService.ctorParameters = function () { return [
|
|
589
603
|
{ type: i0.RendererFactory2 },
|
|
590
|
-
{ type: i0.NgZone }
|
|
604
|
+
{ type: i0.NgZone },
|
|
605
|
+
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [INTERACT_ROOT_CONFIG,] }] }
|
|
591
606
|
]; };
|
|
592
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Use to apply scale to the element and tell the drag and resize directives to account for the scale when
|
|
610
|
+
* @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
|
|
611
|
+
* @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
|
|
612
|
+
* element accounts for scale
|
|
613
|
+
*/
|
|
614
|
+
var AccountForScaleDirective = /** @class */ (function () {
|
|
615
|
+
function AccountForScaleDirective(el) {
|
|
616
|
+
this.el = el;
|
|
617
|
+
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
618
|
+
this.scale = 1;
|
|
619
|
+
}
|
|
620
|
+
return AccountForScaleDirective;
|
|
621
|
+
}());
|
|
622
|
+
AccountForScaleDirective.decorators = [
|
|
623
|
+
{ type: i0.Directive, args: [{
|
|
624
|
+
selector: '[tftAccountForScale]'
|
|
625
|
+
},] }
|
|
626
|
+
];
|
|
627
|
+
AccountForScaleDirective.ctorParameters = function () { return [
|
|
628
|
+
{ type: i0.ElementRef }
|
|
629
|
+
]; };
|
|
630
|
+
AccountForScaleDirective.propDecorators = {
|
|
631
|
+
scale: [{ type: i0.Input }]
|
|
632
|
+
};
|
|
633
|
+
|
|
593
634
|
var DropzoneDirective = /** @class */ (function () {
|
|
594
|
-
function DropzoneDirective(el, renderer, interactService) {
|
|
635
|
+
function DropzoneDirective(el, renderer, interactService, account_for_scale_dir) {
|
|
595
636
|
this.el = el;
|
|
596
637
|
this.renderer = renderer;
|
|
597
638
|
this.interactService = interactService;
|
|
639
|
+
this.account_for_scale_dir = account_for_scale_dir;
|
|
598
640
|
this.dropzoneConfig = {};
|
|
599
641
|
// proxies to pass interact events through to consumer of directive
|
|
600
642
|
this.dropActivate = new i0.EventEmitter();
|
|
@@ -645,11 +687,12 @@
|
|
|
645
687
|
* @param event the drop event emitted by interact, extended with extra fields we added to
|
|
646
688
|
*/
|
|
647
689
|
DropzoneDirective.prototype.mapDropzoneEvent = function (event) {
|
|
648
|
-
var _a, _b;
|
|
690
|
+
var _a, _b, _c;
|
|
649
691
|
var zoneElement = event.target;
|
|
650
692
|
var dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
|
|
693
|
+
var scale = ((_c = this.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || null;
|
|
651
694
|
var positionInDropTarget = zoneElement && dragElement
|
|
652
|
-
? this.interactService.calculatePositionInElement(zoneElement, dragElement)
|
|
695
|
+
? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
|
|
653
696
|
: null;
|
|
654
697
|
return {
|
|
655
698
|
interactEvent: event,
|
|
@@ -672,7 +715,8 @@
|
|
|
672
715
|
DropzoneDirective.ctorParameters = function () { return [
|
|
673
716
|
{ type: i0.ElementRef },
|
|
674
717
|
{ type: i0.Renderer2 },
|
|
675
|
-
{ type: InteractService }
|
|
718
|
+
{ type: InteractService },
|
|
719
|
+
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] }
|
|
676
720
|
]; };
|
|
677
721
|
DropzoneDirective.propDecorators = {
|
|
678
722
|
dropzoneId: [{ type: i0.Input }],
|
|
@@ -739,71 +783,25 @@
|
|
|
739
783
|
return wrapper;
|
|
740
784
|
}
|
|
741
785
|
|
|
742
|
-
/**
|
|
743
|
-
* Use to apply scale to the element and tell the drag and resize directives to account for the scale when
|
|
744
|
-
* @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
|
|
745
|
-
* @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
|
|
746
|
-
* element accounts for scale
|
|
747
|
-
*/
|
|
748
|
-
var AccountForScaleDirective = /** @class */ (function () {
|
|
749
|
-
function AccountForScaleDirective(el) {
|
|
750
|
-
this.el = el;
|
|
751
|
-
this.scaleX = 1;
|
|
752
|
-
this.scaleY = 1;
|
|
753
|
-
}
|
|
754
|
-
Object.defineProperty(AccountForScaleDirective.prototype, "scale", {
|
|
755
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
756
|
-
set: function (val) {
|
|
757
|
-
this.scaleY = val;
|
|
758
|
-
this.scaleX = val;
|
|
759
|
-
},
|
|
760
|
-
enumerable: false,
|
|
761
|
-
configurable: true
|
|
762
|
-
});
|
|
763
|
-
;
|
|
764
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
765
|
-
AccountForScaleDirective.prototype.ngOnChanges = function (_changes) {
|
|
766
|
-
this.transform = "scaleX(" + this.scaleX + ") scaleY(" + this.scaleY + ")";
|
|
767
|
-
};
|
|
768
|
-
return AccountForScaleDirective;
|
|
769
|
-
}());
|
|
770
|
-
AccountForScaleDirective.decorators = [
|
|
771
|
-
{ type: i0.Directive, args: [{
|
|
772
|
-
selector: '[tftAccountForScale]'
|
|
773
|
-
},] }
|
|
774
|
-
];
|
|
775
|
-
AccountForScaleDirective.ctorParameters = function () { return [
|
|
776
|
-
{ type: i0.ElementRef }
|
|
777
|
-
]; };
|
|
778
|
-
AccountForScaleDirective.propDecorators = {
|
|
779
|
-
scale: [{ type: i0.Input }],
|
|
780
|
-
scaleX: [{ type: i0.Input }],
|
|
781
|
-
scaleY: [{ type: i0.Input }],
|
|
782
|
-
transform: [{ type: i0.HostBinding, args: ['style.transform',] }]
|
|
783
|
-
};
|
|
784
|
-
|
|
785
786
|
/**
|
|
786
787
|
* Use this directive to select which element to attach the element to while dragging
|
|
787
788
|
* @example <div tftDragRoot><div tftDraggable> </div> </div>
|
|
788
789
|
* @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
|
|
789
790
|
*/
|
|
790
791
|
var DragRootDirective = /** @class */ (function () {
|
|
791
|
-
function DragRootDirective(el,
|
|
792
|
+
function DragRootDirective(el,
|
|
793
|
+
// This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
|
|
794
|
+
// It allows the the interact service to check if the drag root has some scaling applied to it and account for it when the component is dragged
|
|
795
|
+
account_for_scale_dir) {
|
|
792
796
|
this.el = el;
|
|
793
|
-
|
|
794
|
-
// with a dropzone inside of it and a drag item inside the dropzone
|
|
795
|
-
// e.g <div tftDragRoot> <div tftDropzone> <div tftDraggable</div> </div> </div>
|
|
796
|
-
// TODO: This is a band-aid, root cause in misunderstood, it started after switching from
|
|
797
|
-
// using `translate3d` to top/left for positioning
|
|
798
|
-
if (!account_for_scale_dir) {
|
|
799
|
-
el.nativeElement.style.transform = 'scale(1)';
|
|
800
|
-
}
|
|
797
|
+
this.account_for_scale_dir = account_for_scale_dir;
|
|
801
798
|
}
|
|
802
799
|
return DragRootDirective;
|
|
803
800
|
}());
|
|
804
801
|
DragRootDirective.decorators = [
|
|
805
802
|
{ type: i0.Directive, args: [{
|
|
806
|
-
selector: '[tftDragRoot]'
|
|
803
|
+
selector: '[tftDragRoot]',
|
|
804
|
+
exportAs: 'tftDragRoot'
|
|
807
805
|
},] }
|
|
808
806
|
];
|
|
809
807
|
DragRootDirective.ctorParameters = function () { return [
|
|
@@ -816,7 +814,6 @@
|
|
|
816
814
|
var DraggableDirective = /** @class */ (function () {
|
|
817
815
|
// cache holding element to use as placeholder while dragging
|
|
818
816
|
function DraggableDirective(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
|
|
819
|
-
var _a;
|
|
820
817
|
this.el = el;
|
|
821
818
|
this.interactService = interactService;
|
|
822
819
|
this.renderer = renderer;
|
|
@@ -839,15 +836,15 @@
|
|
|
839
836
|
this.dragMove = new i0.EventEmitter();
|
|
840
837
|
this.dragInertiaStart = new i0.EventEmitter();
|
|
841
838
|
this.dragEnd = new i0.EventEmitter();
|
|
842
|
-
this.dragRoot = ((_a = drag_root_dir === null || drag_root_dir === void 0 ? void 0 : drag_root_dir.el) === null || _a === void 0 ? void 0 : _a.nativeElement) || this._document.body;
|
|
843
839
|
}
|
|
844
840
|
DraggableDirective.prototype.ngOnInit = function () {
|
|
845
841
|
var _this = this;
|
|
846
|
-
var _a;
|
|
842
|
+
var _a, _b, _c, _d, _e;
|
|
847
843
|
this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
|
|
844
|
+
this.dragRootEl = (((_b = (_a = this.dragRoot) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.nativeElement) || ((_d = (_c = this.drag_root_dir) === null || _c === void 0 ? void 0 : _c.el) === null || _d === void 0 ? void 0 : _d.nativeElement)) || this._document.body;
|
|
848
845
|
// register with parent dropzone if it exists, otherwise use default
|
|
849
846
|
// this gives us a place on the registry to store our drag items that don't have a dropzone
|
|
850
|
-
this.registryId = ((
|
|
847
|
+
this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
851
848
|
// add draggable to directory and store its id
|
|
852
849
|
this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
853
850
|
this.alignPositionWithInputs(this.x, this.y);
|
|
@@ -903,7 +900,7 @@
|
|
|
903
900
|
DraggableDirective.prototype.setDragStyles = function (dragElement) {
|
|
904
901
|
this.renderer.setStyle(dragElement, 'touchAction', 'none');
|
|
905
902
|
this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
|
|
906
|
-
this.renderer.setStyle(dragElement, 'position', '
|
|
903
|
+
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
907
904
|
};
|
|
908
905
|
DraggableDirective.prototype.addDragPropertiesToElement = function (nativeElement) {
|
|
909
906
|
this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
|
|
@@ -949,8 +946,9 @@
|
|
|
949
946
|
var interaction = event.interaction;
|
|
950
947
|
// check if we should append drag element to body
|
|
951
948
|
if (_this.enableDragDefault
|
|
952
|
-
&& !!_this.dropzone_dir
|
|
953
949
|
&& interaction.pointerIsDown
|
|
950
|
+
// TODO: probably don't need following condition checks anymore remove by 2022
|
|
951
|
+
// && !!this.dropzone_dir
|
|
954
952
|
// && !interaction.interacting()
|
|
955
953
|
) {
|
|
956
954
|
if (_this._previewTemplate) {
|
|
@@ -962,8 +960,8 @@
|
|
|
962
960
|
}
|
|
963
961
|
_this.addDragPropertiesToElement(_this.previewRef);
|
|
964
962
|
_this.setDragStyles(_this.previewRef);
|
|
965
|
-
_this.
|
|
966
|
-
var
|
|
963
|
+
_this.dragRootEl.prepend(_this.previewRef);
|
|
964
|
+
var _f = _this.interactService.calculatePositionInElement(_this.dragRootEl, nativeElement), x = _f.x, y = _f.y;
|
|
967
965
|
_this.interactService.updatePosition(_this.interactableId, _this.registryId, { x: x, y: y }, _this.previewRef);
|
|
968
966
|
if (!_this.showPlaceholder) {
|
|
969
967
|
_this.renderer.setStyle(_this.el.nativeElement, 'display', 'none');
|
|
@@ -985,16 +983,15 @@
|
|
|
985
983
|
.on('dragend', function (event) {
|
|
986
984
|
var mappedEvent = _this.mapDragEvent(event);
|
|
987
985
|
if (!!_this.dropzone_dir && _this.dropzone_dir === event.target.dropTarget) {
|
|
988
|
-
var
|
|
986
|
+
var _f = mappedEvent.positionInDropTarget, x = _f.x, y = _f.y;
|
|
989
987
|
_this.setPosition(x, y);
|
|
990
988
|
}
|
|
991
989
|
_this.renderer.setStyle(_this.el.nativeElement, 'display', '');
|
|
992
990
|
_this.dragEnd.emit(mappedEvent);
|
|
993
991
|
if (_this.el.nativeElement !== _this.previewRef) {
|
|
994
|
-
// we do this in a timeout, so that we don't
|
|
995
|
-
// remove before the dropzone can get the boundingElementRect
|
|
992
|
+
// we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
|
|
996
993
|
setTimeout(function () {
|
|
997
|
-
_this.
|
|
994
|
+
_this.dragRootEl.removeChild(_this.previewRef);
|
|
998
995
|
});
|
|
999
996
|
}
|
|
1000
997
|
});
|
|
@@ -1018,7 +1015,7 @@
|
|
|
1018
1015
|
{ type: i0.Renderer2 },
|
|
1019
1016
|
{ type: i0.ViewContainerRef },
|
|
1020
1017
|
{ type: Document, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] },
|
|
1021
|
-
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }
|
|
1018
|
+
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] },
|
|
1022
1019
|
{ type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
|
|
1023
1020
|
{ type: DragRootDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
|
|
1024
1021
|
]; };
|
|
@@ -1034,6 +1031,7 @@
|
|
|
1034
1031
|
dragDisabled: [{ type: i0.Input }],
|
|
1035
1032
|
dragConfig: [{ type: i0.Input }],
|
|
1036
1033
|
showPlaceholder: [{ type: i0.Input }],
|
|
1034
|
+
dragRoot: [{ type: i0.Input }],
|
|
1037
1035
|
dragStart: [{ type: i0.Output }],
|
|
1038
1036
|
dragMove: [{ type: i0.Output }],
|
|
1039
1037
|
dragInertiaStart: [{ type: i0.Output }],
|
|
@@ -1280,6 +1278,36 @@
|
|
|
1280
1278
|
gestureEnd: [{ type: i0.Output }]
|
|
1281
1279
|
};
|
|
1282
1280
|
|
|
1281
|
+
var ApplyScaleDirective = /** @class */ (function () {
|
|
1282
|
+
function ApplyScaleDirective(el) {
|
|
1283
|
+
this.el = el;
|
|
1284
|
+
this._scale = 1;
|
|
1285
|
+
}
|
|
1286
|
+
Object.defineProperty(ApplyScaleDirective.prototype, "scale", {
|
|
1287
|
+
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
1288
|
+
set: function (val) {
|
|
1289
|
+
this._scale;
|
|
1290
|
+
this.fontSize = val + "px";
|
|
1291
|
+
},
|
|
1292
|
+
enumerable: false,
|
|
1293
|
+
configurable: true
|
|
1294
|
+
});
|
|
1295
|
+
;
|
|
1296
|
+
return ApplyScaleDirective;
|
|
1297
|
+
}());
|
|
1298
|
+
ApplyScaleDirective.decorators = [
|
|
1299
|
+
{ type: i0.Directive, args: [{
|
|
1300
|
+
selector: '[tftApplyScale]'
|
|
1301
|
+
},] }
|
|
1302
|
+
];
|
|
1303
|
+
ApplyScaleDirective.ctorParameters = function () { return [
|
|
1304
|
+
{ type: i0.ElementRef }
|
|
1305
|
+
]; };
|
|
1306
|
+
ApplyScaleDirective.propDecorators = {
|
|
1307
|
+
scale: [{ type: i0.Input }],
|
|
1308
|
+
fontSize: [{ type: i0.HostBinding, args: ['style.fontSize',] }]
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1283
1311
|
var EXPORTS = [
|
|
1284
1312
|
DraggableDirective,
|
|
1285
1313
|
ResizableDirective,
|
|
@@ -1287,17 +1315,29 @@
|
|
|
1287
1315
|
GesturableDirective,
|
|
1288
1316
|
DragRootDirective,
|
|
1289
1317
|
AccountForScaleDirective,
|
|
1318
|
+
ApplyScaleDirective,
|
|
1290
1319
|
DragPreviewDirective,
|
|
1291
1320
|
ArrayOfNPipe,
|
|
1292
1321
|
];
|
|
1293
1322
|
var InteractModule = /** @class */ (function () {
|
|
1294
1323
|
function InteractModule() {
|
|
1295
1324
|
}
|
|
1325
|
+
InteractModule.forRoot = function (config) {
|
|
1326
|
+
var defaultConfig = { cssDimensionUnit: 'px' };
|
|
1327
|
+
return {
|
|
1328
|
+
ngModule: InteractModule,
|
|
1329
|
+
providers: [
|
|
1330
|
+
{ provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
|
|
1331
|
+
InteractService
|
|
1332
|
+
]
|
|
1333
|
+
};
|
|
1334
|
+
};
|
|
1296
1335
|
return InteractModule;
|
|
1297
1336
|
}());
|
|
1298
1337
|
InteractModule.decorators = [
|
|
1299
1338
|
{ type: i0.NgModule, args: [{
|
|
1300
1339
|
imports: [common.CommonModule],
|
|
1340
|
+
// providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
|
|
1301
1341
|
declarations: __spreadArray([], __read(EXPORTS)),
|
|
1302
1342
|
exports: __spreadArray([], __read(EXPORTS))
|
|
1303
1343
|
},] }
|
|
@@ -1308,6 +1348,7 @@
|
|
|
1308
1348
|
*/
|
|
1309
1349
|
|
|
1310
1350
|
exports.AccountForScaleDirective = AccountForScaleDirective;
|
|
1351
|
+
exports.ApplyScaleDirective = ApplyScaleDirective;
|
|
1311
1352
|
exports.ArrayOfNPipe = ArrayOfNPipe;
|
|
1312
1353
|
exports.DEFAULT_REGISTRY_ID = DEFAULT_REGISTRY_ID;
|
|
1313
1354
|
exports.DragPreviewDirective = DragPreviewDirective;
|
|
@@ -1315,6 +1356,7 @@
|
|
|
1315
1356
|
exports.DraggableDirective = DraggableDirective;
|
|
1316
1357
|
exports.DropzoneDirective = DropzoneDirective;
|
|
1317
1358
|
exports.GesturableDirective = GesturableDirective;
|
|
1359
|
+
exports.INTERACT_ROOT_CONFIG = INTERACT_ROOT_CONFIG;
|
|
1318
1360
|
exports.InteractModule = InteractModule;
|
|
1319
1361
|
exports.ResizableDirective = ResizableDirective;
|
|
1320
1362
|
exports.TFT_DRAG_PREVIEW = TFT_DRAG_PREVIEW;
|
|
@@ -1330,8 +1372,9 @@
|
|
|
1330
1372
|
exports.ɵd = GesturableDirective;
|
|
1331
1373
|
exports.ɵe = DragRootDirective;
|
|
1332
1374
|
exports.ɵf = AccountForScaleDirective;
|
|
1333
|
-
exports.ɵg =
|
|
1334
|
-
exports.ɵh =
|
|
1375
|
+
exports.ɵg = ApplyScaleDirective;
|
|
1376
|
+
exports.ɵh = DragPreviewDirective;
|
|
1377
|
+
exports.ɵi = ArrayOfNPipe;
|
|
1335
1378
|
|
|
1336
1379
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1337
1380
|
|