@tft/interact 12.4.1 → 12.5.1

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.
Files changed (45) hide show
  1. package/bundles/tft-interact.umd.js +158 -124
  2. package/bundles/tft-interact.umd.js.map +1 -1
  3. package/esm2015/lib/directives/account-for-scale.directive.js +3 -11
  4. package/esm2015/lib/directives/account-for-scale.directive.js.map +1 -1
  5. package/esm2015/lib/directives/account-for-scale.directive.metadata.json +1 -1
  6. package/esm2015/lib/directives/apply-scale.directive.js +4 -13
  7. package/esm2015/lib/directives/apply-scale.directive.js.map +1 -1
  8. package/esm2015/lib/directives/apply-scale.directive.metadata.json +1 -1
  9. package/esm2015/lib/directives/drag-root.directive.js +8 -11
  10. package/esm2015/lib/directives/drag-root.directive.js.map +1 -1
  11. package/esm2015/lib/directives/drag-root.directive.metadata.json +1 -1
  12. package/esm2015/lib/directives/draggable.directive.js +21 -12
  13. package/esm2015/lib/directives/draggable.directive.js.map +1 -1
  14. package/esm2015/lib/directives/draggable.directive.metadata.json +1 -1
  15. package/esm2015/lib/directives/dropzone.directive.js +12 -4
  16. package/esm2015/lib/directives/dropzone.directive.js.map +1 -1
  17. package/esm2015/lib/directives/dropzone.directive.metadata.json +1 -1
  18. package/esm2015/lib/directives/index.js.map +1 -1
  19. package/esm2015/lib/directives/resizable.directive.js +27 -8
  20. package/esm2015/lib/directives/resizable.directive.js.map +1 -1
  21. package/esm2015/lib/directives/resizable.directive.metadata.json +1 -1
  22. package/esm2015/lib/interact.module.js +13 -0
  23. package/esm2015/lib/interact.module.js.map +1 -1
  24. package/esm2015/lib/interact.module.metadata.json +1 -1
  25. package/esm2015/lib/models/interact.js +2 -0
  26. package/esm2015/lib/models/interact.js.map +1 -1
  27. package/esm2015/lib/models/interact.metadata.json +1 -1
  28. package/esm2015/lib/services/interact.service.js +31 -32
  29. package/esm2015/lib/services/interact.service.js.map +1 -1
  30. package/esm2015/lib/services/interact.service.metadata.json +1 -1
  31. package/fesm2015/tft-interact.js +136 -111
  32. package/fesm2015/tft-interact.js.map +1 -1
  33. package/lib/directives/account-for-scale.directive.d.ts +1 -3
  34. package/lib/directives/apply-scale.directive.d.ts +4 -7
  35. package/lib/directives/drag-root.directive.d.ts +2 -1
  36. package/lib/directives/draggable.directive.d.ts +3 -1
  37. package/lib/directives/dropzone.directive.d.ts +8 -5
  38. package/lib/directives/resizable.directive.d.ts +3 -1
  39. package/lib/interact.module.d.ts +3 -0
  40. package/lib/models/interact.d.ts +6 -0
  41. package/lib/services/interact.service.d.ts +6 -4
  42. package/package.json +1 -1
  43. package/tft-interact-12.5.1.tgz +0 -0
  44. package/tft-interact.metadata.json +1 -1
  45. package/tft-interact-12.4.1.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 an id is created for the draggable.
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] = {};
@@ -426,6 +430,11 @@
426
430
  InteractService.prototype.destroyInteractable = function (interactableId, registryId) {
427
431
  if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
428
432
  if (this.dragRegistrySystem[registryId][interactableId]) {
433
+ // unsubscribe from all the subscriptions if they're subscriptions
434
+ for (var propName in this.dragRegistrySystem[registryId][interactableId]) {
435
+ var prop = this.dragRegistrySystem[registryId][interactableId][propName];
436
+ prop === null || prop === void 0 ? void 0 : prop.unsubscribe();
437
+ }
429
438
  delete this.dragRegistrySystem[registryId][interactableId];
430
439
  }
431
440
  };
