@tft/interact 12.5.0 → 13.0.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/esm2020/index.mjs +6 -0
- package/esm2020/lib/directives/account-for-scale.directive.mjs +26 -0
- package/esm2020/lib/directives/apply-scale.directive.mjs +28 -0
- package/esm2020/lib/directives/auto-scroll.directive.mjs +56 -0
- package/esm2020/lib/directives/drag-preview.directive.mjs +20 -0
- package/esm2020/lib/directives/drag-root.directive.mjs +32 -0
- package/esm2020/lib/directives/draggable.directive.mjs +320 -0
- package/esm2020/lib/directives/dropzone.directive.mjs +114 -0
- package/esm2020/lib/directives/gesturable.directive.mjs +82 -0
- package/esm2020/lib/directives/index.mjs +10 -0
- package/esm2020/lib/directives/resizable.directive.mjs +228 -0
- package/esm2020/lib/interact.module.mjs +66 -0
- package/esm2020/lib/models/index.mjs +2 -0
- package/esm2020/lib/models/interact.mjs +28 -0
- package/esm2020/lib/pipes/array-of-n.pipe.mjs +22 -0
- package/esm2020/lib/pipes/index.mjs +2 -0
- package/esm2020/lib/services/interact.service.mjs +197 -0
- package/esm2020/lib/utils/helpers.mjs +35 -0
- package/esm2020/lib/utils/index.mjs +2 -0
- package/esm2020/tft-interact.mjs +5 -0
- package/fesm2015/{tft-interact.js → tft-interact.mjs} +511 -289
- package/fesm2015/tft-interact.mjs.map +1 -0
- package/fesm2020/tft-interact.mjs +1192 -0
- package/fesm2020/tft-interact.mjs.map +1 -0
- package/lib/directives/account-for-scale.directive.d.ts +3 -0
- package/lib/directives/apply-scale.directive.d.ts +3 -0
- package/lib/directives/auto-scroll.directive.d.ts +34 -0
- package/lib/directives/drag-preview.directive.d.ts +3 -0
- package/lib/directives/drag-root.directive.d.ts +3 -0
- package/lib/directives/draggable.directive.d.ts +9 -1
- package/lib/directives/dropzone.directive.d.ts +6 -0
- package/lib/directives/gesturable.directive.d.ts +3 -0
- package/lib/directives/index.d.ts +1 -0
- package/lib/directives/resizable.directive.d.ts +13 -3
- package/lib/interact.module.d.ts +15 -0
- package/lib/models/interact.d.ts +4 -0
- package/lib/pipes/array-of-n.pipe.d.ts +3 -0
- package/lib/services/interact.service.d.ts +5 -2
- package/package.json +23 -10
- package/tft-interact-13.0.0.tgz +0 -0
- package/tft-interact.d.ts +1 -2
- package/bundles/tft-interact.umd.js +0 -1382
- package/bundles/tft-interact.umd.js.map +0 -1
- package/esm2015/index.js +0 -6
- package/esm2015/index.js.map +0 -1
- package/esm2015/index.metadata.json +0 -1
- package/esm2015/lib/directives/account-for-scale.directive.js +0 -26
- package/esm2015/lib/directives/account-for-scale.directive.js.map +0 -1
- package/esm2015/lib/directives/account-for-scale.directive.metadata.json +0 -1
- package/esm2015/lib/directives/apply-scale.directive.js +0 -26
- package/esm2015/lib/directives/apply-scale.directive.js.map +0 -1
- package/esm2015/lib/directives/apply-scale.directive.metadata.json +0 -1
- package/esm2015/lib/directives/drag-preview.directive.js +0 -20
- package/esm2015/lib/directives/drag-preview.directive.js.map +0 -1
- package/esm2015/lib/directives/drag-preview.directive.metadata.json +0 -1
- package/esm2015/lib/directives/drag-root.directive.js +0 -27
- package/esm2015/lib/directives/drag-root.directive.js.map +0 -1
- package/esm2015/lib/directives/drag-root.directive.metadata.json +0 -1
- package/esm2015/lib/directives/draggable.directive.js +0 -255
- package/esm2015/lib/directives/draggable.directive.js.map +0 -1
- package/esm2015/lib/directives/draggable.directive.metadata.json +0 -1
- package/esm2015/lib/directives/dropzone.directive.js +0 -99
- package/esm2015/lib/directives/dropzone.directive.js.map +0 -1
- package/esm2015/lib/directives/dropzone.directive.metadata.json +0 -1
- package/esm2015/lib/directives/gesturable.directive.js +0 -77
- package/esm2015/lib/directives/gesturable.directive.js.map +0 -1
- package/esm2015/lib/directives/gesturable.directive.metadata.json +0 -1
- package/esm2015/lib/directives/index.js +0 -9
- package/esm2015/lib/directives/index.js.map +0 -1
- package/esm2015/lib/directives/index.metadata.json +0 -1
- package/esm2015/lib/directives/resizable.directive.js +0 -152
- package/esm2015/lib/directives/resizable.directive.js.map +0 -1
- package/esm2015/lib/directives/resizable.directive.metadata.json +0 -1
- package/esm2015/lib/interact.module.js +0 -42
- package/esm2015/lib/interact.module.js.map +0 -1
- package/esm2015/lib/interact.module.metadata.json +0 -1
- package/esm2015/lib/models/index.js +0 -2
- package/esm2015/lib/models/index.js.map +0 -1
- package/esm2015/lib/models/index.metadata.json +0 -1
- package/esm2015/lib/models/interact.js +0 -28
- package/esm2015/lib/models/interact.js.map +0 -1
- package/esm2015/lib/models/interact.metadata.json +0 -1
- package/esm2015/lib/pipes/array-of-n.pipe.js +0 -18
- package/esm2015/lib/pipes/array-of-n.pipe.js.map +0 -1
- package/esm2015/lib/pipes/array-of-n.pipe.metadata.json +0 -1
- package/esm2015/lib/pipes/index.js +0 -2
- package/esm2015/lib/pipes/index.js.map +0 -1
- package/esm2015/lib/pipes/index.metadata.json +0 -1
- package/esm2015/lib/services/interact.service.js +0 -208
- package/esm2015/lib/services/interact.service.js.map +0 -1
- package/esm2015/lib/services/interact.service.metadata.json +0 -1
- package/esm2015/lib/utils/helpers.js +0 -35
- package/esm2015/lib/utils/helpers.js.map +0 -1
- package/esm2015/lib/utils/helpers.metadata.json +0 -1
- package/esm2015/lib/utils/index.js +0 -2
- package/esm2015/lib/utils/index.js.map +0 -1
- package/esm2015/lib/utils/index.metadata.json +0 -1
- package/esm2015/tft-interact.js +0 -7
- package/esm2015/tft-interact.js.map +0 -1
- package/esm2015/tft-interact.metadata.json +0 -1
- package/fesm2015/tft-interact.js.map +0 -1
- package/tft-interact-12.5.0.tgz +0 -0
- package/tft-interact.metadata.json +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, Input, Optional, SkipSelf, Output, EventEmitter, Renderer2, Inject } from '@angular/core';
|
|
2
|
-
import { DOCUMENT } from '@angular/common';
|
|
3
|
-
import interact from 'interactjs';
|
|
4
|
-
import { InteractService } from '../services/interact.service';
|
|
5
|
-
import { DraggableDirective } from './draggable.directive';
|
|
6
|
-
import { DropzoneDirective } from './dropzone.directive';
|
|
7
|
-
import { DragRootDirective } from './drag-root.directive';
|
|
8
|
-
import { AccountForScaleDirective } from './account-for-scale.directive';
|
|
9
|
-
import { DEFAULT_REGISTRY_ID } from '../models';
|
|
10
|
-
/** @dynamic */
|
|
11
|
-
export class ResizableDirective {
|
|
12
|
-
constructor(el, _document, interactService, renderer, drag_root_dir, account_for_scale_dir, draggable_dir, dropzone_dir) {
|
|
13
|
-
var _a;
|
|
14
|
-
this.el = el;
|
|
15
|
-
this._document = _document;
|
|
16
|
-
this.interactService = interactService;
|
|
17
|
-
this.renderer = renderer;
|
|
18
|
-
this.account_for_scale_dir = account_for_scale_dir;
|
|
19
|
-
this.draggable_dir = draggable_dir;
|
|
20
|
-
this.dropzone_dir = dropzone_dir;
|
|
21
|
-
this.enableResizeDefault = true;
|
|
22
|
-
// TODO: should this be an input with default or should consuming user set display in styles each time
|
|
23
|
-
this.position = 'absolute';
|
|
24
|
-
this.resizeDisabled = false;
|
|
25
|
-
this.resizeStart = new EventEmitter();
|
|
26
|
-
this.resizeMove = new EventEmitter();
|
|
27
|
-
this.resizeInertiaStart = new EventEmitter();
|
|
28
|
-
this.resizeEnd = new EventEmitter();
|
|
29
|
-
this.defaultConfig = {
|
|
30
|
-
edges: { left: true, right: true, bottom: true, top: true }
|
|
31
|
-
};
|
|
32
|
-
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;
|
|
33
|
-
}
|
|
34
|
-
ngOnInit() {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
this.addResizePropertiesToElement(this.el.nativeElement);
|
|
37
|
-
// we check for a dropzone, we use its id as the registry id if there is on
|
|
38
|
-
// otherwise, we use DEFAULT_REGISTRY_ID as a registry id. This allows us to keep our interactable
|
|
39
|
-
// drag state organized by dropzones.
|
|
40
|
-
this.registryId = ((_a = this.dropzone_dir) === null || _a === void 0 ? void 0 : _a.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
41
|
-
this.interactableId = ((_b = this.draggable_dir) === null || _b === void 0 ? void 0 : _b.interactableId) || this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
42
|
-
this.interactable = this.initiateResizeEvents(Object.assign(Object.assign({}, this.defaultConfig), this.resizeConfig), this.el.nativeElement);
|
|
43
|
-
this.alignDimensionsWithInputs(this.width, this.height);
|
|
44
|
-
this.interactableSubscription = this.interactService
|
|
45
|
-
.getInteractableState(this.interactableId, this.registryId)
|
|
46
|
-
.subscribe();
|
|
47
|
-
}
|
|
48
|
-
ngOnChanges(changes) {
|
|
49
|
-
if ((changes.resizeConfig || changes.resizeDisabled) && this.interactable) {
|
|
50
|
-
this.interactable.resizable(Object.assign(Object.assign({}, this.resizeConfig), { enabled: !this.resizeDisabled }));
|
|
51
|
-
}
|
|
52
|
-
if (changes.width || changes.height) {
|
|
53
|
-
this.alignDimensionsWithInputs(this.width, this.height);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
ngOnDestroy() {
|
|
57
|
-
this.interactableSubscription.unsubscribe();
|
|
58
|
-
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
59
|
-
}
|
|
60
|
-
resizeListener(event) {
|
|
61
|
-
const deltaX = event.deltaRect.left;
|
|
62
|
-
const deltaY = event.deltaRect.top;
|
|
63
|
-
const { width, height } = event.rect;
|
|
64
|
-
this.interactService.updateSize(this.interactableId, this.registryId, { deltaX, deltaY, width, height }, this.el.nativeElement);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* hook elements into interacts resize event listeners
|
|
68
|
-
* we spread the configs so that the consuming component only overwrites the
|
|
69
|
-
* pieces that it explicitly indicates
|
|
70
|
-
* @param resizeConfig
|
|
71
|
-
* @param nativeElement
|
|
72
|
-
*/
|
|
73
|
-
initiateResizeEvents(resizeConfig, nativeElement) {
|
|
74
|
-
var _a;
|
|
75
|
-
// TODO: This should try and get interactable from tft_draggable if it exists
|
|
76
|
-
const interactable = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactable) || interact(nativeElement);
|
|
77
|
-
return interactable.resizable(Object.assign(Object.assign({}, resizeConfig), { enabled: !this.resizeDisabled }))
|
|
78
|
-
.on('resizestart', (event) => { this.resizeStart.emit(this.mapResizeEvent(event)); })
|
|
79
|
-
.on('resizemove', (event) => {
|
|
80
|
-
if (this.enableResizeDefault) {
|
|
81
|
-
this.resizeListener(event);
|
|
82
|
-
}
|
|
83
|
-
const mappedEvent = this.mapResizeEvent(event);
|
|
84
|
-
this.resizeMove.emit(mappedEvent);
|
|
85
|
-
})
|
|
86
|
-
.on('resizeinertiastart', (event) => this.resizeInertiaStart.emit(this.mapResizeEvent(event)))
|
|
87
|
-
.on('resizeend', (event) => this.resizeEnd.emit(this.mapResizeEvent(event)));
|
|
88
|
-
}
|
|
89
|
-
mapResizeEvent(event) {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
const target = event.target;
|
|
92
|
-
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;
|
|
93
|
-
const positionInDropTarget = target && relatedTarget
|
|
94
|
-
? this.interactService.calculatePositionInElement(relatedTarget, target)
|
|
95
|
-
: null;
|
|
96
|
-
return {
|
|
97
|
-
interactEvent: event,
|
|
98
|
-
resizeRef: this,
|
|
99
|
-
// should I remove this?
|
|
100
|
-
dragRef: this.draggable_dir,
|
|
101
|
-
dragOrigin: this.dropzone_dir,
|
|
102
|
-
dropTarget: this.el.nativeElement.dropTarget,
|
|
103
|
-
positionInDropTarget
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
alignDimensionsWithInputs(width, height) {
|
|
107
|
-
this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: 0, deltaY: 0, width, height }, this.el.nativeElement);
|
|
108
|
-
}
|
|
109
|
-
addResizePropertiesToElement(nativeElement) {
|
|
110
|
-
this.renderer.setProperty(nativeElement, 'resizeRef', this);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
ResizableDirective.decorators = [
|
|
114
|
-
{ type: Directive, args: [{
|
|
115
|
-
selector: '[tftResizable]',
|
|
116
|
-
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
|
117
|
-
host: {
|
|
118
|
-
// prevents touch events from colliding with with mouse events
|
|
119
|
-
// on touch screen
|
|
120
|
-
'[style.touchAction]': 'this.resizeDisabled ? "auto" : "none"',
|
|
121
|
-
// default to absolute here to accommodate likely use cases
|
|
122
|
-
// consuming component can easily over ride with position input
|
|
123
|
-
'[style.position]': 'position',
|
|
124
|
-
// follows interactjs suggested practices
|
|
125
|
-
'[style.boxSizing]': '"border-box"',
|
|
126
|
-
}
|
|
127
|
-
},] }
|
|
128
|
-
];
|
|
129
|
-
ResizableDirective.ctorParameters = () => [
|
|
130
|
-
{ type: ElementRef },
|
|
131
|
-
{ type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
132
|
-
{ type: InteractService },
|
|
133
|
-
{ type: Renderer2 },
|
|
134
|
-
{ type: DragRootDirective, decorators: [{ type: Optional }] },
|
|
135
|
-
{ type: AccountForScaleDirective, decorators: [{ type: Optional }] },
|
|
136
|
-
{ type: DraggableDirective, decorators: [{ type: Optional }] },
|
|
137
|
-
{ type: DropzoneDirective, decorators: [{ type: Optional }, { type: SkipSelf }] }
|
|
138
|
-
];
|
|
139
|
-
ResizableDirective.propDecorators = {
|
|
140
|
-
enableResizeDefault: [{ type: Input }],
|
|
141
|
-
position: [{ type: Input }],
|
|
142
|
-
resizeConfig: [{ type: Input }],
|
|
143
|
-
interactableId: [{ type: Input }],
|
|
144
|
-
width: [{ type: Input }],
|
|
145
|
-
height: [{ type: Input }],
|
|
146
|
-
resizeDisabled: [{ type: Input }],
|
|
147
|
-
resizeStart: [{ type: Output }],
|
|
148
|
-
resizeMove: [{ type: Output }],
|
|
149
|
-
resizeInertiaStart: [{ type: Output }],
|
|
150
|
-
resizeEnd: [{ type: Output }]
|
|
151
|
-
};
|
|
152
|
-
//# sourceMappingURL=resizable.directive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resizable.directive.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/directives/resizable.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAA4B,SAAS,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACtK,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAiC,mBAAmB,EAAkB,MAAM,WAAW,CAAC;AAE/F,eAAe;AAgBf,MAAM,OAAO,kBAAkB;IA2B7B,YACS,EAAc,EACK,SAAmB,EACrC,eAAgC,EAChC,QAAmB,EACf,aAAiC,EAC1B,qBAAgD,EAC/C,aAAkC,EACtB,YAAgC;;QAPzD,OAAE,GAAF,EAAE,CAAY;QACK,cAAS,GAAT,SAAS,CAAU;QACrC,oBAAe,GAAf,eAAe,CAAiB;QAChC,aAAQ,GAAR,QAAQ,CAAW;QAER,0BAAqB,GAArB,qBAAqB,CAA2B;QAC/C,kBAAa,GAAb,aAAa,CAAqB;QACtB,iBAAY,GAAZ,YAAY,CAAoB;QAjCzD,wBAAmB,GAAG,IAAI,CAAC;QACpC,sG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L,KAAK;qBACL,KAAK;6BACL,KAAK;0BAEL,MAAM;yBACN,MAAM;iCACN,MAAM;wBACN,MAAM","sourcesContent":["import { Directive, OnInit, OnDestroy, ElementRef, Input, Optional, SkipSelf, Output, EventEmitter, OnChanges, SimpleChanges, Renderer2, Inject} from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport interact from 'interactjs';\nimport { InteractService } from '../services/interact.service';\nimport { ResizableOptions, ResizeEvent, Interactable } from '@interactjs/types/index';\nimport { Subscription } from 'rxjs';\nimport { DraggableDirective } from './draggable.directive';\nimport { DropzoneDirective } from './dropzone.directive';\nimport { DragRootDirective } from './drag-root.directive';\nimport { AccountForScaleDirective } from './account-for-scale.directive';\nimport { NgResizeEvent, TftResizeEvent, DEFAULT_REGISTRY_ID, TftDragElement } from '../models';\n\n/** @dynamic */\n@Directive({\n selector: '[tftResizable]',\n // eslint-disable-next-line @angular-eslint/no-host-metadata-property\n host: {\n // prevents touch events from colliding with with mouse events\n // on touch screen\n '[style.touchAction]': 'this.resizeDisabled ? \"auto\" : \"none\"',\n // default to absolute here to accommodate likely use cases\n // consuming component can easily over ride with position input\n '[style.position]': 'position',\n // follows interactjs suggested practices\n '[style.boxSizing]': '\"border-box\"',\n\n }\n})\nexport class ResizableDirective implements OnInit, OnDestroy, OnChanges {\n\n @Input() enableResizeDefault = true;\n // TODO: should this be an input with default or should consuming user set display in styles each time\n @Input() position = 'absolute';\n @Input() resizeConfig: Partial<Interact.OrBoolean<ResizableOptions>>;\n @Input() interactableId: string;\n\n @Input() width: number;\n @Input() height: number;\n @Input() resizeDisabled = false;\n\n @Output() resizeStart = new EventEmitter<TftResizeEvent>();\n @Output() resizeMove = new EventEmitter<TftResizeEvent>();\n @Output() resizeInertiaStart = new EventEmitter<TftResizeEvent>();\n @Output() resizeEnd = new EventEmitter<TftResizeEvent>();\n\n defaultConfig: Partial<Interact.OrBoolean<ResizableOptions>> = {\n edges: { left: true, right: true, bottom: true, top: true }\n };\n registryId: string;\n interactable: Interactable;\n // The\n dragRoot: HTMLElement;\n\n private interactableSubscription: Subscription;\n\n constructor(\n public el: ElementRef,\n @Inject(DOCUMENT) private _document: Document,\n private interactService: InteractService,\n private renderer: Renderer2,\n @Optional() drag_root_dir?: DragRootDirective,\n @Optional() public account_for_scale_dir?: AccountForScaleDirective,\n @Optional() private draggable_dir?: DraggableDirective,\n @Optional() @SkipSelf() private dropzone_dir?: DropzoneDirective\n ) {\n this.dragRoot = (drag_root_dir?.el?.nativeElement as HTMLElement) || this._document.body;\n }\n\n ngOnInit() {\n this.addResizePropertiesToElement(this.el.nativeElement);\n\n // we check for a dropzone, we use its id as the registry id if there is on\n // otherwise, we use DEFAULT_REGISTRY_ID as a registry id. This allows us to keep our interactable\n // drag state organized by dropzones.\n this.registryId = this.dropzone_dir?.dropzoneId || DEFAULT_REGISTRY_ID;\n\n this.interactableId = this.draggable_dir?.interactableId || this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);\n\n this.interactable = this.initiateResizeEvents(\n {...this.defaultConfig, ...this.resizeConfig },\n this.el.nativeElement\n );\n\n this.alignDimensionsWithInputs(this.width, this.height);\n\n this.interactableSubscription = this.interactService\n .getInteractableState(this.interactableId, this.registryId)\n .subscribe();\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if ((changes.resizeConfig || changes.resizeDisabled) && this.interactable) {\n this.interactable.resizable({...this.resizeConfig, enabled: !this.resizeDisabled,});\n }\n if (changes.width || changes.height) {\n this.alignDimensionsWithInputs(this.width, this.height);\n }\n }\n\n ngOnDestroy() {\n this.interactableSubscription.unsubscribe();\n this.interactService.destroyInteractable(this.interactableId, this.registryId);\n }\n\n resizeListener(event: ResizeEvent) {\n const deltaX = event.deltaRect.left;\n const deltaY = event.deltaRect.top;\n const { width, height } = event.rect;\n this.interactService.updateSize(\n this.interactableId,\n this.registryId,\n {deltaX, deltaY, width, height},\n this.el.nativeElement\n );\n }\n /**\n * hook elements into interacts resize event listeners\n * we spread the configs so that the consuming component only overwrites the\n * pieces that it explicitly indicates\n * @param resizeConfig\n * @param nativeElement\n */\n initiateResizeEvents(resizeConfig: Partial<Interact.OrBoolean<ResizableOptions>>, nativeElement: any) {\n // TODO: This should try and get interactable from tft_draggable if it exists\n const interactable = this.draggable_dir?.interactable || interact(nativeElement);\n return interactable.resizable({...resizeConfig, enabled: !this.resizeDisabled})\n .on('resizestart', (event: NgResizeEvent) => { this.resizeStart.emit(this.mapResizeEvent(event))})\n .on('resizemove', (event: NgResizeEvent) => {\n if (this.enableResizeDefault) {\n this.resizeListener(event)\n }\n const mappedEvent = this.mapResizeEvent(event);\n this.resizeMove.emit(mappedEvent)\n })\n .on('resizeinertiastart', (event: NgResizeEvent) => this.resizeInertiaStart.emit(this.mapResizeEvent(event)))\n .on('resizeend', (event: NgResizeEvent) => this.resizeEnd.emit(this.mapResizeEvent(event)));\n }\n\n mapResizeEvent(event: NgResizeEvent ): TftResizeEvent {\n const target = event.target as TftDragElement;\n const relatedTarget = this.draggable_dir?.dropzone_dir?.el.nativeElement\n const positionInDropTarget = target && relatedTarget\n ? this.interactService.calculatePositionInElement(relatedTarget, target)\n : null;\n return {\n interactEvent: event,\n resizeRef: this,\n // should I remove this?\n dragRef: this.draggable_dir,\n dragOrigin: this.dropzone_dir,\n dropTarget: this.el.nativeElement.dropTarget,\n positionInDropTarget\n }\n }\n\n alignDimensionsWithInputs(width: number, height: number) {\n this.interactService.updateSize(\n this.interactableId,\n this.registryId,\n {deltaX: 0, deltaY: 0, width, height},\n this.el.nativeElement\n );\n }\n\n addResizePropertiesToElement(nativeElement: TftDragElement) {\n this.renderer.setProperty(nativeElement, 'resizeRef', this);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"ResizableDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":13,"character":1},"arguments":[{"selector":"[tftResizable]","host":{"[style.touchAction]":"this.resizeDisabled ? \"auto\" : \"none\"","[style.position]":"position","[style.boxSizing]":"\"border-box\"","$quoted$":["[style.touchAction]","[style.position]","[style.boxSizing]"]}}]}],"members":{"enableResizeDefault":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":30,"character":3}}]}],"position":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":32,"character":3}}]}],"resizeConfig":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":33,"character":3}}]}],"interactableId":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":34,"character":3}}]}],"width":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":36,"character":3}}]}],"height":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":37,"character":3}}]}],"resizeDisabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":38,"character":3}}]}],"resizeStart":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":40,"character":3}}]}],"resizeMove":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":41,"character":3}}]}],"resizeInertiaStart":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":42,"character":3}}]}],"resizeEnd":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":43,"character":3}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":57,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/common","name":"DOCUMENT","line":57,"character":12}]}],null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":60,"character":5}}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":61,"character":5}}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":62,"character":5}}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":63,"character":5}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf","line":63,"character":17}}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":56,"character":15},{"__symbolic":"error","message":"Could not resolve type","line":57,"character":41,"context":{"typeName":"Document"}},{"__symbolic":"reference","module":"../services/interact.service","name":"InteractService","line":58,"character":29},{"__symbolic":"reference","module":"@angular/core","name":"Renderer2","line":59,"character":22},{"__symbolic":"reference","module":"./drag-root.directive","name":"DragRootDirective","line":60,"character":32},{"__symbolic":"reference","module":"./account-for-scale.directive","name":"AccountForScaleDirective","line":61,"character":47},{"__symbolic":"reference","module":"./draggable.directive","name":"DraggableDirective","line":62,"character":40},{"__symbolic":"reference","module":"./dropzone.directive","name":"DropzoneDirective","line":63,"character":51}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"resizeListener":[{"__symbolic":"method"}],"initiateResizeEvents":[{"__symbolic":"method"}],"mapResizeEvent":[{"__symbolic":"method"}],"alignDimensionsWithInputs":[{"__symbolic":"method"}],"addResizePropertiesToElement":[{"__symbolic":"method"}]}}}}]
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { ArrayOfNPipe } from './pipes/array-of-n.pipe';
|
|
4
|
-
import { ApplyScaleDirective, DraggableDirective, DragRootDirective, AccountForScaleDirective, GesturableDirective, ResizableDirective, DropzoneDirective, DragPreviewDirective } from './directives';
|
|
5
|
-
import { InteractService } from './services/interact.service';
|
|
6
|
-
import { INTERACT_ROOT_CONFIG } from './models';
|
|
7
|
-
const EXPORTS = [
|
|
8
|
-
DraggableDirective,
|
|
9
|
-
ResizableDirective,
|
|
10
|
-
DropzoneDirective,
|
|
11
|
-
GesturableDirective,
|
|
12
|
-
DragRootDirective,
|
|
13
|
-
AccountForScaleDirective,
|
|
14
|
-
ApplyScaleDirective,
|
|
15
|
-
DragPreviewDirective,
|
|
16
|
-
ArrayOfNPipe,
|
|
17
|
-
];
|
|
18
|
-
export class InteractModule {
|
|
19
|
-
static forRoot(config) {
|
|
20
|
-
const defaultConfig = { cssDimensionUnit: 'px' };
|
|
21
|
-
return {
|
|
22
|
-
ngModule: InteractModule,
|
|
23
|
-
providers: [
|
|
24
|
-
{ provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
|
|
25
|
-
InteractService
|
|
26
|
-
]
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
InteractModule.decorators = [
|
|
31
|
-
{ type: NgModule, args: [{
|
|
32
|
-
imports: [CommonModule],
|
|
33
|
-
// providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
|
|
34
|
-
declarations: [
|
|
35
|
-
...EXPORTS,
|
|
36
|
-
],
|
|
37
|
-
exports: [
|
|
38
|
-
...EXPORTS
|
|
39
|
-
]
|
|
40
|
-
},] }
|
|
41
|
-
];
|
|
42
|
-
//# sourceMappingURL=interact.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interact.module.js","sourceRoot":"","sources":["../../../../../libs/interact/src/lib/interact.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACtM,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAsB,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAIpE,MAAM,OAAO,GAAG;IACd,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;IACjB,mBAAmB;IACnB,iBAAiB;IACjB,wBAAwB;IACxB,mBAAmB;IACnB,oBAAoB;IACpB,YAAY;CACb,CAAC;AAaF,MAAM,OAAO,cAAc;IACzB,MAAM,CAAC,OAAO,CAAC,MAA0B;QACvC,MAAM,aAAa,GAAuB,EAAC,gBAAgB,EAAE,IAAI,EAAC,CAAA;QAClE,OAAO;YACL,QAAQ,EAAE,cAAc;YACxB,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,kCAAM,aAAa,GAAK,MAAM,CAAC,EAAE;gBAC1E,eAAe;aAChB;SACF,CAAC;IACJ,CAAC;;;YApBF,QAAQ,SAAC;gBACR,OAAO,EAAE,CAAC,YAAY,CAAC;gBACvB,kEAAkE;gBAClE,YAAY,EAAE;oBACZ,GAAG,OAAO;iBACX;gBACD,OAAO,EAAE;oBACP,GAAG,OAAO;iBACX;aACF","sourcesContent":["import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ArrayOfNPipe } from './pipes/array-of-n.pipe';\nimport { ApplyScaleDirective, DraggableDirective, DragRootDirective, AccountForScaleDirective, GesturableDirective, ResizableDirective, DropzoneDirective, DragPreviewDirective } from './directives';\nimport { InteractService } from './services/interact.service';\nimport { InteractRootConfig, INTERACT_ROOT_CONFIG } from './models';\n\n\n\nconst EXPORTS = [\n DraggableDirective,\n ResizableDirective,\n DropzoneDirective,\n GesturableDirective,\n DragRootDirective,\n AccountForScaleDirective,\n ApplyScaleDirective,\n DragPreviewDirective,\n ArrayOfNPipe,\n];\n\n\n@NgModule({\n imports: [CommonModule],\n // providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],\n declarations: [\n ...EXPORTS,\n ],\n exports: [\n ...EXPORTS\n ]\n})\nexport class InteractModule {\n static forRoot(config: InteractRootConfig): ModuleWithProviders<InteractModule> {\n const defaultConfig: InteractRootConfig = {cssDimensionUnit: 'px'}\n return {\n ngModule: InteractModule,\n providers: [\n { provide: INTERACT_ROOT_CONFIG, useValue: {...defaultConfig, ...config} },\n InteractService\n ]\n };\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"InteractModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":22,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":23,"character":12}],"declarations":[{"__symbolic":"reference","module":"./directives","name":"DraggableDirective","line":10,"character":2},{"__symbolic":"reference","module":"./directives","name":"ResizableDirective","line":11,"character":2},{"__symbolic":"reference","module":"./directives","name":"DropzoneDirective","line":12,"character":2},{"__symbolic":"reference","module":"./directives","name":"GesturableDirective","line":13,"character":2},{"__symbolic":"reference","module":"./directives","name":"DragRootDirective","line":14,"character":2},{"__symbolic":"reference","module":"./directives","name":"AccountForScaleDirective","line":15,"character":2},{"__symbolic":"reference","module":"./directives","name":"ApplyScaleDirective","line":16,"character":2},{"__symbolic":"reference","module":"./directives","name":"DragPreviewDirective","line":17,"character":2},{"__symbolic":"reference","module":"./pipes/array-of-n.pipe","name":"ArrayOfNPipe","line":18,"character":2}],"exports":[{"__symbolic":"reference","module":"./directives","name":"DraggableDirective","line":10,"character":2},{"__symbolic":"reference","module":"./directives","name":"ResizableDirective","line":11,"character":2},{"__symbolic":"reference","module":"./directives","name":"DropzoneDirective","line":12,"character":2},{"__symbolic":"reference","module":"./directives","name":"GesturableDirective","line":13,"character":2},{"__symbolic":"reference","module":"./directives","name":"DragRootDirective","line":14,"character":2},{"__symbolic":"reference","module":"./directives","name":"AccountForScaleDirective","line":15,"character":2},{"__symbolic":"reference","module":"./directives","name":"ApplyScaleDirective","line":16,"character":2},{"__symbolic":"reference","module":"./directives","name":"DragPreviewDirective","line":17,"character":2},{"__symbolic":"reference","module":"./pipes/array-of-n.pipe","name":"ArrayOfNPipe","line":18,"character":2}]}]}]}}}]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC","sourcesContent":["export * from './interact';"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./interact"}]}]
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
export const INTERACT_ROOT_CONFIG = new InjectionToken('INTERACT_ROOT_CONFIG_PARAMS');
|
|
3
|
-
export const DEFAULT_REGISTRY_ID = 'DEFAULT';
|
|
4
|
-
/**
|
|
5
|
-
* Default initial value for Delta BehaviorSubject
|
|
6
|
-
*/
|
|
7
|
-
export const defaultDelta = {
|
|
8
|
-
deltaX: 0,
|
|
9
|
-
deltaY: 0,
|
|
10
|
-
targetElement: null
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Default initial value for Size BehaviorSubject
|
|
14
|
-
*/
|
|
15
|
-
export const defaultSize = {
|
|
16
|
-
width: null,
|
|
17
|
-
height: null,
|
|
18
|
-
targetElement: null
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Default initial value for Position BehaviorSubject
|
|
22
|
-
*/
|
|
23
|
-
export const defaultPosition = {
|
|
24
|
-
x: 0,
|
|
25
|
-
y: 0,
|
|
26
|
-
targetElement: null
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=interact.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interact.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/models/interact.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQ/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,cAAc,CAAqB,6BAA6B,CAAC,CAAC;AAE1G,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAC7C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,IAAI;CACpB,CAAC;AACF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAS;IAC/B,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,aAAa,EAAE,IAAI;CACpB,CAAA;AACD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,aAAa,EAAE,IAAI;CACpB,CAAA","sourcesContent":["import { DropzoneDirective, DraggableDirective, GesturableDirective, ResizableDirective } from '../directives';\nimport { Point, DragEvent, ResizeEvent, Interactable, DropEvent, GestureEvent } from '@interactjs/types';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { InjectionToken } from '@angular/core';\n\n\n\nexport type CssDimensionUnit = 'px' | 'em';\nexport interface InteractRootConfig {\n cssDimensionUnit: CssDimensionUnit;\n}\nexport const INTERACT_ROOT_CONFIG = new InjectionToken<InteractRootConfig>('INTERACT_ROOT_CONFIG_PARAMS');\n\nexport const DEFAULT_REGISTRY_ID = 'DEFAULT';\n/**\n * Default initial value for Delta BehaviorSubject\n */\nexport const defaultDelta: Delta = {\n deltaX: 0,\n deltaY: 0,\n targetElement: null\n};\n/**\n * Default initial value for Size BehaviorSubject\n */\nexport const defaultSize: Size = {\n width: null,\n height: null,\n targetElement: null\n}\n/**\n * Default initial value for Position BehaviorSubject\n */\nexport const defaultPosition: Position = {\n x: 0,\n y: 0,\n targetElement: null\n}\n/**\n * The shape of the state/events/behavior system for each dropzone\n * and the DEFAULT_REGISTRY_ID system (for drop components initialized outside\n * of a dropzone).\n */\nexport interface InteractableSystem {\n deltas$: BehaviorSubject<Delta>;\n position$: BehaviorSubject<Position>;\n size$: BehaviorSubject<Size & Delta>;\n\n interactable$: Observable<TftCoords>;\n}\n/**\n * The key map of InteractableSystems. One for the drag components\n * that originated outside of a dropzone, plus one for each dropzone.\n */\nexport interface InteractableRegistry {\n [key: string]: InteractableSystem\n}\n\n/**\n * HTMLElement with helpful drag directives attached to facilitate moving drag data between dropzones\n */\nexport type TftDragElement = HTMLElement & {\n dragRef?: DraggableDirective\n dragOrigin?: DropzoneDirective\n dropTarget?: DropzoneDirective\n}\n\n/**\n * HTMLElement with helpful drag directives attached to facilitate moving drag data between dropzones\n */\n export type TftResizeElement = HTMLElement & {\n resizeRef?: ResizableDirective\n}\n\n/**\n * Extends the interact drop events by adding reference to the dropped components drag\n * directive to the html element. This gives the dropzone access to things like data\n * and parent dropzone of the dropped component.\n */\nexport type NgDropEvent = DropEvent & {\n draggable: Interactable & {\n target: TftDragElement;\n };\n relatedTarget: TftDragElement;\n};\n/**\n * Extends the interact resize events by adding a reference to the dragRef\n * directive to the html element.\n */\nexport type NgResizeEvent = ResizeEvent & {\n draggable: Interactable & {\n target: TftDragElement;\n };\n};\n/**\n * We extend the interact DragEvent a little here, adding to the target element references for:\n * - the component we are dragging (dragRef)\n * - the dropzone component where the drag component originated (dragOrigin)\n * - the dropzone component that it was dropped in (dropTarget)\n * This helps us to pass references to directive classes as events like dragenter and drag exit happens.\n * We use these references to emit a (mostly) consistent event across drag, drop, resize event.\n */\nexport type NgDragEvent = DragEvent & {\n dropzone: { target: HTMLElement},\n target: TftDragElement\n};\n/**\n * Event emitted when resizing, dragging, dropping\n */\nexport interface TftInteractableEvent {\n dragRef: DraggableDirective;\n dragOrigin?: DropzoneDirective;\n dropTarget?: DropzoneDirective;\n positionInDropTarget: Point;\n}\n/**\n * Event emitted on drop\n */\nexport interface TftDropEvent extends TftInteractableEvent {\n interactEvent: NgDropEvent\n}\n/**\n * Event emitted on drag\n */\nexport interface TftDragEvent extends TftInteractableEvent {\n interactEvent: NgDragEvent\n}\n/**\n * Event emitted on resize\n */\nexport interface TftResizeEvent extends TftInteractableEvent {\n interactEvent: ResizeEvent,\n resizeRef: ResizableDirective\n}\n\nexport type TftCoords= Delta & Position & Size;\n\nexport interface Delta {\n deltaX: number | null;\n deltaY: number | null;\n targetElement: TftDragElement | null;\n}\n\nexport interface Position {\n x: number | null;\n y: number | null;\n targetElement: TftDragElement | null;\n}\n\nexport interface Size {\n width: number | null;\n height: number | null;\n targetElement: TftResizeElement | null;\n}\n\nexport interface TftGestureEvent {\n gestureRef: GesturableDirective;\n interactEvent: GestureEvent;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"CssDimensionUnit":{"__symbolic":"interface"},"InteractRootConfig":{"__symbolic":"interface"},"INTERACT_ROOT_CONFIG":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":11,"character":40},"arguments":["INTERACT_ROOT_CONFIG_PARAMS"]},"DEFAULT_REGISTRY_ID":"DEFAULT","defaultDelta":{"deltaX":0,"deltaY":0,"targetElement":null},"defaultSize":{"width":null,"height":null,"targetElement":null},"defaultPosition":{"x":0,"y":0,"targetElement":null},"InteractableSystem":{"__symbolic":"interface"},"InteractableRegistry":{"__symbolic":"interface"},"TftDragElement":{"__symbolic":"interface"},"TftResizeElement":{"__symbolic":"interface"},"NgDropEvent":{"__symbolic":"interface"},"NgResizeEvent":{"__symbolic":"interface"},"NgDragEvent":{"__symbolic":"interface"},"TftInteractableEvent":{"__symbolic":"interface"},"TftDropEvent":{"__symbolic":"interface"},"TftDragEvent":{"__symbolic":"interface"},"TftResizeEvent":{"__symbolic":"interface"},"TftCoords":{"__symbolic":"interface"},"Delta":{"__symbolic":"interface"},"Position":{"__symbolic":"interface"},"Size":{"__symbolic":"interface"},"TftGestureEvent":{"__symbolic":"interface"}}}]
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Pipe } from '@angular/core';
|
|
2
|
-
export class ArrayOfNPipe {
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param n the number to make an array of
|
|
6
|
-
* @param max the max length of the array (useful for limiting rendering in ngFor loop)
|
|
7
|
-
*/
|
|
8
|
-
transform(n, max) {
|
|
9
|
-
const length = ((max && max < n) || n === Infinity) ? max : n;
|
|
10
|
-
return new Array(length).fill(length).map((x, i) => i);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
ArrayOfNPipe.decorators = [
|
|
14
|
-
{ type: Pipe, args: [{
|
|
15
|
-
name: 'arrayOfN'
|
|
16
|
-
},] }
|
|
17
|
-
];
|
|
18
|
-
//# sourceMappingURL=array-of-n.pipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-of-n.pipe.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/pipes/array-of-n.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AAKpD,MAAM,OAAO,YAAY;IAEvB;;;;OAIG;IACH,SAAS,CAAC,CAAS,EAAE,GAAW;QAC9B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;;;YAbF,IAAI,SAAC;gBACJ,IAAI,EAAE,UAAU;aACjB","sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'arrayOfN'\n})\nexport class ArrayOfNPipe implements PipeTransform {\n\n /**\n * \n * @param n the number to make an array of \n * @param max the max length of the array (useful for limiting rendering in ngFor loop)\n */\n transform(n: number, max: number): any {\n const length = ((max && max < n) || n === Infinity) ? max : n;\n return new Array(length).fill(length).map((x,i)=> i); \n }\n\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"ArrayOfNPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe","line":2,"character":1},"arguments":[{"name":"arrayOfN"}]}],"members":{"transform":[{"__symbolic":"method"}]}}}}]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './array-of-n.pipe';"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./array-of-n.pipe"}]}]
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { Injectable, RendererFactory2, NgZone, Inject, Optional } from '@angular/core';
|
|
2
|
-
import { BehaviorSubject, combineLatest } from 'rxjs';
|
|
3
|
-
import { tap, map, shareReplay } from 'rxjs/operators';
|
|
4
|
-
import { defaultPosition, defaultSize, defaultDelta, DEFAULT_REGISTRY_ID, INTERACT_ROOT_CONFIG } from '../models';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
import * as i1 from "../models/interact";
|
|
7
|
-
export class InteractService {
|
|
8
|
-
constructor(rendererFactory, ngZone, rootConfig) {
|
|
9
|
-
this.rendererFactory = rendererFactory;
|
|
10
|
-
this.ngZone = ngZone;
|
|
11
|
-
this.rootConfig = rootConfig;
|
|
12
|
-
this._interactableIndex = 0;
|
|
13
|
-
this._dropzoneIndex = 0;
|
|
14
|
-
// TODO: consider using Map here
|
|
15
|
-
this.dragRegistrySystem = {};
|
|
16
|
-
this.cssUnit = 'px';
|
|
17
|
-
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
18
|
-
this.cssUnit = (rootConfig === null || rootConfig === void 0 ? void 0 : rootConfig.cssDimensionUnit) || 'px';
|
|
19
|
-
}
|
|
20
|
-
addDeltaToPosition(delta, position) {
|
|
21
|
-
return {
|
|
22
|
-
x: delta.deltaX + position.x,
|
|
23
|
-
y: delta.deltaY + position.y,
|
|
24
|
-
targetElement: position.targetElement || delta.targetElement
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
addRegistryToSystem(customRegistryId = null) {
|
|
28
|
-
const registryId = customRegistryId || this.createDropzoneId(this._dropzoneIndex++);
|
|
29
|
-
this.dragRegistrySystem[registryId] = {};
|
|
30
|
-
return registryId;
|
|
31
|
-
}
|
|
32
|
-
addDraggableToRegistry(customRegistryId = null, interactableId = null) {
|
|
33
|
-
const registryId = customRegistryId || DEFAULT_REGISTRY_ID;
|
|
34
|
-
// if we pass an id to createInteractableId then it is used when creating the interactable
|
|
35
|
-
// and returned, otherwise a an id is created for the draggable.
|
|
36
|
-
const key = this.createInteractableId(interactableId);
|
|
37
|
-
if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {
|
|
38
|
-
this.dragRegistrySystem[registryId] = {};
|
|
39
|
-
}
|
|
40
|
-
this.dragRegistrySystem[registryId][key] = this.createInteractableState(defaultPosition, defaultSize, defaultDelta);
|
|
41
|
-
return key;
|
|
42
|
-
}
|
|
43
|
-
destroyInteractable(interactableId, registryId = DEFAULT_REGISTRY_ID) {
|
|
44
|
-
if (this.dragRegistrySystem[registryId][interactableId]) {
|
|
45
|
-
delete this.dragRegistrySystem[registryId][interactableId];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
subscribeToInteractable(interactableId, registryId = DEFAULT_REGISTRY_ID) {
|
|
49
|
-
return this.dragRegistrySystem[registryId][interactableId];
|
|
50
|
-
}
|
|
51
|
-
createInteractableState(initialPosition, initialSize, initialDelta) {
|
|
52
|
-
const deltas$ = new BehaviorSubject(initialDelta);
|
|
53
|
-
// tracks the size of the element
|
|
54
|
-
const size$ = new BehaviorSubject(Object.assign(Object.assign({}, initialSize), initialDelta));
|
|
55
|
-
// Stream of positions as they change
|
|
56
|
-
const position$ = new BehaviorSubject(initialPosition);
|
|
57
|
-
// All draggable data mapped together
|
|
58
|
-
const interactable$ = combineLatest([
|
|
59
|
-
size$.pipe(
|
|
60
|
-
// startWith({...initialSize, ...initialDelta}),
|
|
61
|
-
shareReplay(1),
|
|
62
|
-
// filter(resizeEvent => !!resizeEvent.targetElement),
|
|
63
|
-
tap(({ deltaX, deltaY, width, height, targetElement }) => {
|
|
64
|
-
this.ngZone.runOutsideAngular(() => {
|
|
65
|
-
this.setElementSize(width, height, targetElement);
|
|
66
|
-
});
|
|
67
|
-
// only reposition if necessary i.e when resizing left or up
|
|
68
|
-
if (deltaX || deltaY) {
|
|
69
|
-
deltas$.next({ deltaX, deltaY, targetElement });
|
|
70
|
-
}
|
|
71
|
-
})),
|
|
72
|
-
deltas$.pipe(shareReplay(1), tap((delta) => {
|
|
73
|
-
const position = position$.value;
|
|
74
|
-
const newPosition = this.addDeltaToPosition(delta, position);
|
|
75
|
-
position$.next(newPosition);
|
|
76
|
-
})),
|
|
77
|
-
position$.pipe(shareReplay(1), tap(position => {
|
|
78
|
-
this.ngZone.runOutsideAngular(() => {
|
|
79
|
-
this.setElementTransform(position.x, position.y, position);
|
|
80
|
-
});
|
|
81
|
-
}))
|
|
82
|
-
]).pipe(shareReplay(1), map(([size, deltas, position]) => {
|
|
83
|
-
return {
|
|
84
|
-
x: position.x,
|
|
85
|
-
y: position.y,
|
|
86
|
-
deltaX: deltas.deltaX,
|
|
87
|
-
deltaY: deltas.deltaY,
|
|
88
|
-
width: size.width,
|
|
89
|
-
height: size.height,
|
|
90
|
-
targetElement: size.targetElement || position.targetElement || deltas.targetElement
|
|
91
|
-
};
|
|
92
|
-
}));
|
|
93
|
-
// TODO: update system to handle only returning interactable$
|
|
94
|
-
return {
|
|
95
|
-
deltas$,
|
|
96
|
-
position$,
|
|
97
|
-
size$,
|
|
98
|
-
interactable$
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
createInteractableId(customInteractableId = null) {
|
|
102
|
-
return customInteractableId || `interactable${this._interactableIndex++}`;
|
|
103
|
-
}
|
|
104
|
-
createDropzoneId(index) {
|
|
105
|
-
return `dropzone${index}`;
|
|
106
|
-
}
|
|
107
|
-
getInteractableState(interactableId, registryId = DEFAULT_REGISTRY_ID) {
|
|
108
|
-
return this.dragRegistrySystem[registryId][interactableId].interactable$;
|
|
109
|
-
}
|
|
110
|
-
updateDeltas(interactId, registryId, { deltaX, deltaY }, targetElement) {
|
|
111
|
-
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
112
|
-
return;
|
|
113
|
-
this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX, deltaY, targetElement });
|
|
114
|
-
}
|
|
115
|
-
updatePosition(interactId, registryId, { x, y }, targetElement) {
|
|
116
|
-
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
117
|
-
return;
|
|
118
|
-
this.dragRegistrySystem[registryId][interactId].position$.next({ x, y, targetElement });
|
|
119
|
-
}
|
|
120
|
-
updateSize(interactId, registryId, { deltaX, deltaY, width, height }, targetElement) {
|
|
121
|
-
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
122
|
-
return;
|
|
123
|
-
this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX, deltaY, width, height, targetElement });
|
|
124
|
-
}
|
|
125
|
-
interactableExistOnRegistry(interactId, registryId = DEFAULT_REGISTRY_ID) {
|
|
126
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
127
|
-
return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Uses renderer to set width and height of angular component
|
|
131
|
-
* @param width the desired width of component
|
|
132
|
-
* @param height the desired height of component
|
|
133
|
-
* @param target the element to transform
|
|
134
|
-
*/
|
|
135
|
-
setElementSize(width, height, target) {
|
|
136
|
-
var _a;
|
|
137
|
-
if (!target)
|
|
138
|
-
return;
|
|
139
|
-
const accountForScaleDirective = (_a = target.resizeRef) === null || _a === void 0 ? void 0 : _a.account_for_scale_dir;
|
|
140
|
-
if (accountForScaleDirective) {
|
|
141
|
-
const { scale } = accountForScaleDirective;
|
|
142
|
-
const scaledWidth = width / scale;
|
|
143
|
-
const scaledHeight = height / scale;
|
|
144
|
-
this.renderer.setStyle(target, 'width', `${scaledWidth}${this.cssUnit}`);
|
|
145
|
-
this.renderer.setStyle(target, 'height', `${scaledHeight}${this.cssUnit}`);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);
|
|
149
|
-
this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Uses renderer to set position of angular component
|
|
154
|
-
* @param x position on x axis
|
|
155
|
-
* @param y position on y axis
|
|
156
|
-
* @param target the element to transform
|
|
157
|
-
*/
|
|
158
|
-
setElementTransform(x, y, position) {
|
|
159
|
-
var _a, _b;
|
|
160
|
-
if (!(position === null || position === void 0 ? void 0 : position.targetElement))
|
|
161
|
-
return;
|
|
162
|
-
const dragRef = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef;
|
|
163
|
-
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);
|
|
164
|
-
if (accountForScaleDirective) {
|
|
165
|
-
const { scale } = accountForScaleDirective;
|
|
166
|
-
this.renderer.setStyle(position.targetElement, 'left', `${x / scale}${this.cssUnit}`);
|
|
167
|
-
this.renderer.setStyle(position.targetElement, 'top', `${y / scale}${this.cssUnit}`);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);
|
|
171
|
-
this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Generates a translate string for the x and y arguments passed to
|
|
176
|
-
* be passed to css transform
|
|
177
|
-
* @param x the position along the x axis
|
|
178
|
-
* @param y the position along the y axis
|
|
179
|
-
*/
|
|
180
|
-
createTransformString(x, y) {
|
|
181
|
-
return `translate3d(${x}${this.cssUnit}, ${y}${this.cssUnit}, 0)`;
|
|
182
|
-
}
|
|
183
|
-
calculatePositionInElement(zoneElement, dragElement, scale) {
|
|
184
|
-
// TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
|
|
185
|
-
const zoneRect = zoneElement.getBoundingClientRect();
|
|
186
|
-
const dragRect = dragElement.getBoundingClientRect();
|
|
187
|
-
const position = scale
|
|
188
|
-
? {
|
|
189
|
-
x: (dragRect.left - zoneRect.left) / scale || 1,
|
|
190
|
-
y: (dragRect.top - zoneRect.top) / scale || 1
|
|
191
|
-
} : {
|
|
192
|
-
x: dragRect.left - zoneRect.left,
|
|
193
|
-
y: dragRect.top - zoneRect.top
|
|
194
|
-
};
|
|
195
|
-
// console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
|
|
196
|
-
return position;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
InteractService.ɵprov = i0.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i1.INTERACT_ROOT_CONFIG, 8)); }, token: InteractService, providedIn: "root" });
|
|
200
|
-
InteractService.decorators = [
|
|
201
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
202
|
-
];
|
|
203
|
-
InteractService.ctorParameters = () => [
|
|
204
|
-
{ type: RendererFactory2 },
|
|
205
|
-
{ type: NgZone },
|
|
206
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INTERACT_ROOT_CONFIG,] }] }
|
|
207
|
-
];
|
|
208
|
-
//# sourceMappingURL=interact.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interact.service.js","sourceRoot":"","sources":["../../../../../../libs/interact/src/lib/services/interact.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAa,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAkB,QAAQ,EAAiB,MAAM,eAAe,CAAC;AACjI,OAAO,EAAE,eAAe,EAAc,aAAa,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAEL,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAoC,oBAAoB,EACxH,MAAM,WAAW,CAAC;;;AAKnB,MAAM,OAAO,eAAe;IAS1B,YACU,eAAiC,EACjC,MAAc,EAC2B,UAAU;QAFnD,oBAAe,GAAf,eAAe,CAAkB;QACjC,WAAM,GAAN,MAAM,CAAQ;QAC2B,eAAU,GAAV,UAAU,CAAA;QAVrD,uBAAkB,GAAG,CAAC,CAAC;QACvB,mBAAc,GAAG,CAAC,CAAC;QAG3B,gCAAgC;QACvB,uBAAkB,GAA4C,EAAG,CAAC;QACnE,YAAO,GAAG,IAAI,CAAA;QAMpB,IAAI,CAAC,QAAQ,G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rG,MAAM,QAAQ,GAAG,WAAW,CAAC,qBAAqB,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,WAAW,CAAC,qBAAqB,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,KAAK;YACpB,CAAC,CAAC;gBACF,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,IAAK,CAAC;gBAChD,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC;aAC5C,CAAC,CAAC,CAAC;YACF,CAAC,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI;YAChC,CAAC,EAAE,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG;SACjC,CAAC;QACF,oEAAoE;QACpE,OAAO,QAAQ,CAAC;IAClB,CAAC;;;;YApNF,UAAU,SAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;;YAVA,gBAAgB;YAAE,MAAM;4CAuBnD,QAAQ,YAAI,MAAM,SAAC,oBAAoB","sourcesContent":["\nimport { Injectable, Renderer2, RendererFactory2, NgZone, Inject, InjectionToken, Optional, AfterViewInit } from '@angular/core';\nimport { BehaviorSubject, Observable, combineLatest } from 'rxjs';\nimport { tap, map, shareReplay } from 'rxjs/operators';\nimport {\n TftCoords, Delta, Size, Position, InteractableRegistry,\n defaultPosition, defaultSize, defaultDelta, DEFAULT_REGISTRY_ID, TftDragElement, TftResizeElement, INTERACT_ROOT_CONFIG, InteractRootConfig\n} from '../models';\n\n\n\n@Injectable({providedIn: 'root'})\nexport class InteractService {\n\n private _interactableIndex = 0;\n private _dropzoneIndex = 0;\n private renderer: Renderer2;\n\n // TODO: consider using Map here\n readonly dragRegistrySystem: { [key: string]: InteractableRegistry } = { };\n private cssUnit = 'px'\n constructor(\n private rendererFactory: RendererFactory2,\n private ngZone: NgZone,\n @Optional() @Inject(INTERACT_ROOT_CONFIG) public rootConfig\n ) {\n this.renderer = this.rendererFactory.createRenderer(null, null);\n this.cssUnit = rootConfig?.cssDimensionUnit || 'px';\n }\n\n addDeltaToPosition(delta: Delta, position: Position) {\n return {\n x: delta.deltaX + position.x,\n y: delta.deltaY + position.y,\n targetElement: position.targetElement || delta.targetElement\n }\n }\n\n addRegistryToSystem(customRegistryId: string | null = null) {\n const registryId = customRegistryId || this.createDropzoneId(this._dropzoneIndex++);\n this.dragRegistrySystem[registryId] = {};\n return registryId;\n }\n\n addDraggableToRegistry(customRegistryId = null, interactableId: string | null = null ) {\n const registryId = customRegistryId || DEFAULT_REGISTRY_ID;\n // if we pass an id to createInteractableId then it is used when creating the interactable\n // and returned, otherwise a an id is created for the draggable.\n const key = this.createInteractableId(interactableId );\n if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {\n this.dragRegistrySystem[registryId] = {};\n }\n this.dragRegistrySystem[registryId][key] = this.createInteractableState(defaultPosition, defaultSize, defaultDelta);\n return key\n }\n\n destroyInteractable(interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n if(this.dragRegistrySystem[registryId][interactableId]) {\n delete this.dragRegistrySystem[registryId][interactableId];\n }\n }\n\n subscribeToInteractable(interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n return this.dragRegistrySystem[registryId][interactableId];\n }\n\n createInteractableState(initialPosition: Position, initialSize: Size, initialDelta: Delta ) {\n\n const deltas$ = new BehaviorSubject(initialDelta);\n // tracks the size of the element\n const size$ = new BehaviorSubject({...initialSize, ...initialDelta});\n // Stream of positions as they change\n const position$ = new BehaviorSubject(initialPosition);\n\n // All draggable data mapped together\n const interactable$: Observable<TftCoords> = combineLatest([\n size$.pipe(\n // startWith({...initialSize, ...initialDelta}),\n shareReplay(1),\n // filter(resizeEvent => !!resizeEvent.targetElement),\n tap(({deltaX, deltaY, width, height, targetElement}) => {\n this.ngZone.runOutsideAngular(() => {\n this.setElementSize(width, height, targetElement);\n });\n // only reposition if necessary i.e when resizing left or up\n if(deltaX || deltaY) {\n deltas$.next({deltaX, deltaY, targetElement});\n }\n })\n ),\n deltas$.pipe(\n shareReplay(1),\n tap((delta) => {\n const position = position$.value;\n const newPosition = this.addDeltaToPosition(delta, position);\n position$.next(newPosition);\n })\n ),\n position$.pipe(\n shareReplay(1),\n tap( position => {\n this.ngZone.runOutsideAngular(() => {\n this.setElementTransform(position.x, position.y, position);\n })\n })\n )\n ]).pipe(\n shareReplay(1),\n map( ([size, deltas, position]): TftCoords=> {\n return {\n x: position.x,\n y: position.y,\n deltaX: deltas.deltaX,\n deltaY: deltas.deltaY,\n width: size.width,\n height: size.height,\n targetElement: size.targetElement || position.targetElement || deltas.targetElement\n }\n }),\n )\n // TODO: update system to handle only returning interactable$\n return {\n deltas$,\n position$,\n size$,\n interactable$\n }\n }\n\n createInteractableId(customInteractableId: string | null = null) {\n return customInteractableId || `interactable${this._interactableIndex++}`\n }\n\n createDropzoneId(index: number) {\n return `dropzone${index}`\n }\n\n getInteractableState( interactableId: string, registryId = DEFAULT_REGISTRY_ID) {\n return this.dragRegistrySystem[registryId][interactableId].interactable$;\n }\n\n updateDeltas(interactId: string, registryId: string, { deltaX, deltaY }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return;\n this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX, deltaY, targetElement })\n }\n\n updatePosition(interactId: string, registryId: string, { x, y }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return;\n this.dragRegistrySystem[registryId][interactId].position$.next({ x, y, targetElement })\n }\n\n updateSize(interactId: string, registryId: string, { deltaX, deltaY, width, height }, targetElement) {\n if (!this.interactableExistOnRegistry(interactId, registryId)) return\n this.dragRegistrySystem[registryId][interactId].size$.next({deltaX, deltaY, width, height, targetElement});\n }\n\n interactableExistOnRegistry(interactId: string, registryId = DEFAULT_REGISTRY_ID) {\n // eslint-disable-next-line no-prototype-builtins\n return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);\n }\n /**\n * Uses renderer to set width and height of angular component\n * @param width the desired width of component\n * @param height the desired height of component\n * @param target the element to transform\n */\n setElementSize(width: number, height: number, target: TftResizeElement) {\n if(!target) return;\n const accountForScaleDirective = target.resizeRef?.account_for_scale_dir\n if (accountForScaleDirective) {\n const { scale } = accountForScaleDirective\n const scaledWidth = width / scale;\n const scaledHeight = height / scale;\n this.renderer.setStyle(target, 'width', `${scaledWidth}${this.cssUnit}`);\n this.renderer.setStyle(target, 'height', `${scaledHeight}${this.cssUnit}`);\n } else {\n this.renderer.setStyle(target, 'width', `${width}${this.cssUnit}`);\n this.renderer.setStyle(target, 'height', `${height}${this.cssUnit}`);\n }\n }\n /**\n * Uses renderer to set position of angular component\n * @param x position on x axis\n * @param y position on y axis\n * @param target the element to transform\n */\n setElementTransform(x: number, y: number, position: Position ) {\n if(!position?.targetElement) return;\n const dragRef = position.targetElement?.dragRef;\n const accountForScaleDirective = dragRef?.account_for_scale_dir || dragRef?.dragRoot?.account_for_scale_dir\n if (accountForScaleDirective) {\n const {scale} = accountForScaleDirective;\n this.renderer.setStyle(position.targetElement, 'left', `${x / scale}${this.cssUnit}`);\n this.renderer.setStyle(position.targetElement, 'top', `${y / scale}${this.cssUnit}`);\n } else {\n this.renderer.setStyle(position.targetElement, 'left', `${x}${this.cssUnit}`);\n this.renderer.setStyle(position.targetElement, 'top', `${y}${this.cssUnit}`);\n }\n }\n /**\n * Generates a translate string for the x and y arguments passed to\n * be passed to css transform\n * @param x the position along the x axis\n * @param y the position along the y axis\n */\n createTransformString(x: number, y: number) {\n return `translate3d(${x}${this.cssUnit}, ${y}${this.cssUnit}, 0)`\n }\n\n calculatePositionInElement(zoneElement: Interact.Element, dragElement: TftDragElement, scale?: number) {\n // TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements\n const zoneRect = zoneElement.getBoundingClientRect();\n const dragRect = dragElement.getBoundingClientRect();\n const position = scale\n ? {\n x: (dragRect.left - zoneRect.left) / scale || 1,\n y: (dragRect.top - zoneRect.top) / scale || 1\n } : {\n x: dragRect.left - zoneRect.left,\n y: dragRect.top - zoneRect.top\n };\n // console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})\n return position;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"InteractService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":11,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":24,"character":5}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":24,"character":17},"arguments":[{"__symbolic":"reference","module":"../models","name":"INTERACT_ROOT_CONFIG","line":24,"character":24}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"RendererFactory2","line":22,"character":29},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":23,"character":20},null]}],"addDeltaToPosition":[{"__symbolic":"method"}],"addRegistryToSystem":[{"__symbolic":"method"}],"addDraggableToRegistry":[{"__symbolic":"method"}],"destroyInteractable":[{"__symbolic":"method"}],"subscribeToInteractable":[{"__symbolic":"method"}],"createInteractableState":[{"__symbolic":"method"}],"createInteractableId":[{"__symbolic":"method"}],"createDropzoneId":[{"__symbolic":"method"}],"getInteractableState":[{"__symbolic":"method"}],"updateDeltas":[{"__symbolic":"method"}],"updatePosition":[{"__symbolic":"method"}],"updateSize":[{"__symbolic":"method"}],"interactableExistOnRegistry":[{"__symbolic":"method"}],"setElementSize":[{"__symbolic":"method"}],"setElementTransform":[{"__symbolic":"method"}],"createTransformString":[{"__symbolic":"method"}],"calculatePositionInElement":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}}}]
|