@tft/interact 12.4.0 → 12.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/tft-interact.umd.js +147 -104
- package/bundles/tft-interact.umd.js.map +1 -1
- package/esm2015/lib/directives/account-for-scale.directive.js +4 -17
- package/esm2015/lib/directives/account-for-scale.directive.js.map +1 -1
- package/esm2015/lib/directives/account-for-scale.directive.metadata.json +1 -1
- package/esm2015/lib/directives/apply-scale.directive.js +26 -0
- package/esm2015/lib/directives/apply-scale.directive.js.map +1 -0
- package/esm2015/lib/directives/apply-scale.directive.metadata.json +1 -0
- package/esm2015/lib/directives/drag-root.directive.js +8 -11
- package/esm2015/lib/directives/drag-root.directive.js.map +1 -1
- package/esm2015/lib/directives/drag-root.directive.metadata.json +1 -1
- package/esm2015/lib/directives/draggable.directive.js +12 -12
- package/esm2015/lib/directives/draggable.directive.js.map +1 -1
- package/esm2015/lib/directives/draggable.directive.metadata.json +1 -1
- package/esm2015/lib/directives/dropzone.directive.js +9 -5
- package/esm2015/lib/directives/dropzone.directive.js.map +1 -1
- package/esm2015/lib/directives/dropzone.directive.metadata.json +1 -1
- package/esm2015/lib/directives/index.js +1 -0
- package/esm2015/lib/directives/index.js.map +1 -1
- package/esm2015/lib/directives/index.metadata.json +1 -1
- package/esm2015/lib/directives/resizable.directive.js +1 -1
- package/esm2015/lib/directives/resizable.directive.js.map +1 -1
- package/esm2015/lib/interact.module.js +15 -1
- package/esm2015/lib/interact.module.js.map +1 -1
- package/esm2015/lib/interact.module.metadata.json +1 -1
- package/esm2015/lib/models/interact.js +2 -0
- package/esm2015/lib/models/interact.js.map +1 -1
- package/esm2015/lib/models/interact.metadata.json +1 -1
- package/esm2015/lib/services/interact.service.js +39 -24
- package/esm2015/lib/services/interact.service.js.map +1 -1
- package/esm2015/lib/services/interact.service.metadata.json +1 -1
- package/esm2015/tft-interact.js +2 -2
- package/esm2015/tft-interact.js.map +1 -1
- package/esm2015/tft-interact.metadata.json +1 -1
- package/fesm2015/tft-interact.js +128 -89
- package/fesm2015/tft-interact.js.map +1 -1
- package/lib/directives/account-for-scale.directive.d.ts +3 -7
- package/lib/directives/apply-scale.directive.d.ts +8 -0
- package/lib/directives/drag-root.directive.d.ts +2 -1
- package/lib/directives/draggable.directive.d.ts +2 -1
- package/lib/directives/dropzone.directive.d.ts +7 -5
- package/lib/directives/index.d.ts +1 -0
- package/lib/interact.module.d.ts +3 -0
- package/lib/models/interact.d.ts +6 -0
- package/lib/services/interact.service.d.ts +4 -2
- package/package.json +1 -1
- package/tft-interact-12.5.0.tgz +0 -0
- package/tft-interact.d.ts +2 -2
- package/tft-interact.metadata.json +1 -1
- package/tft-interact-12.4.0.tgz +0 -0
package/fesm2015/tft-interact.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Pipe, Injectable, RendererFactory2, NgZone,
|
|
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 {
|
|
@@ -164,8 +168,8 @@ class InteractService {
|
|
|
164
168
|
this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX, deltaY, width, height, targetElement });
|
|
165
169
|
}
|
|
166
170
|
interactableExistOnRegistry(interactId, registryId = DEFAULT_REGISTRY_ID) {
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
172
|
+
return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
|
|
169
173
|
}
|
|
170
174
|
/**
|
|
171
175
|
* Uses renderer to set width and height of angular component
|
|
@@ -179,14 +183,16 @@ class InteractService {
|
|
|
179
183
|
return;
|
|
180
184
|
const accountForScaleDirective = (_a = target.resizeRef) === null || _a === void 0 ? void 0 : _a.account_for_scale_dir;
|
|
181
185
|
if (accountForScaleDirective) {
|
|
182
|
-
const {
|
|
183
|
-
const scaledWidth = width /
|
|
184
|
-
const scaledHeight = height /
|
|
185
|
-
this.renderer.setStyle(target, 'width', `${scaledWidth}
|
|
186
|
-
this.renderer.setStyle(target, 'height', `${scaledHeight}
|
|
186
|
+
const { scale } = accountForScaleDirective;
|
|
187
|
+
const scaledWidth = width / scale;
|
|
188
|
+
const scaledHeight = height / scale;
|
|
189
|
+
this.renderer.setStyle(target, 'width', `${scaledWidth}${this.cssUnit}`);
|
|
190
|
+
this.renderer.setStyle(target, 'height', `${scaledHeight}${this.cssUnit}`);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);
|
|
194
|
+
this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);
|
|
187
195
|
}
|
|
188
|
-
this.renderer.setStyle(target, 'width', `${width}px`);
|
|
189
|
-
this.renderer.setStyle(target, 'height', `${height}px`);
|
|
190
196
|
}
|
|
191
197
|
/**
|
|
192
198
|
* Uses renderer to set position of angular component
|
|
@@ -195,17 +201,19 @@ class InteractService {
|
|
|
195
201
|
* @param target the element to transform
|
|
196
202
|
*/
|
|
197
203
|
setElementTransform(x, y, position) {
|
|
198
|
-
var _a, _b
|
|
204
|
+
var _a, _b;
|
|
199
205
|
if (!(position === null || position === void 0 ? void 0 : position.targetElement))
|
|
200
206
|
return;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
207
|
+
const dragRef = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef;
|
|
208
|
+
const accountForScaleDirective = (dragRef === null || dragRef === void 0 ? void 0 : dragRef.account_for_scale_dir) || ((_b = dragRef === null || dragRef === void 0 ? void 0 : dragRef.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir);
|
|
209
|
+
if (accountForScaleDirective) {
|
|
210
|
+
const { scale } = accountForScaleDirective;
|
|
211
|
+
this.renderer.setStyle(position.targetElement, 'left', `${x / scale}${this.cssUnit}`);
|
|
212
|
+
this.renderer.setStyle(position.targetElement, 'top', `${y / scale}${this.cssUnit}`);
|
|
205
213
|
}
|
|
206
214
|
else {
|
|
207
|
-
this.renderer.setStyle(position.targetElement, 'left', `${x}
|
|
208
|
-
this.renderer.setStyle(position.targetElement, 'top', `${y}
|
|
215
|
+
this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);
|
|
216
|
+
this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);
|
|
209
217
|
}
|
|
210
218
|
}
|
|
211
219
|
/**
|
|
@@ -215,32 +223,65 @@ class InteractService {
|
|
|
215
223
|
* @param y the position along the y axis
|
|
216
224
|
*/
|
|
217
225
|
createTransformString(x, y) {
|
|
218
|
-
return `translate3d(${x}
|
|
226
|
+
return `translate3d(${x}${this.cssUnit}, ${y}${this.cssUnit}, 0)`;
|
|
219
227
|
}
|
|
220
|
-
calculatePositionInElement(zoneElement, dragElement) {
|
|
228
|
+
calculatePositionInElement(zoneElement, dragElement, scale) {
|
|
221
229
|
// TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
|
|
222
230
|
const zoneRect = zoneElement.getBoundingClientRect();
|
|
223
231
|
const dragRect = dragElement.getBoundingClientRect();
|
|
224
|
-
|
|
232
|
+
const position = scale
|
|
233
|
+
? {
|
|
234
|
+
x: (dragRect.left - zoneRect.left) / scale || 1,
|
|
235
|
+
y: (dragRect.top - zoneRect.top) / scale || 1
|
|
236
|
+
} : {
|
|
225
237
|
x: dragRect.left - zoneRect.left,
|
|
226
238
|
y: dragRect.top - zoneRect.top
|
|
227
239
|
};
|
|
240
|
+
// console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
|
|
241
|
+
return position;
|
|
228
242
|
}
|
|
229
243
|
}
|
|
230
|
-
InteractService.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.NgZone)); }, token: InteractService, providedIn: "root" });
|
|
244
|
+
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" });
|
|
231
245
|
InteractService.decorators = [
|
|
232
246
|
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
233
247
|
];
|
|
234
248
|
InteractService.ctorParameters = () => [
|
|
235
249
|
{ type: RendererFactory2 },
|
|
236
|
-
{ type: NgZone }
|
|
250
|
+
{ type: NgZone },
|
|
251
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INTERACT_ROOT_CONFIG,] }] }
|
|
237
252
|
];
|
|
238
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Use to apply scale to the element and tell the drag and resize directives to account for the scale when
|
|
256
|
+
* @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
|
|
257
|
+
* @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
|
|
258
|
+
* element accounts for scale
|
|
259
|
+
*/
|
|
260
|
+
class AccountForScaleDirective {
|
|
261
|
+
constructor(el) {
|
|
262
|
+
this.el = el;
|
|
263
|
+
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
264
|
+
this.scale = 1;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
AccountForScaleDirective.decorators = [
|
|
268
|
+
{ type: Directive, args: [{
|
|
269
|
+
selector: '[tftAccountForScale]'
|
|
270
|
+
},] }
|
|
271
|
+
];
|
|
272
|
+
AccountForScaleDirective.ctorParameters = () => [
|
|
273
|
+
{ type: ElementRef }
|
|
274
|
+
];
|
|
275
|
+
AccountForScaleDirective.propDecorators = {
|
|
276
|
+
scale: [{ type: Input }]
|
|
277
|
+
};
|
|
278
|
+
|
|
239
279
|
class DropzoneDirective {
|
|
240
|
-
constructor(el, renderer, interactService) {
|
|
280
|
+
constructor(el, renderer, interactService, account_for_scale_dir) {
|
|
241
281
|
this.el = el;
|
|
242
282
|
this.renderer = renderer;
|
|
243
283
|
this.interactService = interactService;
|
|
284
|
+
this.account_for_scale_dir = account_for_scale_dir;
|
|
244
285
|
this.dropzoneConfig = {};
|
|
245
286
|
// proxies to pass interact events through to consumer of directive
|
|
246
287
|
this.dropActivate = new EventEmitter();
|
|
@@ -290,11 +331,12 @@ class DropzoneDirective {
|
|
|
290
331
|
* @param event the drop event emitted by interact, extended with extra fields we added to
|
|
291
332
|
*/
|
|
292
333
|
mapDropzoneEvent(event) {
|
|
293
|
-
var _a, _b;
|
|
334
|
+
var _a, _b, _c;
|
|
294
335
|
const zoneElement = event.target;
|
|
295
336
|
const dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
|
|
337
|
+
const scale = ((_c = this.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || null;
|
|
296
338
|
const positionInDropTarget = zoneElement && dragElement
|
|
297
|
-
? this.interactService.calculatePositionInElement(zoneElement, dragElement)
|
|
339
|
+
? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
|
|
298
340
|
: null;
|
|
299
341
|
return {
|
|
300
342
|
interactEvent: event,
|
|
@@ -316,7 +358,8 @@ DropzoneDirective.decorators = [
|
|
|
316
358
|
DropzoneDirective.ctorParameters = () => [
|
|
317
359
|
{ type: ElementRef },
|
|
318
360
|
{ type: Renderer2 },
|
|
319
|
-
{ type: InteractService }
|
|
361
|
+
{ type: InteractService },
|
|
362
|
+
{ type: AccountForScaleDirective, decorators: [{ type: Optional }] }
|
|
320
363
|
];
|
|
321
364
|
DropzoneDirective.propDecorators = {
|
|
322
365
|
dropzoneId: [{ type: Input }],
|
|
@@ -382,65 +425,24 @@ function getRootNode(viewRef, _document) {
|
|
|
382
425
|
return wrapper;
|
|
383
426
|
}
|
|
384
427
|
|
|
385
|
-
/**
|
|
386
|
-
* Use to apply scale to the element and tell the drag and resize directives to account for the scale when
|
|
387
|
-
* @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
|
|
388
|
-
* @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
|
|
389
|
-
* element accounts for scale
|
|
390
|
-
*/
|
|
391
|
-
class AccountForScaleDirective {
|
|
392
|
-
constructor(el) {
|
|
393
|
-
this.el = el;
|
|
394
|
-
this.scaleX = 1;
|
|
395
|
-
this.scaleY = 1;
|
|
396
|
-
}
|
|
397
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
398
|
-
set scale(val) {
|
|
399
|
-
this.scaleY = val;
|
|
400
|
-
this.scaleX = val;
|
|
401
|
-
}
|
|
402
|
-
;
|
|
403
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
404
|
-
ngOnChanges(_changes) {
|
|
405
|
-
this.transform = `scaleX(${this.scaleX}) scaleY(${this.scaleY})`;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
AccountForScaleDirective.decorators = [
|
|
409
|
-
{ type: Directive, args: [{
|
|
410
|
-
selector: '[tftAccountForScale]'
|
|
411
|
-
},] }
|
|
412
|
-
];
|
|
413
|
-
AccountForScaleDirective.ctorParameters = () => [
|
|
414
|
-
{ type: ElementRef }
|
|
415
|
-
];
|
|
416
|
-
AccountForScaleDirective.propDecorators = {
|
|
417
|
-
scale: [{ type: Input }],
|
|
418
|
-
scaleX: [{ type: Input }],
|
|
419
|
-
scaleY: [{ type: Input }],
|
|
420
|
-
transform: [{ type: HostBinding, args: ['style.transform',] }]
|
|
421
|
-
};
|
|
422
|
-
|
|
423
428
|
/**
|
|
424
429
|
* Use this directive to select which element to attach the element to while dragging
|
|
425
430
|
* @example <div tftDragRoot><div tftDraggable> </div> </div>
|
|
426
431
|
* @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
|
|
427
432
|
*/
|
|
428
433
|
class DragRootDirective {
|
|
429
|
-
constructor(el,
|
|
434
|
+
constructor(el,
|
|
435
|
+
// This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
|
|
436
|
+
// 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
|
|
437
|
+
account_for_scale_dir) {
|
|
430
438
|
this.el = el;
|
|
431
|
-
|
|
432
|
-
// with a dropzone inside of it and a drag item inside the dropzone
|
|
433
|
-
// e.g <div tftDragRoot> <div tftDropzone> <div tftDraggable</div> </div> </div>
|
|
434
|
-
// TODO: This is a band-aid, root cause in misunderstood, it started after switching from
|
|
435
|
-
// using `translate3d` to top/left for positioning
|
|
436
|
-
if (!account_for_scale_dir) {
|
|
437
|
-
el.nativeElement.style.transform = 'scale(1)';
|
|
438
|
-
}
|
|
439
|
+
this.account_for_scale_dir = account_for_scale_dir;
|
|
439
440
|
}
|
|
440
441
|
}
|
|
441
442
|
DragRootDirective.decorators = [
|
|
442
443
|
{ type: Directive, args: [{
|
|
443
|
-
selector: '[tftDragRoot]'
|
|
444
|
+
selector: '[tftDragRoot]',
|
|
445
|
+
exportAs: 'tftDragRoot'
|
|
444
446
|
},] }
|
|
445
447
|
];
|
|
446
448
|
DragRootDirective.ctorParameters = () => [
|
|
@@ -453,7 +455,6 @@ DragRootDirective.ctorParameters = () => [
|
|
|
453
455
|
class DraggableDirective {
|
|
454
456
|
// cache holding element to use as placeholder while dragging
|
|
455
457
|
constructor(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
|
|
456
|
-
var _a;
|
|
457
458
|
this.el = el;
|
|
458
459
|
this.interactService = interactService;
|
|
459
460
|
this.renderer = renderer;
|
|
@@ -476,14 +477,14 @@ class DraggableDirective {
|
|
|
476
477
|
this.dragMove = new EventEmitter();
|
|
477
478
|
this.dragInertiaStart = new EventEmitter();
|
|
478
479
|
this.dragEnd = new EventEmitter();
|
|
479
|
-
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;
|
|
480
480
|
}
|
|
481
481
|
ngOnInit() {
|
|
482
|
-
var _a;
|
|
482
|
+
var _a, _b, _c, _d, _e;
|
|
483
483
|
this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
|
|
484
|
+
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;
|
|
484
485
|
// register with parent dropzone if it exists, otherwise use default
|
|
485
486
|
// this gives us a place on the registry to store our drag items that don't have a dropzone
|
|
486
|
-
this.registryId = ((
|
|
487
|
+
this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
487
488
|
// add draggable to directory and store its id
|
|
488
489
|
this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
489
490
|
this.alignPositionWithInputs(this.x, this.y);
|
|
@@ -539,7 +540,7 @@ class DraggableDirective {
|
|
|
539
540
|
setDragStyles(dragElement) {
|
|
540
541
|
this.renderer.setStyle(dragElement, 'touchAction', 'none');
|
|
541
542
|
this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
|
|
542
|
-
this.renderer.setStyle(dragElement, 'position', '
|
|
543
|
+
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
543
544
|
}
|
|
544
545
|
addDragPropertiesToElement(nativeElement) {
|
|
545
546
|
this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
|
|
@@ -584,8 +585,9 @@ class DraggableDirective {
|
|
|
584
585
|
const interaction = event.interaction;
|
|
585
586
|
// check if we should append drag element to body
|
|
586
587
|
if (this.enableDragDefault
|
|
587
|
-
&& !!this.dropzone_dir
|
|
588
588
|
&& interaction.pointerIsDown
|
|
589
|
+
// TODO: probably don't need following condition checks anymore remove by 2022
|
|
590
|
+
// && !!this.dropzone_dir
|
|
589
591
|
// && !interaction.interacting()
|
|
590
592
|
) {
|
|
591
593
|
if (this._previewTemplate) {
|
|
@@ -597,8 +599,8 @@ class DraggableDirective {
|
|
|
597
599
|
}
|
|
598
600
|
this.addDragPropertiesToElement(this.previewRef);
|
|
599
601
|
this.setDragStyles(this.previewRef);
|
|
600
|
-
this.
|
|
601
|
-
const { x, y } = this.interactService.calculatePositionInElement(this.
|
|
602
|
+
this.dragRootEl.prepend(this.previewRef);
|
|
603
|
+
const { x, y } = this.interactService.calculatePositionInElement(this.dragRootEl, nativeElement);
|
|
602
604
|
this.interactService.updatePosition(this.interactableId, this.registryId, { x, y }, this.previewRef);
|
|
603
605
|
if (!this.showPlaceholder) {
|
|
604
606
|
this.renderer.setStyle(this.el.nativeElement, 'display', 'none');
|
|
@@ -626,10 +628,9 @@ class DraggableDirective {
|
|
|
626
628
|
this.renderer.setStyle(this.el.nativeElement, 'display', '');
|
|
627
629
|
this.dragEnd.emit(mappedEvent);
|
|
628
630
|
if (this.el.nativeElement !== this.previewRef) {
|
|
629
|
-
// we do this in a timeout, so that we don't
|
|
630
|
-
// remove before the dropzone can get the boundingElementRect
|
|
631
|
+
// we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
|
|
631
632
|
setTimeout(() => {
|
|
632
|
-
this.
|
|
633
|
+
this.dragRootEl.removeChild(this.previewRef);
|
|
633
634
|
});
|
|
634
635
|
}
|
|
635
636
|
});
|
|
@@ -652,7 +653,7 @@ DraggableDirective.ctorParameters = () => [
|
|
|
652
653
|
{ type: Renderer2 },
|
|
653
654
|
{ type: ViewContainerRef },
|
|
654
655
|
{ type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
655
|
-
{ type: AccountForScaleDirective, decorators: [{ type: Optional }
|
|
656
|
+
{ type: AccountForScaleDirective, decorators: [{ type: Optional }] },
|
|
656
657
|
{ type: DropzoneDirective, decorators: [{ type: Optional }, { type: SkipSelf }] },
|
|
657
658
|
{ type: DragRootDirective, decorators: [{ type: Optional }, { type: SkipSelf }] }
|
|
658
659
|
];
|
|
@@ -668,6 +669,7 @@ DraggableDirective.propDecorators = {
|
|
|
668
669
|
dragDisabled: [{ type: Input }],
|
|
669
670
|
dragConfig: [{ type: Input }],
|
|
670
671
|
showPlaceholder: [{ type: Input }],
|
|
672
|
+
dragRoot: [{ type: Input }],
|
|
671
673
|
dragStart: [{ type: Output }],
|
|
672
674
|
dragMove: [{ type: Output }],
|
|
673
675
|
dragInertiaStart: [{ type: Output }],
|
|
@@ -774,7 +776,7 @@ class ResizableDirective {
|
|
|
774
776
|
}
|
|
775
777
|
mapResizeEvent(event) {
|
|
776
778
|
var _a, _b;
|
|
777
|
-
const
|
|
779
|
+
const target = event.target;
|
|
778
780
|
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;
|
|
779
781
|
const positionInDropTarget = target && relatedTarget
|
|
780
782
|
? this.interactService.calculatePositionInElement(relatedTarget, target)
|
|
@@ -910,6 +912,31 @@ GesturableDirective.propDecorators = {
|
|
|
910
912
|
gestureEnd: [{ type: Output }]
|
|
911
913
|
};
|
|
912
914
|
|
|
915
|
+
class ApplyScaleDirective {
|
|
916
|
+
constructor(el) {
|
|
917
|
+
this.el = el;
|
|
918
|
+
this._scale = 1;
|
|
919
|
+
}
|
|
920
|
+
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
921
|
+
set scale(val) {
|
|
922
|
+
this._scale;
|
|
923
|
+
this.fontSize = `${val}px`;
|
|
924
|
+
}
|
|
925
|
+
;
|
|
926
|
+
}
|
|
927
|
+
ApplyScaleDirective.decorators = [
|
|
928
|
+
{ type: Directive, args: [{
|
|
929
|
+
selector: '[tftApplyScale]'
|
|
930
|
+
},] }
|
|
931
|
+
];
|
|
932
|
+
ApplyScaleDirective.ctorParameters = () => [
|
|
933
|
+
{ type: ElementRef }
|
|
934
|
+
];
|
|
935
|
+
ApplyScaleDirective.propDecorators = {
|
|
936
|
+
scale: [{ type: Input }],
|
|
937
|
+
fontSize: [{ type: HostBinding, args: ['style.fontSize',] }]
|
|
938
|
+
};
|
|
939
|
+
|
|
913
940
|
const EXPORTS = [
|
|
914
941
|
DraggableDirective,
|
|
915
942
|
ResizableDirective,
|
|
@@ -917,14 +944,26 @@ const EXPORTS = [
|
|
|
917
944
|
GesturableDirective,
|
|
918
945
|
DragRootDirective,
|
|
919
946
|
AccountForScaleDirective,
|
|
947
|
+
ApplyScaleDirective,
|
|
920
948
|
DragPreviewDirective,
|
|
921
949
|
ArrayOfNPipe,
|
|
922
950
|
];
|
|
923
951
|
class InteractModule {
|
|
952
|
+
static forRoot(config) {
|
|
953
|
+
const defaultConfig = { cssDimensionUnit: 'px' };
|
|
954
|
+
return {
|
|
955
|
+
ngModule: InteractModule,
|
|
956
|
+
providers: [
|
|
957
|
+
{ provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
|
|
958
|
+
InteractService
|
|
959
|
+
]
|
|
960
|
+
};
|
|
961
|
+
}
|
|
924
962
|
}
|
|
925
963
|
InteractModule.decorators = [
|
|
926
964
|
{ type: NgModule, args: [{
|
|
927
965
|
imports: [CommonModule],
|
|
966
|
+
// providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
|
|
928
967
|
declarations: [
|
|
929
968
|
...EXPORTS,
|
|
930
969
|
],
|
|
@@ -938,5 +977,5 @@ InteractModule.decorators = [
|
|
|
938
977
|
* Generated bundle index. Do not edit.
|
|
939
978
|
*/
|
|
940
979
|
|
|
941
|
-
export { AccountForScaleDirective, 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,
|
|
980
|
+
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 };
|
|
942
981
|
//# sourceMappingURL=tft-interact.js.map
|