@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
package/fesm2015/tft-interact.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Pipe, Injectable, RendererFactory2, NgZone, Directive, ElementRef, Input, EventEmitter, Renderer2,
|
|
2
|
+
import { Pipe, InjectionToken, Injectable, RendererFactory2, NgZone, Optional, Inject, Directive, ElementRef, Input, EventEmitter, Renderer2, Output, TemplateRef, Self, ViewContainerRef, SkipSelf, ContentChild, HostBinding, NgModule } from '@angular/core';
|
|
3
3
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
4
4
|
import interact from 'interactjs';
|
|
5
5
|
import { BehaviorSubject, combineLatest } from 'rxjs';
|
|
@@ -22,6 +22,7 @@ ArrayOfNPipe.decorators = [
|
|
|
22
22
|
},] }
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
+
const INTERACT_ROOT_CONFIG = new InjectionToken('INTERACT_ROOT_CONFIG_PARAMS');
|
|
25
26
|
const DEFAULT_REGISTRY_ID = 'DEFAULT';
|
|
26
27
|
/**
|
|
27
28
|
* Default initial value for Delta BehaviorSubject
|
|
@@ -49,14 +50,17 @@ const defaultPosition = {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
class InteractService {
|
|
52
|
-
constructor(rendererFactory, ngZone) {
|
|
53
|
+
constructor(rendererFactory, ngZone, rootConfig) {
|
|
53
54
|
this.rendererFactory = rendererFactory;
|
|
54
55
|
this.ngZone = ngZone;
|
|
56
|
+
this.rootConfig = rootConfig;
|
|
55
57
|
this._interactableIndex = 0;
|
|
56
58
|
this._dropzoneIndex = 0;
|
|
57
59
|
// TODO: consider using Map here
|
|
58
60
|
this.dragRegistrySystem = {};
|
|
61
|
+
this.cssUnit = 'px';
|
|
59
62
|
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
63
|
+
this.cssUnit = (rootConfig === null || rootConfig === void 0 ? void 0 : rootConfig.cssDimensionUnit) || 'px';
|
|
60
64
|
}
|
|
61
65
|
addDeltaToPosition(delta, position) {
|
|
62
66
|
return {
|
|
@@ -73,7 +77,7 @@ class InteractService {
|
|
|
73
77
|
addDraggableToRegistry(customRegistryId = null, interactableId = null) {
|
|
74
78
|
const registryId = customRegistryId || DEFAULT_REGISTRY_ID;
|
|
75
79
|
// if we pass an id to createInteractableId then it is used when creating the interactable
|
|
76
|
-
// and returned, otherwise a
|
|
80
|
+
// and returned, otherwise a new id is created for the draggable.
|
|
77
81
|
const key = this.createInteractableId(interactableId);
|
|
78
82
|
if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {
|
|
79
83
|
this.dragRegistrySystem[registryId] = {};
|
|
@@ -82,7 +86,16 @@ class InteractService {
|
|
|
82
86
|
return key;
|
|
83
87
|
}
|
|
84
88
|
destroyInteractable(interactableId, registryId = DEFAULT_REGISTRY_ID) {
|
|
85
|
-
|
|
89
|
+
const interactableSystem = this.dragRegistrySystem[registryId][interactableId];
|
|
90
|
+
if (interactableSystem) {
|
|
91
|
+
// unsubscribe from all the subscriptions if they're subscriptions
|
|
92
|
+
for (const propName in interactableSystem) {
|
|
93
|
+
const prop = interactableSystem[propName];
|
|
94
|
+
if (prop.unsubscribe && typeof prop.unsubscribe === 'function') {
|
|
95
|
+
prop.unsubscribe();
|
|
96
|
+
}
|
|
97
|
+
;
|
|
98
|
+
}
|
|
86
99
|
delete this.dragRegistrySystem[registryId][interactableId];
|
|
87
100
|
}
|
|
88
101
|
}
|
|
@@ -164,8 +177,8 @@ class InteractService {
|
|
|
164
177
|
this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX, deltaY, width, height, targetElement });
|
|
165
178
|
}
|
|
166
179
|
interactableExistOnRegistry(interactId, registryId = DEFAULT_REGISTRY_ID) {
|
|
167
|
-
|
|
168
|
-
|
|
180
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
181
|
+
return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
|
|
169
182
|
}
|
|
170
183
|
/**
|
|
171
184
|
* Uses renderer to set width and height of angular component
|
|
@@ -174,21 +187,10 @@ class InteractService {
|
|
|
174
187
|
* @param target the element to transform
|
|
175
188
|
*/
|
|
176
189
|
setElementSize(width, height, target) {
|
|
177
|
-
var _a;
|
|
178
190
|
if (!target)
|
|
179
191
|
return;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const { scaleX, scaleY } = accountForScaleDirective;
|
|
183
|
-
const scaledWidth = width / scaleX;
|
|
184
|
-
const scaledHeight = height / scaleY;
|
|
185
|
-
this.renderer.setStyle(target, 'width', `${scaledWidth}px`);
|
|
186
|
-
this.renderer.setStyle(target, 'height', `${scaledHeight}px`);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
this.renderer.setStyle(target, 'width', `${width}px`);
|
|
190
|
-
this.renderer.setStyle(target, 'height', `${height}px`);
|
|
191
|
-
}
|
|
192
|
+
this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);
|
|
193
|
+
this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);
|
|
192
194
|
}
|
|
193
195
|
/**
|
|
194
196
|
* Uses renderer to set position of angular component
|
|
@@ -197,19 +199,10 @@ class InteractService {
|
|
|
197
199
|
* @param target the element to transform
|
|
198
200
|
*/
|
|
199
201
|
setElementTransform(x, y, position) {
|
|
200
|
-
var _a, _b;
|
|
201
202
|
if (!(position === null || position === void 0 ? void 0 : position.targetElement))
|
|
202
203
|
return;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const { scaleX, scaleY } = accountForScaleDirective;
|
|
206
|
-
this.renderer.setStyle(position.targetElement, 'left', `${x / scaleX}px`);
|
|
207
|
-
this.renderer.setStyle(position.targetElement, 'top', `${y / scaleY}px`);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
this.renderer.setStyle(position.targetElement, 'left', `${x}px`);
|
|
211
|
-
this.renderer.setStyle(position.targetElement, 'top', `${y}px`);
|
|
212
|
-
}
|
|
204
|
+
this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);
|
|
205
|
+
this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);
|
|
213
206
|
}
|
|
214
207
|
/**
|
|
215
208
|
* Generates a translate string for the x and y arguments passed to
|
|
@@ -218,7 +211,7 @@ class InteractService {
|
|
|
218
211
|
* @param y the position along the y axis
|
|
219
212
|
*/
|
|
220
213
|
createTransformString(x, y) {
|
|
221
|
-
return `translate3d(${x}
|
|
214
|
+
return `translate3d(${x}${this.cssUnit}, ${y}${this.cssUnit}, 0)`;
|
|
222
215
|
}
|
|
223
216
|
calculatePositionInElement(zoneElement, dragElement, scale) {
|
|
224
217
|
// TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
|
|
@@ -226,22 +219,24 @@ class InteractService {
|
|
|
226
219
|
const dragRect = dragElement.getBoundingClientRect();
|
|
227
220
|
const position = scale
|
|
228
221
|
? {
|
|
229
|
-
x: (dragRect.left - zoneRect.left) / scale
|
|
230
|
-
y: (dragRect.top - zoneRect.top) / scale
|
|
222
|
+
x: (dragRect.left - zoneRect.left) / scale || 1,
|
|
223
|
+
y: (dragRect.top - zoneRect.top) / scale || 1
|
|
231
224
|
} : {
|
|
232
225
|
x: dragRect.left - zoneRect.left,
|
|
233
226
|
y: dragRect.top - zoneRect.top
|
|
234
227
|
};
|
|
228
|
+
// console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
|
|
235
229
|
return position;
|
|
236
230
|
}
|
|
237
231
|
}
|
|
238
|
-
InteractService.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.NgZone)); }, token: InteractService, providedIn: "root" });
|
|
232
|
+
InteractService.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(INTERACT_ROOT_CONFIG, 8)); }, token: InteractService, providedIn: "root" });
|
|
239
233
|
InteractService.decorators = [
|
|
240
234
|
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
241
235
|
];
|
|
242
236
|
InteractService.ctorParameters = () => [
|
|
243
237
|
{ type: RendererFactory2 },
|
|
244
|
-
{ type: NgZone }
|
|
238
|
+
{ type: NgZone },
|
|
239
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INTERACT_ROOT_CONFIG,] }] }
|
|
245
240
|
];
|
|
246
241
|
|
|
247
242
|
/**
|
|
@@ -253,15 +248,9 @@ InteractService.ctorParameters = () => [
|
|
|
253
248
|
class AccountForScaleDirective {
|
|
254
249
|
constructor(el) {
|
|
255
250
|
this.el = el;
|
|
256
|
-
this
|
|
257
|
-
this.
|
|
258
|
-
}
|
|
259
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
260
|
-
set scale(val) {
|
|
261
|
-
this.scaleY = val;
|
|
262
|
-
this.scaleX = val;
|
|
251
|
+
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
252
|
+
this.scale = 1;
|
|
263
253
|
}
|
|
264
|
-
;
|
|
265
254
|
}
|
|
266
255
|
AccountForScaleDirective.decorators = [
|
|
267
256
|
{ type: Directive, args: [{
|
|
@@ -272,9 +261,7 @@ AccountForScaleDirective.ctorParameters = () => [
|
|
|
272
261
|
{ type: ElementRef }
|
|
273
262
|
];
|
|
274
263
|
AccountForScaleDirective.propDecorators = {
|
|
275
|
-
scale: [{ type: Input }]
|
|
276
|
-
scaleX: [{ type: Input }],
|
|
277
|
-
scaleY: [{ type: Input }]
|
|
264
|
+
scale: [{ type: Input }]
|
|
278
265
|
};
|
|
279
266
|
|
|
280
267
|
class DropzoneDirective {
|
|
@@ -290,6 +277,10 @@ class DropzoneDirective {
|
|
|
290
277
|
this.dragLeave = new EventEmitter();
|
|
291
278
|
this.dragDrop = new EventEmitter();
|
|
292
279
|
}
|
|
280
|
+
get scale() {
|
|
281
|
+
var _a;
|
|
282
|
+
return (_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale;
|
|
283
|
+
}
|
|
293
284
|
ngOnInit() {
|
|
294
285
|
// connects
|
|
295
286
|
this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig);
|
|
@@ -335,10 +326,7 @@ class DropzoneDirective {
|
|
|
335
326
|
var _a, _b;
|
|
336
327
|
const zoneElement = event.target;
|
|
337
328
|
const dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
|
|
338
|
-
const scale = this.
|
|
339
|
-
x: this.account_for_scale_dir.scaleX,
|
|
340
|
-
y: this.account_for_scale_dir.scaleY
|
|
341
|
-
} : null;
|
|
329
|
+
const scale = this.scale;
|
|
342
330
|
const positionInDropTarget = zoneElement && dragElement
|
|
343
331
|
? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
|
|
344
332
|
: null;
|
|
@@ -435,21 +423,18 @@ function getRootNode(viewRef, _document) {
|
|
|
435
423
|
* @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
|
|
436
424
|
*/
|
|
437
425
|
class DragRootDirective {
|
|
438
|
-
constructor(el,
|
|
426
|
+
constructor(el,
|
|
427
|
+
// This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
|
|
428
|
+
// 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
|
|
429
|
+
account_for_scale_dir) {
|
|
439
430
|
this.el = el;
|
|
440
|
-
|
|
441
|
-
// with a dropzone inside of it and a drag item inside the dropzone
|
|
442
|
-
// e.g <div tftDragRoot> <div tftDropzone> <div tftDraggable</div> </div> </div>
|
|
443
|
-
// TODO: This is a band-aid, root cause in misunderstood, it started after switching from
|
|
444
|
-
// using `translate3d` to top/left for positioning
|
|
445
|
-
if (!account_for_scale_dir) {
|
|
446
|
-
el.nativeElement.style.transform = 'scale(1)';
|
|
447
|
-
}
|
|
431
|
+
this.account_for_scale_dir = account_for_scale_dir;
|
|
448
432
|
}
|
|
449
433
|
}
|
|
450
434
|
DragRootDirective.decorators = [
|
|
451
435
|
{ type: Directive, args: [{
|
|
452
|
-
selector: '[tftDragRoot]'
|
|
436
|
+
selector: '[tftDragRoot]',
|
|
437
|
+
exportAs: 'tftDragRoot'
|
|
453
438
|
},] }
|
|
454
439
|
];
|
|
455
440
|
DragRootDirective.ctorParameters = () => [
|
|
@@ -460,7 +445,6 @@ DragRootDirective.ctorParameters = () => [
|
|
|
460
445
|
/** @dynamic */
|
|
461
446
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
462
447
|
class DraggableDirective {
|
|
463
|
-
// cache holding element to use as placeholder while dragging
|
|
464
448
|
constructor(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
|
|
465
449
|
this.el = el;
|
|
466
450
|
this.interactService = interactService;
|
|
@@ -485,13 +469,18 @@ class DraggableDirective {
|
|
|
485
469
|
this.dragInertiaStart = new EventEmitter();
|
|
486
470
|
this.dragEnd = new EventEmitter();
|
|
487
471
|
}
|
|
472
|
+
// check all the different places for scale
|
|
473
|
+
get scale() {
|
|
474
|
+
var _a, _b, _c, _d;
|
|
475
|
+
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);
|
|
476
|
+
}
|
|
488
477
|
ngOnInit() {
|
|
489
|
-
var _a, _b, _c;
|
|
478
|
+
var _a, _b, _c, _d, _e;
|
|
490
479
|
this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
|
|
491
|
-
this.
|
|
480
|
+
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;
|
|
492
481
|
// register with parent dropzone if it exists, otherwise use default
|
|
493
482
|
// this gives us a place on the registry to store our drag items that don't have a dropzone
|
|
494
|
-
this.registryId = ((
|
|
483
|
+
this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
495
484
|
// add draggable to directory and store its id
|
|
496
485
|
this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
497
486
|
this.alignPositionWithInputs(this.x, this.y);
|
|
@@ -542,12 +531,15 @@ class DraggableDirective {
|
|
|
542
531
|
}
|
|
543
532
|
dragMoveListener(event, element) {
|
|
544
533
|
const { dx, dy } = event;
|
|
545
|
-
|
|
534
|
+
const scale = this.scale;
|
|
535
|
+
const deltaX = scale ? dx / scale : dx;
|
|
536
|
+
const deltaY = scale ? dy / scale : dy;
|
|
537
|
+
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX, deltaY }, element);
|
|
546
538
|
}
|
|
547
539
|
setDragStyles(dragElement) {
|
|
548
540
|
this.renderer.setStyle(dragElement, 'touchAction', 'none');
|
|
549
541
|
this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
|
|
550
|
-
this.renderer.setStyle(dragElement, 'position', '
|
|
542
|
+
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
551
543
|
}
|
|
552
544
|
addDragPropertiesToElement(nativeElement) {
|
|
553
545
|
this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
|
|
@@ -558,8 +550,9 @@ class DraggableDirective {
|
|
|
558
550
|
var _a;
|
|
559
551
|
const { target, dropzone } = event;
|
|
560
552
|
const dropzoneElement = (dropzone === null || dropzone === void 0 ? void 0 : dropzone.target) || ((_a = target.dropTarget) === null || _a === void 0 ? void 0 : _a.el.nativeElement);
|
|
553
|
+
const scale = this.scale;
|
|
561
554
|
const positionInDropTarget = target && dropzoneElement
|
|
562
|
-
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef)
|
|
555
|
+
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
|
|
563
556
|
: null;
|
|
564
557
|
return {
|
|
565
558
|
interactEvent: event,
|
|
@@ -589,6 +582,7 @@ class DraggableDirective {
|
|
|
589
582
|
initiateDragEvents(dragConfig, nativeElement) {
|
|
590
583
|
return interact(nativeElement).draggable(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }))
|
|
591
584
|
.on('dragstart', (event) => {
|
|
585
|
+
var _a, _b, _c;
|
|
592
586
|
const interaction = event.interaction;
|
|
593
587
|
// check if we should append drag element to body
|
|
594
588
|
if (this.enableDragDefault
|
|
@@ -606,8 +600,9 @@ class DraggableDirective {
|
|
|
606
600
|
}
|
|
607
601
|
this.addDragPropertiesToElement(this.previewRef);
|
|
608
602
|
this.setDragStyles(this.previewRef);
|
|
609
|
-
this.
|
|
610
|
-
const
|
|
603
|
+
this.dragRootEl.prepend(this.previewRef);
|
|
604
|
+
const 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;
|
|
605
|
+
const { x, y } = this.interactService.calculatePositionInElement(this.dragRootEl, nativeElement, scale);
|
|
611
606
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.previewRef);
|
|
612
607
|
if (!this.showPlaceholder) {
|
|
613
608
|
this.renderer.setStyle(this.el.nativeElement, 'display', 'none');
|
|
@@ -635,10 +630,9 @@ class DraggableDirective {
|
|
|
635
630
|
this.renderer.setStyle(this.el.nativeElement, 'display', '');
|
|
636
631
|
this.dragEnd.emit(mappedEvent);
|
|
637
632
|
if (this.el.nativeElement !== this.previewRef) {
|
|
638
|
-
// we do this in a timeout, so that we don't
|
|
639
|
-
// remove before the dropzone can get the boundingElementRect
|
|
633
|
+
// we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
|
|
640
634
|
setTimeout(() => {
|
|
641
|
-
this.
|
|
635
|
+
this.dragRootEl.removeChild(this.previewRef);
|
|
642
636
|
});
|
|
643
637
|
}
|
|
644
638
|
});
|
|
@@ -711,6 +705,7 @@ class ResizableDirective {
|
|
|
711
705
|
this._document = _document;
|
|
712
706
|
this.interactService = interactService;
|
|
713
707
|
this.renderer = renderer;
|
|
708
|
+
this.drag_root_dir = drag_root_dir;
|
|
714
709
|
this.account_for_scale_dir = account_for_scale_dir;
|
|
715
710
|
this.draggable_dir = draggable_dir;
|
|
716
711
|
this.dropzone_dir = dropzone_dir;
|
|
@@ -725,7 +720,11 @@ class ResizableDirective {
|
|
|
725
720
|
this.defaultConfig = {
|
|
726
721
|
edges: { left: true, right: true, bottom: true, top: true }
|
|
727
722
|
};
|
|
728
|
-
this.
|
|
723
|
+
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;
|
|
724
|
+
}
|
|
725
|
+
get scale() {
|
|
726
|
+
var _a, _b, _c;
|
|
727
|
+
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);
|
|
729
728
|
}
|
|
730
729
|
ngOnInit() {
|
|
731
730
|
var _a, _b;
|
|
@@ -754,9 +753,23 @@ class ResizableDirective {
|
|
|
754
753
|
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
755
754
|
}
|
|
756
755
|
resizeListener(event) {
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
|
|
756
|
+
const scale = this.scale;
|
|
757
|
+
let deltaX;
|
|
758
|
+
let deltaY;
|
|
759
|
+
let height;
|
|
760
|
+
let width;
|
|
761
|
+
if (scale) {
|
|
762
|
+
deltaX = event.deltaRect.left / scale;
|
|
763
|
+
deltaY = event.deltaRect.top / scale;
|
|
764
|
+
height = event.rect.height / scale;
|
|
765
|
+
width = event.rect.width / scale;
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
deltaX = event.deltaRect.left;
|
|
769
|
+
deltaY = event.deltaRect.top;
|
|
770
|
+
width = event.rect.width;
|
|
771
|
+
height = event.rect.height;
|
|
772
|
+
}
|
|
760
773
|
this.interactService.updateSize(this.interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
|
|
761
774
|
}
|
|
762
775
|
/**
|
|
@@ -786,21 +799,21 @@ class ResizableDirective {
|
|
|
786
799
|
var _a, _b;
|
|
787
800
|
const target = event.target;
|
|
788
801
|
const relatedTarget = (_b = (_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.dropzone_dir) === null || _b === void 0 ? void 0 : _b.el.nativeElement;
|
|
789
|
-
const scale = this.
|
|
790
|
-
x: this.account_for_scale_dir.scaleX,
|
|
791
|
-
y: this.account_for_scale_dir.scaleY
|
|
792
|
-
} : null;
|
|
802
|
+
const scale = this.scale;
|
|
793
803
|
const positionInDropTarget = target && relatedTarget
|
|
794
804
|
? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
|
|
795
805
|
: null;
|
|
796
806
|
return {
|
|
797
807
|
interactEvent: event,
|
|
798
808
|
resizeRef: this,
|
|
799
|
-
// should I remove this?
|
|
800
809
|
dragRef: this.draggable_dir,
|
|
801
810
|
dragOrigin: this.dropzone_dir,
|
|
802
811
|
dropTarget: this.el.nativeElement.dropTarget,
|
|
803
|
-
positionInDropTarget
|
|
812
|
+
positionInDropTarget,
|
|
813
|
+
size: {
|
|
814
|
+
width: target.clientWidth / scale,
|
|
815
|
+
height: target.clientHeight / scale
|
|
816
|
+
}
|
|
804
817
|
};
|
|
805
818
|
}
|
|
806
819
|
alignDimensionsWithInputs(width, height) {
|
|
@@ -927,20 +940,14 @@ GesturableDirective.propDecorators = {
|
|
|
927
940
|
class ApplyScaleDirective {
|
|
928
941
|
constructor(el) {
|
|
929
942
|
this.el = el;
|
|
930
|
-
this.
|
|
931
|
-
this.scaleY = 1;
|
|
932
|
-
this.transformOrigin = '0 0';
|
|
943
|
+
this._scale = 1;
|
|
933
944
|
}
|
|
934
945
|
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
935
946
|
set scale(val) {
|
|
936
|
-
this.
|
|
937
|
-
this.
|
|
947
|
+
this._scale;
|
|
948
|
+
this.fontSize = `${val}px`;
|
|
938
949
|
}
|
|
939
950
|
;
|
|
940
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
941
|
-
ngOnChanges(_changes) {
|
|
942
|
-
this.transform = `scaleX(${this.scaleX}) scaleY(${this.scaleY})`;
|
|
943
|
-
}
|
|
944
951
|
}
|
|
945
952
|
ApplyScaleDirective.decorators = [
|
|
946
953
|
{ type: Directive, args: [{
|
|
@@ -952,10 +959,7 @@ ApplyScaleDirective.ctorParameters = () => [
|
|
|
952
959
|
];
|
|
953
960
|
ApplyScaleDirective.propDecorators = {
|
|
954
961
|
scale: [{ type: Input }],
|
|
955
|
-
|
|
956
|
-
scaleY: [{ type: Input }],
|
|
957
|
-
transform: [{ type: HostBinding, args: ['style.transform',] }],
|
|
958
|
-
transformOrigin: [{ type: Input }, { type: HostBinding, args: ['style.transformOrigin',] }]
|
|
962
|
+
fontSize: [{ type: HostBinding, args: ['style.fontSize',] }]
|
|
959
963
|
};
|
|
960
964
|
|
|
961
965
|
const EXPORTS = [
|
|
@@ -970,10 +974,21 @@ const EXPORTS = [
|
|
|
970
974
|
ArrayOfNPipe,
|
|
971
975
|
];
|
|
972
976
|
class InteractModule {
|
|
977
|
+
static forRoot(config) {
|
|
978
|
+
const defaultConfig = { cssDimensionUnit: 'px' };
|
|
979
|
+
return {
|
|
980
|
+
ngModule: InteractModule,
|
|
981
|
+
providers: [
|
|
982
|
+
{ provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
|
|
983
|
+
InteractService
|
|
984
|
+
]
|
|
985
|
+
};
|
|
986
|
+
}
|
|
973
987
|
}
|
|
974
988
|
InteractModule.decorators = [
|
|
975
989
|
{ type: NgModule, args: [{
|
|
976
990
|
imports: [CommonModule],
|
|
991
|
+
// providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
|
|
977
992
|
declarations: [
|
|
978
993
|
...EXPORTS,
|
|
979
994
|
],
|
|
@@ -987,5 +1002,5 @@ InteractModule.decorators = [
|
|
|
987
1002
|
* Generated bundle index. Do not edit.
|
|
988
1003
|
*/
|
|
989
1004
|
|
|
990
|
-
export { AccountForScaleDirective, ApplyScaleDirective, ArrayOfNPipe, DEFAULT_REGISTRY_ID, DragPreviewDirective, DragRootDirective, DraggableDirective, DropzoneDirective, GesturableDirective, InteractModule, ResizableDirective, TFT_DRAG_PREVIEW, cloneElement$1 as cloneElement, defaultDelta, defaultPosition, defaultSize, getClosestMatchingAncestor, getRootNode, DraggableDirective as ɵa, ResizableDirective as ɵb, DropzoneDirective as ɵc, GesturableDirective as ɵd, DragRootDirective as ɵe, AccountForScaleDirective as ɵf, ApplyScaleDirective as ɵg, DragPreviewDirective as ɵh, ArrayOfNPipe as ɵi };
|
|
1005
|
+
export { AccountForScaleDirective, ApplyScaleDirective, ArrayOfNPipe, DEFAULT_REGISTRY_ID, DragPreviewDirective, DragRootDirective, DraggableDirective, DropzoneDirective, GesturableDirective, INTERACT_ROOT_CONFIG, InteractModule, ResizableDirective, TFT_DRAG_PREVIEW, cloneElement$1 as cloneElement, defaultDelta, defaultPosition, defaultSize, getClosestMatchingAncestor, getRootNode, DraggableDirective as ɵa, ResizableDirective as ɵb, DropzoneDirective as ɵc, GesturableDirective as ɵd, DragRootDirective as ɵe, AccountForScaleDirective as ɵf, ApplyScaleDirective as ɵg, DragPreviewDirective as ɵh, ArrayOfNPipe as ɵi };
|
|
991
1006
|
//# sourceMappingURL=tft-interact.js.map
|