@tft/interact 12.4.3 → 12.5.3
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 +255 -120
- 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/account-for-scale.directive.ngfactory.js.map +1 -0
- 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/apply-scale.directive.ngfactory.js.map +1 -0
- package/esm2015/lib/directives/auto-scroll.directive.js +54 -0
- package/esm2015/lib/directives/auto-scroll.directive.js.map +1 -0
- package/esm2015/lib/directives/auto-scroll.directive.metadata.json +1 -0
- package/esm2015/lib/directives/auto-scroll.directive.ngfactory.js.map +1 -0
- package/esm2015/lib/directives/drag-preview.directive.ngfactory.js.map +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/drag-root.directive.ngfactory.js.map +1 -0
- package/esm2015/lib/directives/draggable.directive.js +45 -15
- package/esm2015/lib/directives/draggable.directive.js.map +1 -1
- package/esm2015/lib/directives/draggable.directive.metadata.json +1 -1
- package/esm2015/lib/directives/draggable.directive.ngfactory.js.map +1 -0
- package/esm2015/lib/directives/dropzone.directive.js +9 -6
- package/esm2015/lib/directives/dropzone.directive.js.map +1 -1
- package/esm2015/lib/directives/dropzone.directive.metadata.json +1 -1
- package/esm2015/lib/directives/dropzone.directive.ngfactory.js.map +1 -0
- package/esm2015/lib/directives/gesturable.directive.ngfactory.js.map +1 -0
- 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 +62 -13
- package/esm2015/lib/directives/resizable.directive.js.map +1 -1
- package/esm2015/lib/directives/resizable.directive.metadata.json +1 -1
- package/esm2015/lib/directives/resizable.directive.ngfactory.js.map +1 -0
- 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/interact.module.ngfactory.js.map +1 -0
- 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/pipes/array-of-n.pipe.ngfactory.js.map +1 -0
- 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/esm2015/lib/services/interact.service.ngfactory.js.map +1 -0
- 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 +223 -105
- 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/auto-scroll.directive.d.ts +31 -0
- package/lib/directives/drag-root.directive.d.ts +2 -1
- package/lib/directives/draggable.directive.d.ts +8 -2
- package/lib/directives/dropzone.directive.d.ts +7 -4
- package/lib/directives/index.d.ts +1 -0
- package/lib/directives/resizable.directive.d.ts +10 -3
- 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.3.tgz +0 -0
- package/tft-interact.d.ts +2 -2
- package/tft-interact.metadata.json +1 -1
- package/tft-interact-12.4.3.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 () {
|
|
@@ -643,12 +626,21 @@
|
|
|
643
626
|
this.interactService = interactService;
|
|
644
627
|
this.account_for_scale_dir = account_for_scale_dir;
|
|
645
628
|
this.dropzoneConfig = {};
|
|
629
|
+
this.position = 'relative';
|
|
646
630
|
// proxies to pass interact events through to consumer of directive
|
|
647
631
|
this.dropActivate = new i0.EventEmitter();
|
|
648
632
|
this.dragEnter = new i0.EventEmitter();
|
|
649
633
|
this.dragLeave = new i0.EventEmitter();
|
|
650
634
|
this.dragDrop = new i0.EventEmitter();
|
|
651
635
|
}
|
|
636
|
+
Object.defineProperty(DropzoneDirective.prototype, "scale", {
|
|
637
|
+
get: function () {
|
|
638
|
+
var _a;
|
|
639
|
+
return (_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale;
|
|
640
|
+
},
|
|
641
|
+
enumerable: false,
|
|
642
|
+
configurable: true
|
|
643
|
+
});
|
|
652
644
|
DropzoneDirective.prototype.ngOnInit = function () {
|
|
653
645
|
// connects
|
|
654
646
|
this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig);
|
|
@@ -695,10 +687,7 @@
|
|
|
695
687
|
var _a, _b;
|
|
696
688
|
var zoneElement = event.target;
|
|
697
689
|
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;
|
|
690
|
+
var scale = this.scale;
|
|
702
691
|
var positionInDropTarget = zoneElement && dragElement
|
|
703
692
|
? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
|
|
704
693
|
: null;
|
|
@@ -716,7 +705,7 @@
|
|
|
716
705
|
{ type: i0.Directive, args: [{
|
|
717
706
|
selector: '[tftDropzone]',
|
|
718
707
|
host: {
|
|
719
|
-
'[id]': 'dropzoneId'
|
|
708
|
+
'[id]': 'dropzoneId'
|
|
720
709
|
}
|
|
721
710
|
},] }
|
|
722
711
|
];
|
|
@@ -730,6 +719,7 @@
|
|
|
730
719
|
dropzoneId: [{ type: i0.Input }],
|
|
731
720
|
dropzoneConfig: [{ type: i0.Input }],
|
|
732
721
|
dropzoneData: [{ type: i0.Input }],
|
|
722
|
+
position: [{ type: i0.Input }, { type: i0.HostBinding, args: ['style.position',] }],
|
|
733
723
|
dropActivate: [{ type: i0.Output }],
|
|
734
724
|
dragEnter: [{ type: i0.Output }],
|
|
735
725
|
dragLeave: [{ type: i0.Output }],
|
|
@@ -797,22 +787,19 @@
|
|
|
797
787
|
* @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
|
|
798
788
|
*/
|
|
799
789
|
var DragRootDirective = /** @class */ (function () {
|
|
800
|
-
function DragRootDirective(el,
|
|
790
|
+
function DragRootDirective(el,
|
|
791
|
+
// This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
|
|
792
|
+
// 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
|
|
793
|
+
account_for_scale_dir) {
|
|
801
794
|
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
|
-
}
|
|
795
|
+
this.account_for_scale_dir = account_for_scale_dir;
|
|
810
796
|
}
|
|
811
797
|
return DragRootDirective;
|
|
812
798
|
}());
|
|
813
799
|
DragRootDirective.decorators = [
|
|
814
800
|
{ type: i0.Directive, args: [{
|
|
815
|
-
selector: '[tftDragRoot]'
|
|
801
|
+
selector: '[tftDragRoot]',
|
|
802
|
+
exportAs: 'tftDragRoot'
|
|
816
803
|
},] }
|
|
817
804
|
];
|
|
818
805
|
DragRootDirective.ctorParameters = function () { return [
|
|
@@ -820,11 +807,63 @@
|
|
|
820
807
|
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }, { type: i0.Self }] }
|
|
821
808
|
]; };
|
|
822
809
|
|
|
810
|
+
;
|
|
811
|
+
/**
|
|
812
|
+
* Use to apply scale to the element and tell the drag and resize directives to account for the scale when
|
|
813
|
+
* @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
|
|
814
|
+
* @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
|
|
815
|
+
* element accounts for scale
|
|
816
|
+
*/
|
|
817
|
+
var AutoScrollDirective = /** @class */ (function () {
|
|
818
|
+
function AutoScrollDirective(el) {
|
|
819
|
+
var _this = this;
|
|
820
|
+
this.el = el;
|
|
821
|
+
/**
|
|
822
|
+
* Limit minimum time between scroll events in milliseconds
|
|
823
|
+
*/
|
|
824
|
+
this.autoScrollConfig = {
|
|
825
|
+
margin: 50,
|
|
826
|
+
distance: 3,
|
|
827
|
+
interval: 50,
|
|
828
|
+
speed: 300,
|
|
829
|
+
enabled: true
|
|
830
|
+
};
|
|
831
|
+
this.scrollDeltaObserver = new rxjs.Subject();
|
|
832
|
+
var _a = el.nativeElement, scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
|
|
833
|
+
this.scrollSubject = new rxjs.BehaviorSubject({ scrollTop: scrollTop, scrollLeft: scrollLeft });
|
|
834
|
+
this.scrollObserver = this.scrollSubject.pipe(operators.scan(function (previous, current) {
|
|
835
|
+
var scrollTop = current.scrollTop - previous.scrollTop;
|
|
836
|
+
var scrollLeft = current.scrollLeft - previous.scrollLeft;
|
|
837
|
+
_this.scrollDeltaObserver.next({ scrollTop: scrollTop, scrollLeft: scrollLeft });
|
|
838
|
+
return current;
|
|
839
|
+
}), operators.shareReplay(1));
|
|
840
|
+
this.scrollObserver.subscribe();
|
|
841
|
+
}
|
|
842
|
+
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
843
|
+
AutoScrollDirective.prototype.scroll = function (scrollEvent) {
|
|
844
|
+
var target = scrollEvent.target;
|
|
845
|
+
var scrollTop = target.scrollTop, scrollLeft = target.scrollLeft;
|
|
846
|
+
this.scrollSubject.next({ scrollTop: scrollTop, scrollLeft: scrollLeft });
|
|
847
|
+
};
|
|
848
|
+
return AutoScrollDirective;
|
|
849
|
+
}());
|
|
850
|
+
AutoScrollDirective.decorators = [
|
|
851
|
+
{ type: i0.Directive, args: [{
|
|
852
|
+
selector: '[tftAutoScroll]'
|
|
853
|
+
},] }
|
|
854
|
+
];
|
|
855
|
+
AutoScrollDirective.ctorParameters = function () { return [
|
|
856
|
+
{ type: i0.ElementRef }
|
|
857
|
+
]; };
|
|
858
|
+
AutoScrollDirective.propDecorators = {
|
|
859
|
+
autoScrollConfig: [{ type: i0.Input }],
|
|
860
|
+
scroll: [{ type: i0.HostListener, args: ['scroll', ['$event'],] }]
|
|
861
|
+
};
|
|
862
|
+
|
|
823
863
|
/** @dynamic */
|
|
824
864
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
825
865
|
var DraggableDirective = /** @class */ (function () {
|
|
826
|
-
|
|
827
|
-
function DraggableDirective(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
|
|
866
|
+
function DraggableDirective(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir, auto_scroll_dir) {
|
|
828
867
|
this.el = el;
|
|
829
868
|
this.interactService = interactService;
|
|
830
869
|
this.renderer = renderer;
|
|
@@ -833,6 +872,7 @@
|
|
|
833
872
|
this.account_for_scale_dir = account_for_scale_dir;
|
|
834
873
|
this.dropzone_dir = dropzone_dir;
|
|
835
874
|
this.drag_root_dir = drag_root_dir;
|
|
875
|
+
this.auto_scroll_dir = auto_scroll_dir;
|
|
836
876
|
/* zIndex while dragging*/
|
|
837
877
|
this.dragZIndex = 10000;
|
|
838
878
|
this.enableDragDefault = true;
|
|
@@ -848,14 +888,23 @@
|
|
|
848
888
|
this.dragInertiaStart = new i0.EventEmitter();
|
|
849
889
|
this.dragEnd = new i0.EventEmitter();
|
|
850
890
|
}
|
|
891
|
+
Object.defineProperty(DraggableDirective.prototype, "scale", {
|
|
892
|
+
// check all the different places for scale
|
|
893
|
+
get: function () {
|
|
894
|
+
var _a, _b, _c, _d;
|
|
895
|
+
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);
|
|
896
|
+
},
|
|
897
|
+
enumerable: false,
|
|
898
|
+
configurable: true
|
|
899
|
+
});
|
|
851
900
|
DraggableDirective.prototype.ngOnInit = function () {
|
|
852
901
|
var _this = this;
|
|
853
|
-
var _a, _b, _c;
|
|
902
|
+
var _a, _b, _c, _d, _e;
|
|
854
903
|
this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
|
|
855
|
-
this.
|
|
904
|
+
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
905
|
// register with parent dropzone if it exists, otherwise use default
|
|
857
906
|
// this gives us a place on the registry to store our drag items that don't have a dropzone
|
|
858
|
-
this.registryId = ((
|
|
907
|
+
this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
859
908
|
// add draggable to directory and store its id
|
|
860
909
|
this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
861
910
|
this.alignPositionWithInputs(this.x, this.y);
|
|
@@ -906,12 +955,15 @@
|
|
|
906
955
|
};
|
|
907
956
|
DraggableDirective.prototype.dragMoveListener = function (event, element) {
|
|
908
957
|
var dx = event.dx, dy = event.dy;
|
|
909
|
-
|
|
958
|
+
var scale = this.scale;
|
|
959
|
+
var deltaX = scale ? dx / scale : dx;
|
|
960
|
+
var deltaY = scale ? dy / scale : dy;
|
|
961
|
+
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY }, element);
|
|
910
962
|
};
|
|
911
963
|
DraggableDirective.prototype.setDragStyles = function (dragElement) {
|
|
912
964
|
this.renderer.setStyle(dragElement, 'touchAction', 'none');
|
|
913
965
|
this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
|
|
914
|
-
this.renderer.setStyle(dragElement, 'position', '
|
|
966
|
+
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
915
967
|
};
|
|
916
968
|
DraggableDirective.prototype.addDragPropertiesToElement = function (nativeElement) {
|
|
917
969
|
this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
|
|
@@ -922,8 +974,9 @@
|
|
|
922
974
|
var _a;
|
|
923
975
|
var target = event.target, dropzone = event.dropzone;
|
|
924
976
|
var dropzoneElement = (dropzone === null || dropzone === void 0 ? void 0 : dropzone.target) || ((_a = target.dropTarget) === null || _a === void 0 ? void 0 : _a.el.nativeElement);
|
|
977
|
+
var scale = this.scale;
|
|
925
978
|
var positionInDropTarget = target && dropzoneElement
|
|
926
|
-
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef)
|
|
979
|
+
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
|
|
927
980
|
: null;
|
|
928
981
|
return {
|
|
929
982
|
interactEvent: event,
|
|
@@ -952,8 +1005,12 @@
|
|
|
952
1005
|
};
|
|
953
1006
|
DraggableDirective.prototype.initiateDragEvents = function (dragConfig, nativeElement) {
|
|
954
1007
|
var _this = this;
|
|
955
|
-
|
|
1008
|
+
var defaultDragConfig = Object.assign(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }), (this.auto_scroll_dir && {
|
|
1009
|
+
autoScroll: Object.assign(Object.assign({}, this.auto_scroll_dir.autoScrollConfig), { container: this.auto_scroll_dir.el.nativeElement })
|
|
1010
|
+
}));
|
|
1011
|
+
return interact__default['default'](nativeElement).draggable(defaultDragConfig)
|
|
956
1012
|
.on('dragstart', function (event) {
|
|
1013
|
+
var _a, _b, _c;
|
|
957
1014
|
var interaction = event.interaction;
|
|
958
1015
|
// check if we should append drag element to body
|
|
959
1016
|
if (_this.enableDragDefault
|
|
@@ -971,13 +1028,18 @@
|
|
|
971
1028
|
}
|
|
972
1029
|
_this.addDragPropertiesToElement(_this.previewRef);
|
|
973
1030
|
_this.setDragStyles(_this.previewRef);
|
|
974
|
-
_this.
|
|
975
|
-
var
|
|
1031
|
+
_this.dragRootEl.prepend(_this.previewRef);
|
|
1032
|
+
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;
|
|
1033
|
+
var _f = _this.interactService.calculatePositionInElement(_this.dragRootEl, nativeElement, scale), x = _f.x, y = _f.y;
|
|
976
1034
|
_this.interactService.updatePosition(_this.interactableId, _this.registryId, { x: x, y: y }, _this.previewRef);
|
|
977
1035
|
if (!_this.showPlaceholder) {
|
|
978
1036
|
_this.renderer.setStyle(_this.el.nativeElement, 'display', 'none');
|
|
979
1037
|
}
|
|
980
1038
|
}
|
|
1039
|
+
// subscribe to scroll events if they are there, by only subscribing on dragstart we avoid wasting subscriptions on interactables that aren't be dragged
|
|
1040
|
+
if (_this.auto_scroll_dir) {
|
|
1041
|
+
_this.subscribeToScrollEvents();
|
|
1042
|
+
}
|
|
981
1043
|
_this.dragStart.emit(_this.mapDragEvent(event));
|
|
982
1044
|
})
|
|
983
1045
|
.on('dragmove', function (event) {
|
|
@@ -994,20 +1056,32 @@
|
|
|
994
1056
|
.on('dragend', function (event) {
|
|
995
1057
|
var mappedEvent = _this.mapDragEvent(event);
|
|
996
1058
|
if (!!_this.dropzone_dir && _this.dropzone_dir === event.target.dropTarget) {
|
|
997
|
-
var
|
|
1059
|
+
var _f = mappedEvent.positionInDropTarget, x = _f.x, y = _f.y;
|
|
998
1060
|
_this.setPosition(x, y);
|
|
999
1061
|
}
|
|
1000
1062
|
_this.renderer.setStyle(_this.el.nativeElement, 'display', '');
|
|
1001
1063
|
_this.dragEnd.emit(mappedEvent);
|
|
1064
|
+
// unsubscribe from scroll events if subscribed
|
|
1065
|
+
if (_this.auto_scroll_dir) {
|
|
1066
|
+
_this.scrollEventsSubscription.unsubscribe();
|
|
1067
|
+
}
|
|
1002
1068
|
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
|
|
1069
|
+
// we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
|
|
1005
1070
|
setTimeout(function () {
|
|
1006
|
-
_this.
|
|
1071
|
+
_this.dragRootEl.removeChild(_this.previewRef);
|
|
1007
1072
|
});
|
|
1008
1073
|
}
|
|
1009
1074
|
});
|
|
1010
1075
|
};
|
|
1076
|
+
DraggableDirective.prototype.subscribeToScrollEvents = function () {
|
|
1077
|
+
var _this = this;
|
|
1078
|
+
this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(function (_f) {
|
|
1079
|
+
var scrollLeft = _f.scrollLeft, scrollTop = _f.scrollTop;
|
|
1080
|
+
var deltaX = _this.scale ? scrollLeft / _this.scale : scrollLeft;
|
|
1081
|
+
var deltaY = _this.scale ? scrollTop / _this.scale : scrollTop;
|
|
1082
|
+
_this.interactService.updateDeltas(_this.interactableId, _this.registryId, { deltaX: deltaX, deltaY: deltaY }, _this.previewRef);
|
|
1083
|
+
});
|
|
1084
|
+
};
|
|
1011
1085
|
return DraggableDirective;
|
|
1012
1086
|
}());
|
|
1013
1087
|
DraggableDirective.decorators = [
|
|
@@ -1029,7 +1103,8 @@
|
|
|
1029
1103
|
{ type: Document, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] },
|
|
1030
1104
|
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] },
|
|
1031
1105
|
{ type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
|
|
1032
|
-
{ type: DragRootDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
|
|
1106
|
+
{ type: DragRootDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
|
|
1107
|
+
{ type: AutoScrollDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
|
|
1033
1108
|
]; };
|
|
1034
1109
|
DraggableDirective.propDecorators = {
|
|
1035
1110
|
x: [{ type: i0.Input }],
|
|
@@ -1071,15 +1146,17 @@
|
|
|
1071
1146
|
|
|
1072
1147
|
/** @dynamic */
|
|
1073
1148
|
var ResizableDirective = /** @class */ (function () {
|
|
1074
|
-
function ResizableDirective(el, _document, interactService, renderer, drag_root_dir, account_for_scale_dir, draggable_dir, dropzone_dir) {
|
|
1149
|
+
function ResizableDirective(el, _document, interactService, renderer, drag_root_dir, account_for_scale_dir, draggable_dir, dropzone_dir, auto_scroll_dir) {
|
|
1075
1150
|
var _a;
|
|
1076
1151
|
this.el = el;
|
|
1077
1152
|
this._document = _document;
|
|
1078
1153
|
this.interactService = interactService;
|
|
1079
1154
|
this.renderer = renderer;
|
|
1155
|
+
this.drag_root_dir = drag_root_dir;
|
|
1080
1156
|
this.account_for_scale_dir = account_for_scale_dir;
|
|
1081
1157
|
this.draggable_dir = draggable_dir;
|
|
1082
1158
|
this.dropzone_dir = dropzone_dir;
|
|
1159
|
+
this.auto_scroll_dir = auto_scroll_dir;
|
|
1083
1160
|
this.enableResizeDefault = true;
|
|
1084
1161
|
// TODO: should this be an input with default or should consuming user set display in styles each time
|
|
1085
1162
|
this.position = 'absolute';
|
|
@@ -1091,8 +1168,17 @@
|
|
|
1091
1168
|
this.defaultConfig = {
|
|
1092
1169
|
edges: { left: true, right: true, bottom: true, top: true }
|
|
1093
1170
|
};
|
|
1094
|
-
this.
|
|
1171
|
+
this.activeEdges = { left: false, right: false, top: false, bottom: false };
|
|
1172
|
+
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
1173
|
}
|
|
1174
|
+
Object.defineProperty(ResizableDirective.prototype, "scale", {
|
|
1175
|
+
get: function () {
|
|
1176
|
+
var _a, _b, _c;
|
|
1177
|
+
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);
|
|
1178
|
+
},
|
|
1179
|
+
enumerable: false,
|
|
1180
|
+
configurable: true
|
|
1181
|
+
});
|
|
1096
1182
|
ResizableDirective.prototype.ngOnInit = function () {
|
|
1097
1183
|
var _a, _b;
|
|
1098
1184
|
this.addResizePropertiesToElement(this.el.nativeElement);
|
|
@@ -1120,9 +1206,16 @@
|
|
|
1120
1206
|
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
1121
1207
|
};
|
|
1122
1208
|
ResizableDirective.prototype.resizeListener = function (event) {
|
|
1123
|
-
var
|
|
1124
|
-
var
|
|
1125
|
-
var
|
|
1209
|
+
var element = this.el.nativeElement;
|
|
1210
|
+
var scale = this.scale;
|
|
1211
|
+
var deltaRect = event.deltaRect;
|
|
1212
|
+
var deltaX = deltaRect.left / scale;
|
|
1213
|
+
var deltaY = deltaRect.top / scale;
|
|
1214
|
+
// We get the width and height directly from the native element because
|
|
1215
|
+
// the event dimension can get out of sync when resizing with autoScroll
|
|
1216
|
+
var rect = element.getBoundingClientRect();
|
|
1217
|
+
var width = (rect.width + deltaRect.width) / scale;
|
|
1218
|
+
var height = (rect.height + deltaRect.height) / scale;
|
|
1126
1219
|
this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY, width: width, height: height }, this.el.nativeElement);
|
|
1127
1220
|
};
|
|
1128
1221
|
/**
|
|
@@ -1136,9 +1229,18 @@
|
|
|
1136
1229
|
var _this = this;
|
|
1137
1230
|
var _a;
|
|
1138
1231
|
// TODO: This should try and get interactable from tft_draggable if it exists
|
|
1232
|
+
var defaultResizeConfig = Object.assign(Object.assign(Object.assign({}, resizeConfig), { enabled: !this.resizeDisabled }), (this.auto_scroll_dir && {
|
|
1233
|
+
autoScroll: Object.assign(Object.assign({}, this.auto_scroll_dir.autoScrollConfig), { container: this.auto_scroll_dir.el.nativeElement })
|
|
1234
|
+
}));
|
|
1139
1235
|
var interactable = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactable) || interact__default['default'](nativeElement);
|
|
1140
|
-
return interactable.resizable(
|
|
1141
|
-
.on('resizestart', function (event) {
|
|
1236
|
+
return interactable.resizable(defaultResizeConfig)
|
|
1237
|
+
.on('resizestart', function (event) {
|
|
1238
|
+
_this.activeEdges = event.edges;
|
|
1239
|
+
if (_this.auto_scroll_dir) {
|
|
1240
|
+
_this.subscribeToScrollEvents();
|
|
1241
|
+
}
|
|
1242
|
+
_this.resizeStart.emit(_this.mapResizeEvent(event));
|
|
1243
|
+
})
|
|
1142
1244
|
.on('resizemove', function (event) {
|
|
1143
1245
|
if (_this.enableResizeDefault) {
|
|
1144
1246
|
_this.resizeListener(event);
|
|
@@ -1147,23 +1249,33 @@
|
|
|
1147
1249
|
_this.resizeMove.emit(mappedEvent);
|
|
1148
1250
|
})
|
|
1149
1251
|
.on('resizeinertiastart', function (event) { return _this.resizeInertiaStart.emit(_this.mapResizeEvent(event)); })
|
|
1150
|
-
.on('resizeend', function (event) {
|
|
1252
|
+
.on('resizeend', function (event) {
|
|
1253
|
+
if (_this.auto_scroll_dir) {
|
|
1254
|
+
_this.scrollEventsSubscription.unsubscribe();
|
|
1255
|
+
}
|
|
1256
|
+
_this.activeEdges = { left: false, right: false, top: false, bottom: false };
|
|
1257
|
+
_this.resizeEnd.emit(_this.mapResizeEvent(event));
|
|
1258
|
+
});
|
|
1151
1259
|
};
|
|
1152
1260
|
ResizableDirective.prototype.mapResizeEvent = function (event) {
|
|
1153
1261
|
var _a, _b;
|
|
1154
|
-
var target =
|
|
1262
|
+
var target = this.el.nativeElement;
|
|
1155
1263
|
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;
|
|
1264
|
+
var scale = this.scale;
|
|
1156
1265
|
var positionInDropTarget = target && relatedTarget
|
|
1157
|
-
? this.interactService.calculatePositionInElement(relatedTarget, target)
|
|
1266
|
+
? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
|
|
1158
1267
|
: null;
|
|
1159
1268
|
return {
|
|
1160
1269
|
interactEvent: event,
|
|
1161
1270
|
resizeRef: this,
|
|
1162
|
-
// should I remove this?
|
|
1163
1271
|
dragRef: this.draggable_dir,
|
|
1164
1272
|
dragOrigin: this.dropzone_dir,
|
|
1165
1273
|
dropTarget: this.el.nativeElement.dropTarget,
|
|
1166
|
-
positionInDropTarget: positionInDropTarget
|
|
1274
|
+
positionInDropTarget: positionInDropTarget,
|
|
1275
|
+
size: {
|
|
1276
|
+
width: target.clientWidth / scale,
|
|
1277
|
+
height: target.clientHeight / scale
|
|
1278
|
+
}
|
|
1167
1279
|
};
|
|
1168
1280
|
};
|
|
1169
1281
|
ResizableDirective.prototype.alignDimensionsWithInputs = function (width, height) {
|
|
@@ -1172,6 +1284,22 @@
|
|
|
1172
1284
|
ResizableDirective.prototype.addResizePropertiesToElement = function (nativeElement) {
|
|
1173
1285
|
this.renderer.setProperty(nativeElement, 'resizeRef', this);
|
|
1174
1286
|
};
|
|
1287
|
+
ResizableDirective.prototype.subscribeToScrollEvents = function () {
|
|
1288
|
+
var _this = this;
|
|
1289
|
+
this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(function (_d) {
|
|
1290
|
+
var scrollLeft = _d.scrollLeft, scrollTop = _d.scrollTop;
|
|
1291
|
+
var scale = _this.scale;
|
|
1292
|
+
var target = _this.el.nativeElement;
|
|
1293
|
+
var _e = target.getBoundingClientRect(), prevWidth = _e.width, prevHeight = _e.height;
|
|
1294
|
+
var deltaHeight = scrollTop * (_this.activeEdges.top ? -1 : _this.activeEdges.bottom ? 1 : 0);
|
|
1295
|
+
var deltaWidth = scrollLeft * (_this.activeEdges.left ? -1 : _this.activeEdges.right ? 1 : 0);
|
|
1296
|
+
var height = (prevHeight + deltaHeight) / scale;
|
|
1297
|
+
var width = (prevWidth + deltaWidth) / scale;
|
|
1298
|
+
var deltaX = _this.activeEdges.left ? (scrollLeft / scale) : 0;
|
|
1299
|
+
var deltaY = _this.activeEdges.top ? (scrollTop / scale) : 0;
|
|
1300
|
+
_this.interactService.updateSize(_this.interactableId, _this.registryId, { deltaX: deltaX, deltaY: deltaY, width: width, height: height }, _this.el.nativeElement);
|
|
1301
|
+
});
|
|
1302
|
+
};
|
|
1175
1303
|
return ResizableDirective;
|
|
1176
1304
|
}());
|
|
1177
1305
|
ResizableDirective.decorators = [
|
|
@@ -1198,7 +1326,8 @@
|
|
|
1198
1326
|
{ type: DragRootDirective, decorators: [{ type: i0.Optional }] },
|
|
1199
1327
|
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] },
|
|
1200
1328
|
{ type: DraggableDirective, decorators: [{ type: i0.Optional }] },
|
|
1201
|
-
{ type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
|
|
1329
|
+
{ type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
|
|
1330
|
+
{ type: AutoScrollDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
|
|
1202
1331
|
]; };
|
|
1203
1332
|
ResizableDirective.propDecorators = {
|
|
1204
1333
|
enableResizeDefault: [{ type: i0.Input }],
|
|
@@ -1293,24 +1422,18 @@
|
|
|
1293
1422
|
var ApplyScaleDirective = /** @class */ (function () {
|
|
1294
1423
|
function ApplyScaleDirective(el) {
|
|
1295
1424
|
this.el = el;
|
|
1296
|
-
this.
|
|
1297
|
-
this.scaleY = 1;
|
|
1298
|
-
this.transformOrigin = '0 0';
|
|
1425
|
+
this._scale = 1;
|
|
1299
1426
|
}
|
|
1300
1427
|
Object.defineProperty(ApplyScaleDirective.prototype, "scale", {
|
|
1301
1428
|
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
1302
1429
|
set: function (val) {
|
|
1303
|
-
this.
|
|
1304
|
-
this.
|
|
1430
|
+
this._scale;
|
|
1431
|
+
this.fontSize = val + "px";
|
|
1305
1432
|
},
|
|
1306
1433
|
enumerable: false,
|
|
1307
1434
|
configurable: true
|
|
1308
1435
|
});
|
|
1309
1436
|
;
|
|
1310
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1311
|
-
ApplyScaleDirective.prototype.ngOnChanges = function (_changes) {
|
|
1312
|
-
this.transform = "scaleX(" + this.scaleX + ") scaleY(" + this.scaleY + ")";
|
|
1313
|
-
};
|
|
1314
1437
|
return ApplyScaleDirective;
|
|
1315
1438
|
}());
|
|
1316
1439
|
ApplyScaleDirective.decorators = [
|
|
@@ -1323,10 +1446,7 @@
|
|
|
1323
1446
|
]; };
|
|
1324
1447
|
ApplyScaleDirective.propDecorators = {
|
|
1325
1448
|
scale: [{ type: i0.Input }],
|
|
1326
|
-
|
|
1327
|
-
scaleY: [{ type: i0.Input }],
|
|
1328
|
-
transform: [{ type: i0.HostBinding, args: ['style.transform',] }],
|
|
1329
|
-
transformOrigin: [{ type: i0.Input }, { type: i0.HostBinding, args: ['style.transformOrigin',] }]
|
|
1449
|
+
fontSize: [{ type: i0.HostBinding, args: ['style.fontSize',] }]
|
|
1330
1450
|
};
|
|
1331
1451
|
|
|
1332
1452
|
var EXPORTS = [
|
|
@@ -1335,6 +1455,7 @@
|
|
|
1335
1455
|
DropzoneDirective,
|
|
1336
1456
|
GesturableDirective,
|
|
1337
1457
|
DragRootDirective,
|
|
1458
|
+
AutoScrollDirective,
|
|
1338
1459
|
AccountForScaleDirective,
|
|
1339
1460
|
ApplyScaleDirective,
|
|
1340
1461
|
DragPreviewDirective,
|
|
@@ -1343,11 +1464,22 @@
|
|
|
1343
1464
|
var InteractModule = /** @class */ (function () {
|
|
1344
1465
|
function InteractModule() {
|
|
1345
1466
|
}
|
|
1467
|
+
InteractModule.forRoot = function (config) {
|
|
1468
|
+
var defaultConfig = { cssDimensionUnit: 'px' };
|
|
1469
|
+
return {
|
|
1470
|
+
ngModule: InteractModule,
|
|
1471
|
+
providers: [
|
|
1472
|
+
{ provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
|
|
1473
|
+
InteractService
|
|
1474
|
+
]
|
|
1475
|
+
};
|
|
1476
|
+
};
|
|
1346
1477
|
return InteractModule;
|
|
1347
1478
|
}());
|
|
1348
1479
|
InteractModule.decorators = [
|
|
1349
1480
|
{ type: i0.NgModule, args: [{
|
|
1350
1481
|
imports: [common.CommonModule],
|
|
1482
|
+
// providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
|
|
1351
1483
|
declarations: __spreadArray([], __read(EXPORTS)),
|
|
1352
1484
|
exports: __spreadArray([], __read(EXPORTS))
|
|
1353
1485
|
},] }
|
|
@@ -1360,12 +1492,14 @@
|
|
|
1360
1492
|
exports.AccountForScaleDirective = AccountForScaleDirective;
|
|
1361
1493
|
exports.ApplyScaleDirective = ApplyScaleDirective;
|
|
1362
1494
|
exports.ArrayOfNPipe = ArrayOfNPipe;
|
|
1495
|
+
exports.AutoScrollDirective = AutoScrollDirective;
|
|
1363
1496
|
exports.DEFAULT_REGISTRY_ID = DEFAULT_REGISTRY_ID;
|
|
1364
1497
|
exports.DragPreviewDirective = DragPreviewDirective;
|
|
1365
1498
|
exports.DragRootDirective = DragRootDirective;
|
|
1366
1499
|
exports.DraggableDirective = DraggableDirective;
|
|
1367
1500
|
exports.DropzoneDirective = DropzoneDirective;
|
|
1368
1501
|
exports.GesturableDirective = GesturableDirective;
|
|
1502
|
+
exports.INTERACT_ROOT_CONFIG = INTERACT_ROOT_CONFIG;
|
|
1369
1503
|
exports.InteractModule = InteractModule;
|
|
1370
1504
|
exports.ResizableDirective = ResizableDirective;
|
|
1371
1505
|
exports.TFT_DRAG_PREVIEW = TFT_DRAG_PREVIEW;
|
|
@@ -1380,10 +1514,11 @@
|
|
|
1380
1514
|
exports.ɵc = DropzoneDirective;
|
|
1381
1515
|
exports.ɵd = GesturableDirective;
|
|
1382
1516
|
exports.ɵe = DragRootDirective;
|
|
1383
|
-
exports.ɵf =
|
|
1384
|
-
exports.ɵg =
|
|
1385
|
-
exports.ɵh =
|
|
1386
|
-
exports.ɵi =
|
|
1517
|
+
exports.ɵf = AutoScrollDirective;
|
|
1518
|
+
exports.ɵg = AccountForScaleDirective;
|
|
1519
|
+
exports.ɵh = ApplyScaleDirective;
|
|
1520
|
+
exports.ɵi = DragPreviewDirective;
|
|
1521
|
+
exports.ɵj = ArrayOfNPipe;
|
|
1387
1522
|
|
|
1388
1523
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1389
1524
|
|