@tft/interact 12.4.2 → 12.5.2
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 +133 -109
- package/bundles/tft-interact.umd.js.map +1 -1
- package/esm2015/lib/directives/account-for-scale.directive.js +3 -11
- 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 +4 -13
- package/esm2015/lib/directives/apply-scale.directive.js.map +1 -1
- package/esm2015/lib/directives/apply-scale.directive.metadata.json +1 -1
- 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 +21 -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 +5 -4
- 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.map +1 -1
- package/esm2015/lib/directives/resizable.directive.js +29 -10
- package/esm2015/lib/directives/resizable.directive.js.map +1 -1
- package/esm2015/lib/directives/resizable.directive.metadata.json +1 -1
- package/esm2015/lib/interact.module.js +13 -0
- 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 +31 -36
- package/esm2015/lib/services/interact.service.js.map +1 -1
- package/esm2015/lib/services/interact.service.metadata.json +1 -1
- package/fesm2015/tft-interact.js +111 -96
- package/fesm2015/tft-interact.js.map +1 -1
- package/lib/directives/account-for-scale.directive.d.ts +1 -3
- package/lib/directives/apply-scale.directive.d.ts +4 -7
- package/lib/directives/drag-root.directive.d.ts +2 -1
- package/lib/directives/draggable.directive.d.ts +3 -1
- package/lib/directives/dropzone.directive.d.ts +5 -4
- package/lib/directives/resizable.directive.d.ts +3 -1
- package/lib/interact.module.d.ts +3 -0
- package/lib/models/interact.d.ts +10 -0
- package/lib/services/interact.service.d.ts +6 -7
- package/package.json +1 -1
- package/tft-interact-12.5.2.tgz +0 -0
- package/tft-interact.metadata.json +1 -1
- package/tft-interact-12.4.2.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 {
|
|
@@ -415,7 +419,7 @@
|
|
|
415
419
|
if (interactableId === void 0) { interactableId = null; }
|
|
416
420
|
var registryId = customRegistryId || DEFAULT_REGISTRY_ID;
|
|
417
421
|
// if we pass an id to createInteractableId then it is used when creating the interactable
|
|
418
|
-
// and returned, otherwise a
|
|
422
|
+
// and returned, otherwise a new id is created for the draggable.
|
|
419
423
|
var key = this.createInteractableId(interactableId);
|
|
420
424
|
if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {
|
|
421
425
|
this.dragRegistrySystem[registryId] = {};
|
|
@@ -425,7 +429,16 @@
|
|
|
425
429
|
};
|
|
426
430
|
InteractService.prototype.destroyInteractable = function (interactableId, registryId) {
|
|
427
431
|
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
428
|
-
|
|
432
|
+
var interactableSystem = this.dragRegistrySystem[registryId][interactableId];
|
|
433
|
+
if (interactableSystem) {
|
|
434
|
+
// unsubscribe from all the subscriptions if they're subscriptions
|
|
435
|
+
for (var propName in interactableSystem) {
|
|
436
|
+
var prop = interactableSystem[propName];
|
|
437
|
+
if (prop.unsubscribe && typeof prop.unsubscribe === 'function') {
|
|
438
|
+
prop.unsubscribe();
|
|
439
|
+
}
|
|
440
|
+
;
|
|
441
|
+
}
|
|
429
442
|
delete this.dragRegistrySystem[registryId][interactableId];
|
|
430
443
|
}
|
|
431
444
|
};
|
|
@@ -446,8 +459,8 @@
|
|
|
446
459
|
// startWith({...initialSize, ...initialDelta}),
|
|
447
460
|
operators.shareReplay(1),
|
|
448
461
|
// filter(resizeEvent => !!resizeEvent.targetElement),
|
|
449
|
-
operators.tap(function (
|
|
450
|
-
var deltaX =
|
|
462
|
+
operators.tap(function (_a) {
|
|
463
|
+
var deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, targetElement = _a.targetElement;
|
|
451
464
|
_this.ngZone.runOutsideAngular(function () {
|
|
452
465
|
_this.setElementSize(width, height, targetElement);
|
|
453
466
|
});
|
|
@@ -466,8 +479,8 @@
|
|
|
466
479
|
_this.setElementTransform(position.x, position.y, position);
|
|
467
480
|
});
|
|
468
481
|
}))
|
|
469
|
-
]).pipe(operators.shareReplay(1), operators.map(function (
|
|
470
|
-
var
|
|
482
|
+
]).pipe(operators.shareReplay(1), operators.map(function (_a) {
|
|
483
|
+
var _b = __read(_a, 3), size = _b[0], deltas = _b[1], position = _b[2];
|
|
471
484
|
return {
|
|
472
485
|
x: position.x,
|
|
473
486
|
y: position.y,
|
|
@@ -497,28 +510,28 @@
|
|
|
497
510
|
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
498
511
|
return this.dragRegistrySystem[registryId][interactableId].interactable$;
|
|
499
512
|
};
|
|
500
|
-
InteractService.prototype.updateDeltas = function (interactId, registryId,
|
|
501
|
-
var deltaX =
|
|
513
|
+
InteractService.prototype.updateDeltas = function (interactId, registryId, _a, targetElement) {
|
|
514
|
+
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
502
515
|
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
503
516
|
return;
|
|
504
517
|
this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX: deltaX, deltaY: deltaY, targetElement: targetElement });
|
|
505
518
|
};
|
|
506
|
-
InteractService.prototype.updatePosition = function (interactId, registryId,
|
|
507
|
-
var x =
|
|
519
|
+
InteractService.prototype.updatePosition = function (interactId, registryId, _a, targetElement) {
|
|
520
|
+
var x = _a.x, y = _a.y;
|
|
508
521
|
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
509
522
|
return;
|
|
510
523
|
this.dragRegistrySystem[registryId][interactId].position$.next({ x: x, y: y, targetElement: targetElement });
|
|
511
524
|
};
|
|
512
|
-
InteractService.prototype.updateSize = function (interactId, registryId,
|
|
513
|
-
var deltaX =
|
|
525
|
+
InteractService.prototype.updateSize = function (interactId, registryId, _a, targetElement) {
|
|
526
|
+
var deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height;
|
|
514
527
|
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
515
528
|
return;
|
|
516
529
|
this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX: deltaX, deltaY: deltaY, width: width, height: height, targetElement: targetElement });
|
|
517
530
|
};
|
|
518
531
|
InteractService.prototype.interactableExistOnRegistry = function (interactId, registryId) {
|
|
519
532
|
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
520
|
-
|
|
521
|
-
|
|
533
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
534
|
+
return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
|
|
522
535
|
};
|
|
523
536
|
/**
|
|
524
537
|
* Uses renderer to set width and height of angular component
|
|
@@ -527,21 +540,10 @@
|
|
|
527
540
|
* @param target the element to transform
|
|
528
541
|
*/
|
|
529
542
|
InteractService.prototype.setElementSize = function (width, height, target) {
|
|
530
|
-
var _a;
|
|
531
543
|
if (!target)
|
|
532
544
|
return;
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
var scaleX = accountForScaleDirective.scaleX, scaleY = accountForScaleDirective.scaleY;
|
|
536
|
-
var scaledWidth = width / scaleX;
|
|
537
|
-
var scaledHeight = height / scaleY;
|
|
538
|
-
this.renderer.setStyle(target, 'width', scaledWidth + "px");
|
|
539
|
-
this.renderer.setStyle(target, 'height', scaledHeight + "px");
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
this.renderer.setStyle(target, 'width', width + "px");
|
|
543
|
-
this.renderer.setStyle(target, 'height', height + "px");
|
|
544
|
-
}
|
|
545
|
+
this.renderer.setStyle(target, 'width', "" + width + this.cssUnit);
|
|
546
|
+
this.renderer.setStyle(target, 'height', "" + height + this.cssUnit);
|
|
545
547
|
};
|
|
546
548
|
/**
|
|
547
549
|
* Uses renderer to set position of angular component
|
|
@@ -550,19 +552,10 @@
|
|
|
550
552
|
* @param target the element to transform
|
|
551
553
|
*/
|
|
552
554
|
InteractService.prototype.setElementTransform = function (x, y, position) {
|
|
553
|
-
var _a, _b;
|
|
554
555
|
if (!(position === null || position === void 0 ? void 0 : position.targetElement))
|
|
555
556
|
return;
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
var scaleX = accountForScaleDirective.scaleX, scaleY = accountForScaleDirective.scaleY;
|
|
559
|
-
this.renderer.setStyle(position.targetElement, 'left', x / scaleX + "px");
|
|
560
|
-
this.renderer.setStyle(position.targetElement, 'top', y / scaleY + "px");
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
this.renderer.setStyle(position.targetElement, 'left', x + "px");
|
|
564
|
-
this.renderer.setStyle(position.targetElement, 'top', y + "px");
|
|
565
|
-
}
|
|
557
|
+
this.renderer.setStyle(position.targetElement, 'left', "" + x + this.cssUnit);
|
|
558
|
+
this.renderer.setStyle(position.targetElement, 'top', "" + y + this.cssUnit);
|
|
566
559
|
};
|
|
567
560
|
/**
|
|
568
561
|
* Generates a translate string for the x and y arguments passed to
|
|
@@ -571,7 +564,7 @@
|
|
|
571
564
|
* @param y the position along the y axis
|
|
572
565
|
*/
|
|
573
566
|
InteractService.prototype.createTransformString = function (x, y) {
|
|
574
|
-
return "translate3d(" + x + "
|
|
567
|
+
return "translate3d(" + x + this.cssUnit + ", " + y + this.cssUnit + ", 0)";
|
|
575
568
|
};
|
|
576
569
|
InteractService.prototype.calculatePositionInElement = function (zoneElement, dragElement, scale) {
|
|
577
570
|
// TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
|
|
@@ -579,23 +572,25 @@
|
|
|
579
572
|
var dragRect = dragElement.getBoundingClientRect();
|
|
580
573
|
var position = scale
|
|
581
574
|
? {
|
|
582
|
-
x: (dragRect.left - zoneRect.left) / scale
|
|
583
|
-
y: (dragRect.top - zoneRect.top) / scale
|
|
575
|
+
x: (dragRect.left - zoneRect.left) / scale || 1,
|
|
576
|
+
y: (dragRect.top - zoneRect.top) / scale || 1
|
|
584
577
|
} : {
|
|
585
578
|
x: dragRect.left - zoneRect.left,
|
|
586
579
|
y: dragRect.top - zoneRect.top
|
|
587
580
|
};
|
|
581
|
+
// console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
|
|
588
582
|
return position;
|
|
589
583
|
};
|
|
590
584
|
return InteractService;
|
|
591
585
|
}());
|
|
592
|
-
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" });
|
|
586
|
+
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" });
|
|
593
587
|
InteractService.decorators = [
|
|
594
588
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
595
589
|
];
|
|
596
590
|
InteractService.ctorParameters = function () { return [
|
|
597
591
|
{ type: i0.RendererFactory2 },
|
|
598
|
-
{ type: i0.NgZone }
|
|
592
|
+
{ type: i0.NgZone },
|
|
593
|
+
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [INTERACT_ROOT_CONFIG,] }] }
|
|
599
594
|
]; };
|
|
600
595
|
|
|
601
596
|
/**
|
|
@@ -607,19 +602,9 @@
|
|
|
607
602
|
var AccountForScaleDirective = /** @class */ (function () {
|
|
608
603
|
function AccountForScaleDirective(el) {
|
|
609
604
|
this.el = el;
|
|
610
|
-
this.scaleX = 1;
|
|
611
|
-
this.scaleY = 1;
|
|
612
|
-
}
|
|
613
|
-
Object.defineProperty(AccountForScaleDirective.prototype, "scale", {
|
|
614
605
|
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
this.scaleX = val;
|
|
618
|
-
},
|
|
619
|
-
enumerable: false,
|
|
620
|
-
configurable: true
|
|
621
|
-
});
|
|
622
|
-
;
|
|
606
|
+
this.scale = 1;
|
|
607
|
+
}
|
|
623
608
|
return AccountForScaleDirective;
|
|
624
609
|
}());
|
|
625
610
|
AccountForScaleDirective.decorators = [
|
|
@@ -631,9 +616,7 @@
|
|
|
631
616
|
{ type: i0.ElementRef }
|
|
632
617
|
]; };
|
|
633
618
|
AccountForScaleDirective.propDecorators = {
|
|
634
|
-
scale: [{ type: i0.Input }]
|
|
635
|
-
scaleX: [{ type: i0.Input }],
|
|
636
|
-
scaleY: [{ type: i0.Input }]
|
|
619
|
+
scale: [{ type: i0.Input }]
|
|
637
620
|
};
|
|
638
621
|
|
|
639
622
|
var DropzoneDirective = /** @class */ (function () {
|
|
@@ -649,6 +632,14 @@
|
|
|
649
632
|
this.dragLeave = new i0.EventEmitter();
|
|
650
633
|
this.dragDrop = new i0.EventEmitter();
|
|
651
634
|
}
|
|
635
|
+
Object.defineProperty(DropzoneDirective.prototype, "scale", {
|
|
636
|
+
get: function () {
|
|
637
|
+
var _a;
|
|
638
|
+
return (_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale;
|
|
639
|
+
},
|
|
640
|
+
enumerable: false,
|
|
641
|
+
configurable: true
|
|
642
|
+
});
|
|
652
643
|
DropzoneDirective.prototype.ngOnInit = function () {
|
|
653
644
|
// connects
|
|
654
645
|
this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig);
|
|
@@ -695,10 +686,7 @@
|
|
|
695
686
|
var _a, _b;
|
|
696
687
|
var zoneElement = event.target;
|
|
697
688
|
var dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
|
|
698
|
-
var scale = this.
|
|
699
|
-
x: this.account_for_scale_dir.scaleX,
|
|
700
|
-
y: this.account_for_scale_dir.scaleY
|
|
701
|
-
} : null;
|
|
689
|
+
var scale = this.scale;
|
|
702
690
|
var positionInDropTarget = zoneElement && dragElement
|
|
703
691
|
? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
|
|
704
692
|
: null;
|
|
@@ -797,22 +785,19 @@
|
|
|
797
785
|
* @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
|
|
798
786
|
*/
|
|
799
787
|
var DragRootDirective = /** @class */ (function () {
|
|
800
|
-
function DragRootDirective(el,
|
|
788
|
+
function DragRootDirective(el,
|
|
789
|
+
// This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
|
|
790
|
+
// 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
|
|
791
|
+
account_for_scale_dir) {
|
|
801
792
|
this.el = el;
|
|
802
|
-
|
|
803
|
-
// with a dropzone inside of it and a drag item inside the dropzone
|
|
804
|
-
// e.g <div tftDragRoot> <div tftDropzone> <div tftDraggable</div> </div> </div>
|
|
805
|
-
// TODO: This is a band-aid, root cause in misunderstood, it started after switching from
|
|
806
|
-
// using `translate3d` to top/left for positioning
|
|
807
|
-
if (!account_for_scale_dir) {
|
|
808
|
-
el.nativeElement.style.transform = 'scale(1)';
|
|
809
|
-
}
|
|
793
|
+
this.account_for_scale_dir = account_for_scale_dir;
|
|
810
794
|
}
|
|
811
795
|
return DragRootDirective;
|
|
812
796
|
}());
|
|
813
797
|
DragRootDirective.decorators = [
|
|
814
798
|
{ type: i0.Directive, args: [{
|
|
815
|
-
selector: '[tftDragRoot]'
|
|
799
|
+
selector: '[tftDragRoot]',
|
|
800
|
+
exportAs: 'tftDragRoot'
|
|
816
801
|
},] }
|
|
817
802
|
];
|
|
818
803
|
DragRootDirective.ctorParameters = function () { return [
|
|
@@ -823,7 +808,6 @@
|
|
|
823
808
|
/** @dynamic */
|
|
824
809
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
825
810
|
var DraggableDirective = /** @class */ (function () {
|
|
826
|
-
// cache holding element to use as placeholder while dragging
|
|
827
811
|
function DraggableDirective(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
|
|
828
812
|
this.el = el;
|
|
829
813
|
this.interactService = interactService;
|
|
@@ -848,14 +832,23 @@
|
|
|
848
832
|
this.dragInertiaStart = new i0.EventEmitter();
|
|
849
833
|
this.dragEnd = new i0.EventEmitter();
|
|
850
834
|
}
|
|
835
|
+
Object.defineProperty(DraggableDirective.prototype, "scale", {
|
|
836
|
+
// check all the different places for scale
|
|
837
|
+
get: function () {
|
|
838
|
+
var _a, _b, _c, _d;
|
|
839
|
+
return ((_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_b = this.drag_root_dir) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir.scale) || ((_d = (_c = this.dragRoot) === null || _c === void 0 ? void 0 : _c.account_for_scale_dir) === null || _d === void 0 ? void 0 : _d.scale);
|
|
840
|
+
},
|
|
841
|
+
enumerable: false,
|
|
842
|
+
configurable: true
|
|
843
|
+
});
|
|
851
844
|
DraggableDirective.prototype.ngOnInit = function () {
|
|
852
845
|
var _this = this;
|
|
853
|
-
var _a, _b, _c;
|
|
846
|
+
var _a, _b, _c, _d, _e;
|
|
854
847
|
this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
|
|
855
|
-
this.
|
|
848
|
+
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;
|
|
856
849
|
// register with parent dropzone if it exists, otherwise use default
|
|
857
850
|
// this gives us a place on the registry to store our drag items that don't have a dropzone
|
|
858
|
-
this.registryId = ((
|
|
851
|
+
this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
859
852
|
// add draggable to directory and store its id
|
|
860
853
|
this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
861
854
|
this.alignPositionWithInputs(this.x, this.y);
|
|
@@ -906,12 +899,15 @@
|
|
|
906
899
|
};
|
|
907
900
|
DraggableDirective.prototype.dragMoveListener = function (event, element) {
|
|
908
901
|
var dx = event.dx, dy = event.dy;
|
|
909
|
-
|
|
902
|
+
var scale = this.scale;
|
|
903
|
+
var deltaX = scale ? dx / scale : dx;
|
|
904
|
+
var deltaY = scale ? dy / scale : dy;
|
|
905
|
+
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY }, element);
|
|
910
906
|
};
|
|
911
907
|
DraggableDirective.prototype.setDragStyles = function (dragElement) {
|
|
912
908
|
this.renderer.setStyle(dragElement, 'touchAction', 'none');
|
|
913
909
|
this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
|
|
914
|
-
this.renderer.setStyle(dragElement, 'position', '
|
|
910
|
+
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
915
911
|
};
|
|
916
912
|
DraggableDirective.prototype.addDragPropertiesToElement = function (nativeElement) {
|
|
917
913
|
this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
|
|
@@ -922,8 +918,9 @@
|
|
|
922
918
|
var _a;
|
|
923
919
|
var target = event.target, dropzone = event.dropzone;
|
|
924
920
|
var dropzoneElement = (dropzone === null || dropzone === void 0 ? void 0 : dropzone.target) || ((_a = target.dropTarget) === null || _a === void 0 ? void 0 : _a.el.nativeElement);
|
|
921
|
+
var scale = this.scale;
|
|
925
922
|
var positionInDropTarget = target && dropzoneElement
|
|
926
|
-
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef)
|
|
923
|
+
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
|
|
927
924
|
: null;
|
|
928
925
|
return {
|
|
929
926
|
interactEvent: event,
|
|
@@ -954,6 +951,7 @@
|
|
|
954
951
|
var _this = this;
|
|
955
952
|
return interact__default['default'](nativeElement).draggable(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }))
|
|
956
953
|
.on('dragstart', function (event) {
|
|
954
|
+
var _a, _b, _c;
|
|
957
955
|
var interaction = event.interaction;
|
|
958
956
|
// check if we should append drag element to body
|
|
959
957
|
if (_this.enableDragDefault
|
|
@@ -971,8 +969,9 @@
|
|
|
971
969
|
}
|
|
972
970
|
_this.addDragPropertiesToElement(_this.previewRef);
|
|
973
971
|
_this.setDragStyles(_this.previewRef);
|
|
974
|
-
_this.
|
|
975
|
-
var
|
|
972
|
+
_this.dragRootEl.prepend(_this.previewRef);
|
|
973
|
+
var scale = ((_a = _this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_c = (_b = _this.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || 1;
|
|
974
|
+
var _f = _this.interactService.calculatePositionInElement(_this.dragRootEl, nativeElement, scale), x = _f.x, y = _f.y;
|
|
976
975
|
_this.interactService.updatePosition(_this.interactableId, _this.registryId, { x: x, y: y }, _this.previewRef);
|
|
977
976
|
if (!_this.showPlaceholder) {
|
|
978
977
|
_this.renderer.setStyle(_this.el.nativeElement, 'display', 'none');
|
|
@@ -994,16 +993,15 @@
|
|
|
994
993
|
.on('dragend', function (event) {
|
|
995
994
|
var mappedEvent = _this.mapDragEvent(event);
|
|
996
995
|
if (!!_this.dropzone_dir && _this.dropzone_dir === event.target.dropTarget) {
|
|
997
|
-
var
|
|
996
|
+
var _f = mappedEvent.positionInDropTarget, x = _f.x, y = _f.y;
|
|
998
997
|
_this.setPosition(x, y);
|
|
999
998
|
}
|
|
1000
999
|
_this.renderer.setStyle(_this.el.nativeElement, 'display', '');
|
|
1001
1000
|
_this.dragEnd.emit(mappedEvent);
|
|
1002
1001
|
if (_this.el.nativeElement !== _this.previewRef) {
|
|
1003
|
-
// we do this in a timeout, so that we don't
|
|
1004
|
-
// remove before the dropzone can get the boundingElementRect
|
|
1002
|
+
// we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
|
|
1005
1003
|
setTimeout(function () {
|
|
1006
|
-
_this.
|
|
1004
|
+
_this.dragRootEl.removeChild(_this.previewRef);
|
|
1007
1005
|
});
|
|
1008
1006
|
}
|
|
1009
1007
|
});
|
|
@@ -1077,6 +1075,7 @@
|
|
|
1077
1075
|
this._document = _document;
|
|
1078
1076
|
this.interactService = interactService;
|
|
1079
1077
|
this.renderer = renderer;
|
|
1078
|
+
this.drag_root_dir = drag_root_dir;
|
|
1080
1079
|
this.account_for_scale_dir = account_for_scale_dir;
|
|
1081
1080
|
this.draggable_dir = draggable_dir;
|
|
1082
1081
|
this.dropzone_dir = dropzone_dir;
|
|
@@ -1091,8 +1090,16 @@
|
|
|
1091
1090
|
this.defaultConfig = {
|
|
1092
1091
|
edges: { left: true, right: true, bottom: true, top: true }
|
|
1093
1092
|
};
|
|
1094
|
-
this.
|
|
1093
|
+
this.dragRootEl = ((_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;
|
|
1095
1094
|
}
|
|
1095
|
+
Object.defineProperty(ResizableDirective.prototype, "scale", {
|
|
1096
|
+
get: function () {
|
|
1097
|
+
var _a, _b, _c;
|
|
1098
|
+
return ((_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_c = (_b = this.drag_root_dir) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale);
|
|
1099
|
+
},
|
|
1100
|
+
enumerable: false,
|
|
1101
|
+
configurable: true
|
|
1102
|
+
});
|
|
1096
1103
|
ResizableDirective.prototype.ngOnInit = function () {
|
|
1097
1104
|
var _a, _b;
|
|
1098
1105
|
this.addResizePropertiesToElement(this.el.nativeElement);
|
|
@@ -1120,9 +1127,23 @@
|
|
|
1120
1127
|
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
1121
1128
|
};
|
|
1122
1129
|
ResizableDirective.prototype.resizeListener = function (event) {
|
|
1123
|
-
var
|
|
1124
|
-
var
|
|
1125
|
-
var
|
|
1130
|
+
var scale = this.scale;
|
|
1131
|
+
var deltaX;
|
|
1132
|
+
var deltaY;
|
|
1133
|
+
var height;
|
|
1134
|
+
var width;
|
|
1135
|
+
if (scale) {
|
|
1136
|
+
deltaX = event.deltaRect.left / scale;
|
|
1137
|
+
deltaY = event.deltaRect.top / scale;
|
|
1138
|
+
height = event.rect.height / scale;
|
|
1139
|
+
width = event.rect.width / scale;
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
deltaX = event.deltaRect.left;
|
|
1143
|
+
deltaY = event.deltaRect.top;
|
|
1144
|
+
width = event.rect.width;
|
|
1145
|
+
height = event.rect.height;
|
|
1146
|
+
}
|
|
1126
1147
|
this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY, width: width, height: height }, this.el.nativeElement);
|
|
1127
1148
|
};
|
|
1128
1149
|
/**
|
|
@@ -1153,21 +1174,21 @@
|
|
|
1153
1174
|
var _a, _b;
|
|
1154
1175
|
var target = event.target;
|
|
1155
1176
|
var relatedTarget = (_b = (_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.dropzone_dir) === null || _b === void 0 ? void 0 : _b.el.nativeElement;
|
|
1156
|
-
var scale = this.
|
|
1157
|
-
x: this.account_for_scale_dir.scaleX,
|
|
1158
|
-
y: this.account_for_scale_dir.scaleY
|
|
1159
|
-
} : null;
|
|
1177
|
+
var scale = this.scale;
|
|
1160
1178
|
var positionInDropTarget = target && relatedTarget
|
|
1161
1179
|
? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
|
|
1162
1180
|
: null;
|
|
1163
1181
|
return {
|
|
1164
1182
|
interactEvent: event,
|
|
1165
1183
|
resizeRef: this,
|
|
1166
|
-
// should I remove this?
|
|
1167
1184
|
dragRef: this.draggable_dir,
|
|
1168
1185
|
dragOrigin: this.dropzone_dir,
|
|
1169
1186
|
dropTarget: this.el.nativeElement.dropTarget,
|
|
1170
|
-
positionInDropTarget: positionInDropTarget
|
|
1187
|
+
positionInDropTarget: positionInDropTarget,
|
|
1188
|
+
size: {
|
|
1189
|
+
width: target.clientWidth / scale,
|
|
1190
|
+
height: target.clientHeight / scale
|
|
1191
|
+
}
|
|
1171
1192
|
};
|
|
1172
1193
|
};
|
|
1173
1194
|
ResizableDirective.prototype.alignDimensionsWithInputs = function (width, height) {
|
|
@@ -1297,24 +1318,18 @@
|
|
|
1297
1318
|
var ApplyScaleDirective = /** @class */ (function () {
|
|
1298
1319
|
function ApplyScaleDirective(el) {
|
|
1299
1320
|
this.el = el;
|
|
1300
|
-
this.
|
|
1301
|
-
this.scaleY = 1;
|
|
1302
|
-
this.transformOrigin = '0 0';
|
|
1321
|
+
this._scale = 1;
|
|
1303
1322
|
}
|
|
1304
1323
|
Object.defineProperty(ApplyScaleDirective.prototype, "scale", {
|
|
1305
1324
|
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
1306
1325
|
set: function (val) {
|
|
1307
|
-
this.
|
|
1308
|
-
this.
|
|
1326
|
+
this._scale;
|
|
1327
|
+
this.fontSize = val + "px";
|
|
1309
1328
|
},
|
|
1310
1329
|
enumerable: false,
|
|
1311
1330
|
configurable: true
|
|
1312
1331
|
});
|
|
1313
1332
|
;
|
|
1314
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1315
|
-
ApplyScaleDirective.prototype.ngOnChanges = function (_changes) {
|
|
1316
|
-
this.transform = "scaleX(" + this.scaleX + ") scaleY(" + this.scaleY + ")";
|
|
1317
|
-
};
|
|
1318
1333
|
return ApplyScaleDirective;
|
|
1319
1334
|
}());
|
|
1320
1335
|
ApplyScaleDirective.decorators = [
|
|
@@ -1327,10 +1342,7 @@
|
|
|
1327
1342
|
]; };
|
|
1328
1343
|
ApplyScaleDirective.propDecorators = {
|
|
1329
1344
|
scale: [{ type: i0.Input }],
|
|
1330
|
-
|
|
1331
|
-
scaleY: [{ type: i0.Input }],
|
|
1332
|
-
transform: [{ type: i0.HostBinding, args: ['style.transform',] }],
|
|
1333
|
-
transformOrigin: [{ type: i0.Input }, { type: i0.HostBinding, args: ['style.transformOrigin',] }]
|
|
1345
|
+
fontSize: [{ type: i0.HostBinding, args: ['style.fontSize',] }]
|
|
1334
1346
|
};
|
|
1335
1347
|
|
|
1336
1348
|
var EXPORTS = [
|
|
@@ -1347,11 +1359,22 @@
|
|
|
1347
1359
|
var InteractModule = /** @class */ (function () {
|
|
1348
1360
|
function InteractModule() {
|
|
1349
1361
|
}
|
|
1362
|
+
InteractModule.forRoot = function (config) {
|
|
1363
|
+
var defaultConfig = { cssDimensionUnit: 'px' };
|
|
1364
|
+
return {
|
|
1365
|
+
ngModule: InteractModule,
|
|
1366
|
+
providers: [
|
|
1367
|
+
{ provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
|
|
1368
|
+
InteractService
|
|
1369
|
+
]
|
|
1370
|
+
};
|
|
1371
|
+
};
|
|
1350
1372
|
return InteractModule;
|
|
1351
1373
|
}());
|
|
1352
1374
|
InteractModule.decorators = [
|
|
1353
1375
|
{ type: i0.NgModule, args: [{
|
|
1354
1376
|
imports: [common.CommonModule],
|
|
1377
|
+
// providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
|
|
1355
1378
|
declarations: __spreadArray([], __read(EXPORTS)),
|
|
1356
1379
|
exports: __spreadArray([], __read(EXPORTS))
|
|
1357
1380
|
},] }
|
|
@@ -1370,6 +1393,7 @@
|
|
|
1370
1393
|
exports.DraggableDirective = DraggableDirective;
|
|
1371
1394
|
exports.DropzoneDirective = DropzoneDirective;
|
|
1372
1395
|
exports.GesturableDirective = GesturableDirective;
|
|
1396
|
+
exports.INTERACT_ROOT_CONFIG = INTERACT_ROOT_CONFIG;
|
|
1373
1397
|
exports.InteractModule = InteractModule;
|
|
1374
1398
|
exports.ResizableDirective = ResizableDirective;
|
|
1375
1399
|
exports.TFT_DRAG_PREVIEW = TFT_DRAG_PREVIEW;
|