@@ -446,8 +455,8 @@
446
455
  // startWith({...initialSize, ...initialDelta}),
447
456
  operators.shareReplay(1),
448
457
  // filter(resizeEvent => !!resizeEvent.targetElement),
449
- operators.tap(function (_e) {
450
- var deltaX = _e.deltaX, deltaY = _e.deltaY, width = _e.width, height = _e.height, targetElement = _e.targetElement;
458
+ operators.tap(function (_a) {
459
+ var deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, targetElement = _a.targetElement;
451
460
  _this.ngZone.runOutsideAngular(function () {
452
461
  _this.setElementSize(width, height, targetElement);
453
462
  });
@@ -466,8 +475,8 @@
466
475
  _this.setElementTransform(position.x, position.y, position);
467
476
  });
468
477
  }))
469
- ]).pipe(operators.shareReplay(1), operators.map(function (_e) {
470
- var _f = __read(_e, 3), size = _f[0], deltas = _f[1], position = _f[2];
478
+ ]).pipe(operators.shareReplay(1), operators.map(function (_a) {
479
+ var _b = __read(_a, 3), size = _b[0], deltas = _b[1], position = _b[2];
471
480
  return {
472
481
  x: position.x,
473
482
  y: position.y,
@@ -497,28 +506,28 @@
497
506
  if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
498
507
  return this.dragRegistrySystem[registryId][interactableId].interactable$;
499
508
  };
500
- InteractService.prototype.updateDeltas = function (interactId, registryId, _e, targetElement) {
501
- var deltaX = _e.deltaX, deltaY = _e.deltaY;
509
+ InteractService.prototype.updateDeltas = function (interactId, registryId, _a, targetElement) {
510
+ var deltaX = _a.deltaX, deltaY = _a.deltaY;
502
511
  if (!this.interactableExistOnRegistry(interactId, registryId))
503
512
  return;
504
513
  this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX: deltaX, deltaY: deltaY, targetElement: targetElement });
505
514
  };
506
- InteractService.prototype.updatePosition = function (interactId, registryId, _e, targetElement) {
507
- var x = _e.x, y = _e.y;
515
+ InteractService.prototype.updatePosition = function (interactId, registryId, _a, targetElement) {
516
+ var x = _a.x, y = _a.y;
508
517
  if (!this.interactableExistOnRegistry(interactId, registryId))
509
518
  return;
510
519
  this.dragRegistrySystem[registryId][interactId].position$.next({ x: x, y: y, targetElement: targetElement });
511
520
  };
512
- InteractService.prototype.updateSize = function (interactId, registryId, _e, targetElement) {
513
- var deltaX = _e.deltaX, deltaY = _e.deltaY, width = _e.width, height = _e.height;
521
+ InteractService.prototype.updateSize = function (interactId, registryId, _a, targetElement) {
522
+ var deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height;
514
523
  if (!this.interactableExistOnRegistry(interactId, registryId))
515
524
  return;
516
525
  this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX: deltaX, deltaY: deltaY, width: width, height: height, targetElement: targetElement });
517
526
  };
518
527
  InteractService.prototype.interactableExistOnRegistry = function (interactId, registryId) {
519
528
  if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
520
- return this.dragRegistrySystem.hasOwnProperty(registryId)
521
- && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
529
+ // eslint-disable-next-line no-prototype-builtins
530
+ return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
522
531
  };
523
532
  /**
524
533
  * Uses renderer to set width and height of angular component
@@ -527,19 +536,10 @@
527
536
  * @param target the element to transform
528
537
  */
529
538
  InteractService.prototype.setElementSize = function (width, height, target) {
530
- var _a;
531
539
  if (!target)
532
540
  return;
533
- var accountForScaleDirective = (_a = target.resizeRef) === null || _a === void 0 ? void 0 : _a.account_for_scale_dir;
534
- if (accountForScaleDirective) {
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
- this.renderer.setStyle(target, 'width', width + "px");
542
- this.renderer.setStyle(target, 'height', height + "px");
541
+ this.renderer.setStyle(target, 'width', "" + width + this.cssUnit);
542
+ this.renderer.setStyle(target, 'height', "" + height + this.cssUnit);
543
543
  };
544
544
  /**
545
545
  * Uses renderer to set position of angular component
@@ -548,18 +548,10 @@
548
548
  * @param target the element to transform
549
549
  */
550
550
  InteractService.prototype.setElementTransform = function (x, y, position) {
551
- var _a, _b, _c, _d;
552
551
  if (!(position === null || position === void 0 ? void 0 : position.targetElement))
553
552
  return;
554
- if ((_b = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) {
555
- var _e = (_d = (_c = position.targetElement) === null || _c === void 0 ? void 0 : _c.dragRef) === null || _d === void 0 ? void 0 : _d.account_for_scale_dir, scaleX = _e.scaleX, scaleY = _e.scaleY;
556
- this.renderer.setStyle(position.targetElement, 'left', x / scaleX + "px");
557
- this.renderer.setStyle(position.targetElement, 'top', y / scaleY + "px");
558
- }
559
- else {
560
- this.renderer.setStyle(position.targetElement, 'left', x + "px");
561
- this.renderer.setStyle(position.targetElement, 'top', y + "px");
562
- }
553
+ this.renderer.setStyle(position.targetElement, 'left', "" + x + this.cssUnit);
554
+ this.renderer.setStyle(position.targetElement, 'top', "" + y + this.cssUnit);
563
555
  };
564
556
  /**
565
557
  * Generates a translate string for the x and y arguments passed to
@@ -568,33 +560,67 @@
568
560
  * @param y the position along the y axis
569
561
  */
570
562
  InteractService.prototype.createTransformString = function (x, y) {
571
- return "translate3d(" + x + "px, " + y + "px, 0)";
563
+ return "translate3d(" + x + this.cssUnit + ", " + y + this.cssUnit + ", 0)";
572
564
  };
573
- InteractService.prototype.calculatePositionInElement = function (zoneElement, dragElement) {
565
+ InteractService.prototype.calculatePositionInElement = function (zoneElement, dragElement, scale) {
574
566
  // TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
575
567
  var zoneRect = zoneElement.getBoundingClientRect();
576
568
  var dragRect = dragElement.getBoundingClientRect();
577
- return {
569
+ var position = scale
570
+ ? {
571
+ x: (dragRect.left - zoneRect.left) / scale || 1,
572
+ y: (dragRect.top - zoneRect.top) / scale || 1
573
+ } : {
578
574
  x: dragRect.left - zoneRect.left,
579
575
  y: dragRect.top - zoneRect.top
580
576
  };
577
+ // console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
578
+ return position;
581
579
  };
582
580
  return InteractService;
583
581
  }());
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" });
582
+ 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
583
  InteractService.decorators = [
586
584
  { type: i0.Injectable, args: [{ providedIn: 'root' },] }
587
585
  ];
588
586
  InteractService.ctorParameters = function () { return [
589
587
  { type: i0.RendererFactory2 },
590
- { type: i0.NgZone }
588
+ { type: i0.NgZone },
589
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [INTERACT_ROOT_CONFIG,] }] }
591
590
  ]; };
592
591
 
592
+ /**
593
+ * Use to apply scale to the element and tell the drag and resize directives to account for the scale when
594
+ * @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
595
+ * @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
596
+ * element accounts for scale
597
+ */
598
+ var AccountForScaleDirective = /** @class */ (function () {
599
+ function AccountForScaleDirective(el) {
600
+ this.el = el;
601
+ // this setup allows consumers to set x, y scale independently or just set them both with scale
602
+ this.scale = 1;
603
+ }
604
+ return AccountForScaleDirective;
605
+ }());
606
+ AccountForScaleDirective.decorators = [
607
+ { type: i0.Directive, args: [{
608
+ selector: '[tftAccountForScale]'
609
+ },] }
610
+ ];
611
+ AccountForScaleDirective.ctorParameters = function () { return [
612
+ { type: i0.ElementRef }
613
+ ]; };
614
+ AccountForScaleDirective.propDecorators = {
615
+ scale: [{ type: i0.Input }]
616
+ };
617
+
593
618
  var DropzoneDirective = /** @class */ (function () {
594
- function DropzoneDirective(el, renderer, interactService) {
619
+ function DropzoneDirective(el, renderer, interactService, account_for_scale_dir) {
595
620
  this.el = el;
596
621
  this.renderer = renderer;
597
622
  this.interactService = interactService;
623
+ this.account_for_scale_dir = account_for_scale_dir;
598
624
  this.dropzoneConfig = {};
599
625
  // proxies to pass interact events through to consumer of directive
600
626
  this.dropActivate = new i0.EventEmitter();
@@ -602,6 +628,14 @@
602
628
  this.dragLeave = new i0.EventEmitter();
603
629
  this.dragDrop = new i0.EventEmitter();
604
630
  }
631
+ Object.defineProperty(DropzoneDirective.prototype, "scale", {
632
+ get: function () {
633
+ var _a;
634
+ return (_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale;
635
+ },
636
+ enumerable: false,
637
+ configurable: true
638
+ });
605
639
  DropzoneDirective.prototype.ngOnInit = function () {
606
640
  // connects
607
641
  this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig);
@@ -648,8 +682,9 @@
648
682
  var _a, _b;
649
683
  var zoneElement = event.target;
650
684
  var dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
685
+ var scale = this.scale;
651
686
  var positionInDropTarget = zoneElement && dragElement
652
- ? this.interactService.calculatePositionInElement(zoneElement, dragElement)
687
+ ? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
653
688
  : null;
654
689
  return {
655
690
  interactEvent: event,
@@ -672,7 +707,8 @@
672
707
  DropzoneDirective.ctorParameters = function () { return [
673
708
  { type: i0.ElementRef },
674
709
  { type: i0.Renderer2 },
675
- { type: InteractService }
710
+ { type: InteractService },
711
+ { type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] }
676
712
  ]; };
677
713
  DropzoneDirective.propDecorators = {
678
714
  dropzoneId: [{ type: i0.Input }],
@@ -739,66 +775,25 @@
739
775
  return wrapper;
740
776
  }
741
777
 
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
- return AccountForScaleDirective;
765
- }());
766
- AccountForScaleDirective.decorators = [
767
- { type: i0.Directive, args: [{
768
- selector: '[tftAccountForScale]'
769
- },] }
770
- ];
771
- AccountForScaleDirective.ctorParameters = function () { return [
772
- { type: i0.ElementRef }
773
- ]; };
774
- AccountForScaleDirective.propDecorators = {
775
- scale: [{ type: i0.Input }],
776
- scaleX: [{ type: i0.Input }],
777
- scaleY: [{ type: i0.Input }]
778
- };
779
-
780
778
  /**
781
779
  * Use this directive to select which element to attach the element to while dragging
782
780
  * @example <div tftDragRoot><div tftDraggable> </div> </div>
783
781
  * @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
784
782
  */
785
783
  var DragRootDirective = /** @class */ (function () {
786
- function DragRootDirective(el, account_for_scale_dir) {
784
+ function DragRootDirective(el,
785
+ // This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
786
+ // 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
787
+ account_for_scale_dir) {
787
788
  this.el = el;
788
- // This accounts for a bug where drag element is misaligned when using a drag root
789
- // with a dropzone inside of it and a drag item inside the dropzone
790
- // e.g <div tftDragRoot> <div tftDropzone> <div tftDraggable</div> </div> </div>
791
- // TODO: This is a band-aid, root cause in misunderstood, it started after switching from
792
- // using `translate3d` to top/left for positioning
793
- if (!account_for_scale_dir) {
794
- el.nativeElement.style.transform = 'scale(1)';
795
- }
789
+ this.account_for_scale_dir = account_for_scale_dir;
796
790
  }
797
791
  return DragRootDirective;
798
792
  }());
799
793
  DragRootDirective.decorators = [
800
794
  { type: i0.Directive, args: [{
801
- selector: '[tftDragRoot]'
795
+ selector: '[tftDragRoot]',
796
+ exportAs: 'tftDragRoot'
802
797
  },] }
803
798
  ];
804
799
  DragRootDirective.ctorParameters = function () { return [
@@ -809,7 +804,6 @@
809
804
  /** @dynamic */
810
805
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
811
806
  var DraggableDirective = /** @class */ (function () {
812
- // cache holding element to use as placeholder while dragging
813
807
  function DraggableDirective(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
814
808
  this.el = el;
815
809
  this.interactService = interactService;
@@ -834,14 +828,23 @@
834
828
  this.dragInertiaStart = new i0.EventEmitter();
835
829
  this.dragEnd = new i0.EventEmitter();
836
830
  }
831
+ Object.defineProperty(DraggableDirective.prototype, "scale", {
832
+ // check all the different places for scale
833
+ get: function () {
834
+ var _a, _b, _c, _d;
835
+ 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);
836
+ },
837
+ enumerable: false,
838
+ configurable: true
839
+ });
837
840
  DraggableDirective.prototype.ngOnInit = function () {
838
841
  var _this = this;
839
- var _a, _b, _c;
842
+ var _a, _b, _c, _d, _e;
840
843
  this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
841
- this.dragRoot = this.dragRoot || ((_b = (_a = this.drag_root_dir) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.nativeElement) || this._document.body;
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;
842
845
  // register with parent dropzone if it exists, otherwise use default
843
846
  // this gives us a place on the registry to store our drag items that don't have a dropzone
844
- this.registryId = ((_c = this.dropzone_dir) === null || _c === void 0 ? void 0 : _c.dropzoneId) || DEFAULT_REGISTRY_ID;
847
+ this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
845
848
  // add draggable to directory and store its id
846
849
  this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
847
850
  this.alignPositionWithInputs(this.x, this.y);
@@ -892,12 +895,15 @@
892
895
  };
893
896
  DraggableDirective.prototype.dragMoveListener = function (event, element) {
894
897
  var dx = event.dx, dy = event.dy;
895
- this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX: dx, deltaY: dy }, element);
898
+ var scale = this.scale;
899
+ var deltaX = scale ? dx / scale : dx;
900
+ var deltaY = scale ? dy / scale : dy;
901
+ this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY }, element);
896
902
  };
897
903
  DraggableDirective.prototype.setDragStyles = function (dragElement) {
898
904
  this.renderer.setStyle(dragElement, 'touchAction', 'none');
899
905
  this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
900
- this.renderer.setStyle(dragElement, 'position', 'fixed');
906
+ this.renderer.setStyle(dragElement, 'position', 'absolute');
901
907
  };
902
908
  DraggableDirective.prototype.addDragPropertiesToElement = function (nativeElement) {
903
909
  this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
@@ -908,8 +914,9 @@
908
914
  var _a;
909
915
  var target = event.target, dropzone = event.dropzone;
910
916
  var dropzoneElement = (dropzone === null || dropzone === void 0 ? void 0 : dropzone.target) || ((_a = target.dropTarget) === null || _a === void 0 ? void 0 : _a.el.nativeElement);
917
+ var scale = this.scale;
911
918
  var positionInDropTarget = target && dropzoneElement
912
- ? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef)
919
+ ? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
913
920
  : null;
914
921
  return {
915
922
  interactEvent: event,
@@ -940,6 +947,7 @@
940
947
  var _this = this;
941
948
  return interact__default['default'](nativeElement).draggable(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }))
942
949
  .on('dragstart', function (event) {
950
+ var _a, _b, _c;
943
951
  var interaction = event.interaction;
944
952
  // check if we should append drag element to body
945
953
  if (_this.enableDragDefault
@@ -957,8 +965,9 @@
957
965
  }
958
966
  _this.addDragPropertiesToElement(_this.previewRef);
959
967
  _this.setDragStyles(_this.previewRef);
960
- _this.dragRoot.prepend(_this.previewRef);
961
- var _d = _this.interactService.calculatePositionInElement(_this.dragRoot, nativeElement), x = _d.x, y = _d.y;
968
+ _this.dragRootEl.prepend(_this.previewRef);
969
+ 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;
970
+ var _f = _this.interactService.calculatePositionInElement(_this.dragRootEl, nativeElement, scale), x = _f.x, y = _f.y;
962
971
  _this.interactService.updatePosition(_this.interactableId, _this.registryId, { x: x, y: y }, _this.previewRef);
963
972
  if (!_this.showPlaceholder) {
964
973
  _this.renderer.setStyle(_this.el.nativeElement, 'display', 'none');
@@ -980,16 +989,15 @@
980
989
  .on('dragend', function (event) {
981
990
  var mappedEvent = _this.mapDragEvent(event);
982
991
  if (!!_this.dropzone_dir && _this.dropzone_dir === event.target.dropTarget) {
983
- var _d = mappedEvent.positionInDropTarget, x = _d.x, y = _d.y;
992
+ var _f = mappedEvent.positionInDropTarget, x = _f.x, y = _f.y;
984
993
  _this.setPosition(x, y);
985
994
  }
986
995
  _this.renderer.setStyle(_this.el.nativeElement, 'display', '');
987
996
  _this.dragEnd.emit(mappedEvent);
988
997
  if (_this.el.nativeElement !== _this.previewRef) {
989
- // we do this in a timeout, so that we don't
990
- // remove before the dropzone can get the boundingElementRect
998
+ // we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
991
999
  setTimeout(function () {
992
- _this.dragRoot.removeChild(_this.previewRef);
1000
+ _this.dragRootEl.removeChild(_this.previewRef);
993
1001
  });
994
1002
  }
995
1003
  });
@@ -1063,6 +1071,7 @@
1063
1071
  this._document = _document;
1064
1072
  this.interactService = interactService;
1065
1073
  this.renderer = renderer;
1074
+ this.drag_root_dir = drag_root_dir;
1066
1075
  this.account_for_scale_dir = account_for_scale_dir;
1067
1076
  this.draggable_dir = draggable_dir;
1068
1077
  this.dropzone_dir = dropzone_dir;
@@ -1077,8 +1086,16 @@
1077
1086
  this.defaultConfig = {
1078
1087
  edges: { left: true, right: true, bottom: true, top: true }
1079
1088
  };
1080
- 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;
1089
+ 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;
1081
1090
  }
1091
+ Object.defineProperty(ResizableDirective.prototype, "scale", {
1092
+ get: function () {
1093
+ var _a, _b;
1094
+ 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);
1095
+ },
1096
+ enumerable: false,
1097
+ configurable: true
1098
+ });
1082
1099
  ResizableDirective.prototype.ngOnInit = function () {
1083
1100
  var _a, _b;
1084
1101
  this.addResizePropertiesToElement(this.el.nativeElement);
@@ -1106,9 +1123,23 @@
1106
1123
  this.interactService.destroyInteractable(this.interactableId, this.registryId);
1107
1124
  };
1108
1125
  ResizableDirective.prototype.resizeListener = function (event) {
1109
- var deltaX = event.deltaRect.left;
1110
- var deltaY = event.deltaRect.top;
1111
- var _c = event.rect, width = _c.width, height = _c.height;
1126
+ var scale = this.scale;
1127
+ var deltaX;
1128
+ var deltaY;
1129
+ var height;
1130
+ var width;
1131
+ if (scale) {
1132
+ deltaX = event.deltaRect.left / scale;
1133
+ deltaY = event.deltaRect.top / scale;
1134
+ height = event.rect.height / scale;
1135
+ width = event.rect.width / scale;
1136
+ }
1137
+ else {
1138
+ deltaX = event.deltaRect.left;
1139
+ deltaY = event.deltaRect.top;
1140
+ width = event.rect.width;
1141
+ height = event.rect.height;
1142
+ }
1112
1143
  this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY, width: width, height: height }, this.el.nativeElement);
1113
1144
  };
1114
1145
  /**
@@ -1136,16 +1167,16 @@
1136
1167
  .on('resizeend', function (event) { return _this.resizeEnd.emit(_this.mapResizeEvent(event)); });
1137
1168
  };
1138
1169
  ResizableDirective.prototype.mapResizeEvent = function (event) {
1139
- var _a, _b;
1170
+ var _a, _b, _c, _d, _e;
1140
1171
  var target = event.target;
1141
1172
  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;
1173
+ var scale = ((_c = this.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || ((_e = (_d = this.drag_root_dir) === null || _d === void 0 ? void 0 : _d.account_for_scale_dir) === null || _e === void 0 ? void 0 : _e.scale) || 1;
1142
1174
  var positionInDropTarget = target && relatedTarget
1143
- ? this.interactService.calculatePositionInElement(relatedTarget, target)
1175
+ ? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
1144
1176
  : null;
1145
1177
  return {
1146
1178
  interactEvent: event,
1147
1179
  resizeRef: this,
1148
- // should I remove this?
1149
1180
  dragRef: this.draggable_dir,
1150
1181
  dragOrigin: this.dropzone_dir,
1151
1182
  dropTarget: this.el.nativeElement.dropTarget,
@@ -1279,24 +1310,18 @@
1279
1310
  var ApplyScaleDirective = /** @class */ (function () {
1280
1311
  function ApplyScaleDirective(el) {
1281
1312
  this.el = el;
1282
- this.scaleX = 1;
1283
- this.scaleY = 1;
1284
- this.transformOrigin = '0 0';
1313
+ this._scale = 1;
1285
1314
  }
1286
1315
  Object.defineProperty(ApplyScaleDirective.prototype, "scale", {
1287
1316
  // this setup allows consumers to set x, y scale independently or just set them both with scale
1288
1317
  set: function (val) {
1289
- this.scaleY = val;
1290
- this.scaleX = val;
1318
+ this._scale;
1319
+ this.fontSize = val + "px";
1291
1320
  },
1292
1321
  enumerable: false,
1293
1322
  configurable: true
1294
1323
  });
1295
1324
  ;
1296
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1297
- ApplyScaleDirective.prototype.ngOnChanges = function (_changes) {
1298
- this.transform = "scaleX(" + this.scaleX + ") scaleY(" + this.scaleY + ")";
1299
- };
1300
1325
  return ApplyScaleDirective;
1301
1326
  }());
1302
1327
  ApplyScaleDirective.decorators = [
@@ -1309,10 +1334,7 @@
1309
1334
  ]; };
1310
1335
  ApplyScaleDirective.propDecorators = {
1311
1336
  scale: [{ type: i0.Input }],
1312
- scaleX: [{ type: i0.Input }],
1313
- scaleY: [{ type: i0.Input }],
1314
- transform: [{ type: i0.HostBinding, args: ['style.transform',] }],
1315
- transformOrigin: [{ type: i0.Input }, { type: i0.HostBinding, args: ['style.transformOrigin',] }]
1337
+ fontSize: [{ type: i0.HostBinding, args: ['style.fontSize',] }]
1316
1338
  };
1317
1339
 
1318
1340
  var EXPORTS = [
@@ -1329,11 +1351,22 @@
1329
1351
  var InteractModule = /** @class */ (function () {
1330
1352
  function InteractModule() {
1331
1353
  }
1354
+ InteractModule.forRoot = function (config) {
1355
+ var defaultConfig = { cssDimensionUnit: 'px' };
1356
+ return {
1357
+ ngModule: InteractModule,
1358
+ providers: [
1359
+ { provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
1360
+ InteractService
1361
+ ]
1362
+ };
1363
+ };
1332
1364
  return InteractModule;
1333
1365
  }());
1334
1366
  InteractModule.decorators = [
1335
1367
  { type: i0.NgModule, args: [{
1336
1368
  imports: [common.CommonModule],
1369
+ // providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
1337
1370
  declarations: __spreadArray([], __read(EXPORTS)),
1338
1371
  exports: __spreadArray([], __read(EXPORTS))
1339
1372
  },] }
@@ -1352,6 +1385,7 @@
1352
1385
  exports.DraggableDirective = DraggableDirective;
1353
1386
  exports.DropzoneDirective = DropzoneDirective;
1354
1387
  exports.GesturableDirective = GesturableDirective;
1388
+ exports.INTERACT_ROOT_CONFIG = INTERACT_ROOT_CONFIG;
1355
1389
  exports.InteractModule = InteractModule;
1356
1390
  exports.ResizableDirective = ResizableDirective;
1357
1391
  exports.TFT_DRAG_PREVIEW = TFT_DRAG_PREVIEW;