gridstack 7.2.2 → 7.3.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/LICENSE +2 -10
- package/README.md +17 -17
- package/dist/angular/README.md +6 -5
- package/dist/angular/gridstack-item.component.ts +21 -5
- package/dist/angular/gridstack.component.ts +59 -46
- package/dist/dd-base-impl.d.ts +1 -1
- package/dist/dd-base-impl.js +1 -1
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +1 -1
- package/dist/dd-draggable.js +4 -5
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +1 -1
- package/dist/dd-droppable.js +1 -1
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +1 -1
- package/dist/dd-element.js +1 -1
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +1 -1
- package/dist/dd-gridstack.js +1 -1
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +1 -1
- package/dist/dd-manager.js +1 -1
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +1 -1
- package/dist/dd-resizable-handle.js +1 -1
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +1 -1
- package/dist/dd-resizable.js +1 -1
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +1 -1
- package/dist/dd-touch.js +2 -1
- package/dist/dd-touch.js.map +1 -1
- package/dist/es5/dd-base-impl.d.ts +1 -1
- package/dist/es5/dd-base-impl.js +1 -1
- package/dist/es5/dd-base-impl.js.map +1 -1
- package/dist/es5/dd-draggable.d.ts +1 -1
- package/dist/es5/dd-draggable.js +4 -5
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +1 -1
- package/dist/es5/dd-droppable.js +1 -1
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +1 -1
- package/dist/es5/dd-element.js +1 -1
- package/dist/es5/dd-element.js.map +1 -1
- package/dist/es5/dd-gridstack.d.ts +1 -1
- package/dist/es5/dd-gridstack.js +1 -1
- package/dist/es5/dd-gridstack.js.map +1 -1
- package/dist/es5/dd-manager.d.ts +1 -1
- package/dist/es5/dd-manager.js +1 -1
- package/dist/es5/dd-manager.js.map +1 -1
- package/dist/es5/dd-resizable-handle.d.ts +1 -1
- package/dist/es5/dd-resizable-handle.js +1 -1
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +1 -1
- package/dist/es5/dd-resizable.js +1 -1
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +1 -1
- package/dist/es5/dd-touch.js +2 -1
- package/dist/es5/dd-touch.js.map +1 -1
- package/dist/es5/gridstack-all.js +1 -1
- package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-all.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +5 -3
- package/dist/es5/gridstack-engine.js +38 -19
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +1 -1
- package/dist/es5/gridstack.js +43 -35
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +14 -7
- package/dist/es5/types.js +2 -2
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +4 -2
- package/dist/es5/utils.js +5 -2
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack-engine.d.ts +5 -3
- package/dist/gridstack-engine.js +36 -18
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/gridstack.d.ts +1 -1
- package/dist/gridstack.js +43 -35
- package/dist/gridstack.js.map +1 -1
- package/dist/src/gridstack.scss +1 -1
- package/dist/types.d.ts +14 -7
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +4 -2
- package/dist/utils.js +5 -2
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +12 -0
- package/doc/README.md +4 -1
- package/package.json +9 -9
package/LICENSE
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
under MIT license
|
|
1
|
+
MIT License
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* https://gridstackjs.com/
|
|
7
|
-
* (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov
|
|
8
|
-
* gridstack.js may be freely distributed under the MIT license.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
The MIT License (MIT)
|
|
3
|
+
Copyright (c) 2019-2023 Alain Dumesny. v0.4.0 and older (c) 2014-2018 Pavel Reznikov, Dylan Weiss
|
|
12
4
|
|
|
13
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://coveralls.io/github/gridstack/gridstack.js?branch=develop)
|
|
5
5
|
[](https://www.npmjs.com/package/gridstack)
|
|
6
6
|
|
|
7
|
-
Mobile-friendly modern Typescript library for dashboard layout and creation. Making a drag-and-drop, multi-column responsive dashboard has never been easier. Has multiple bindings and works great with [React](https://reactjs.org/), [Vue](https://vuejs.org/), [Angular](https://angular.io/), [Knockout.js](http://knockoutjs.com), [Ember](https://www.emberjs.com/) and others (see [frameworks](#
|
|
7
|
+
Mobile-friendly modern Typescript library for dashboard layout and creation. Making a drag-and-drop, multi-column responsive dashboard has never been easier. Has multiple bindings and works great with [React](https://reactjs.org/), [Vue](https://vuejs.org/), [Angular](https://angular.io/), [Knockout.js](http://knockoutjs.com), [Ember](https://www.emberjs.com/) and others (see [frameworks](#specific-frameworks) section).
|
|
8
8
|
|
|
9
9
|
Inspired by no-longer maintained gridster, built with love.
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ If you find this lib useful, please donate [PayPal](https://www.paypal.me/alaind
|
|
|
15
15
|
[](https://www.paypal.me/alaind831)
|
|
16
16
|
[](https://www.venmo.com/adumesny)
|
|
17
17
|
|
|
18
|
-
Join us on Slack: https://gridstackjs.slack.com
|
|
18
|
+
Join us on Slack: [https://gridstackjs.slack.com](https://join.slack.com/t/gridstackjs/shared_invite/zt-1jobnclsy-FqGGeLX5dFPM_ZQzTunBsw)
|
|
19
19
|
|
|
20
20
|
<!-- [](https://gridstackjs.slack.com) -->
|
|
21
21
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
@@ -28,13 +28,13 @@ Join us on Slack: https://gridstackjs.slack.com
|
|
|
28
28
|
- [Include](#include)
|
|
29
29
|
- [Basic usage](#basic-usage)
|
|
30
30
|
- [Requirements](#requirements)
|
|
31
|
+
- [Specific frameworks](#specific-frameworks)
|
|
31
32
|
- [Extend Library](#extend-library)
|
|
32
33
|
- [Extend Engine](#extend-engine)
|
|
33
34
|
- [Change grid columns](#change-grid-columns)
|
|
34
35
|
- [Custom columns CSS](#custom-columns-css)
|
|
35
36
|
- [Override resizable/draggable options](#override-resizabledraggable-options)
|
|
36
37
|
- [Touch devices support](#touch-devices-support)
|
|
37
|
-
- [gridstack.js for specific frameworks](#gridstackjs-for-specific-frameworks)
|
|
38
38
|
- [Migrating](#migrating)
|
|
39
39
|
- [Migrating to v0.6](#migrating-to-v06)
|
|
40
40
|
- [Migrating to v1](#migrating-to-v1)
|
|
@@ -142,6 +142,20 @@ see [jsfiddle sample](https://jsfiddle.net/adumesny/jqhkry7g) as running example
|
|
|
142
142
|
|
|
143
143
|
GridStack no longer requires external dependencies as of v1.0.0 (lodash was removed in v0.5.0 and jquery API in v1.0.0). v3 is a complete HTML5 re-write removing need for jquery (still available for legacy apps). v6 is native mouse and touch event for mobile support, and no longer have jquery-ui version. All you need to include now is `gridstack-all.js` and `gridstack.min.css` (layouts are done using CSS column based %).
|
|
144
144
|
|
|
145
|
+
## Specific frameworks
|
|
146
|
+
|
|
147
|
+
search for ['gridstack' under NPM](https://www.npmjs.com/search?q=gridstack&ranking=popularity) for latest, more to come...
|
|
148
|
+
|
|
149
|
+
- **Angular**: we now ship out of the box with Angular wrapper components - see <a href="https://github.com/gridstack/gridstack.js/tree/master/demo/angular/src/app" target="_blank">Angular Demo</a>.
|
|
150
|
+
- **Angular9**: [lb-gridstack](https://github.com/pfms84/lb-gridstack) Note: very old v0.3 gridstack instance so recommend for **concept ONLY if you wish to use directive instead**.
|
|
151
|
+
- **AngularJS**: [gridstack-angular](https://github.com/kdietrich/gridstack-angular)
|
|
152
|
+
- **Ember**: [ember-gridstack](https://github.com/yahoo/ember-gridstack)
|
|
153
|
+
- **knockout**: see [demo](https://gridstackjs.com/demo/knockout.html) using component, but check [custom bindings ticket](https://github.com/gridstack/gridstack.js/issues/465) which is likely better approach.
|
|
154
|
+
- **Rails**: [gridstack-js-rails](https://github.com/randoum/gridstack-js-rails)
|
|
155
|
+
- **React**: see [demo](https://gridstackjs.com/demo/react.html) with [src](https://github.com/gridstack/gridstack.js/tree/master/demo/react.html), or [react-gridstack-example](https://github.com/Inder2108/react-gridstack-example/tree/master/src/App.js), or read on what [hooks to use](https://github.com/gridstack/gridstack.js/issues/735#issuecomment-329888796)
|
|
156
|
+
- **Vue**: see [demo](https://gridstackjs.com/demo/vue3js.html) with [v3 src](https://github.com/gridstack/gridstack.js/tree/master/demo/vue3js.html) or [v2 src](https://github.com/gridstack/gridstack.js/tree/master/demo/vue2js.html)
|
|
157
|
+
- **Aurelia**: [aurelia-gridstack](https://github.com/aurelia-ui-toolkits/aurelia-gridstack), see [demo](https://aurelia-ui-toolkits.github.io/aurelia-gridstack/)
|
|
158
|
+
|
|
145
159
|
## Extend Library
|
|
146
160
|
|
|
147
161
|
You can easily extend or patch gridstack with code like this:
|
|
@@ -289,20 +303,6 @@ GridStack.init(options);
|
|
|
289
303
|
|
|
290
304
|
See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html).
|
|
291
305
|
|
|
292
|
-
# gridstack.js for specific frameworks
|
|
293
|
-
|
|
294
|
-
search for ['gridstack' under NPM](https://www.npmjs.com/search?q=gridstack&ranking=popularity) for latest, more to come...
|
|
295
|
-
|
|
296
|
-
- **Angular**: we now ship out of the box with Angular wrapper components - see <a href="https://github.com/gridstack/gridstack.js/tree/master/demo/angular/src/app" target="_blank">Angular Demo</a>.
|
|
297
|
-
- **Angular9**: [lb-gridstack](https://github.com/pfms84/lb-gridstack) Note: very old v0.3 gridstack instance so recommend for **concept ONLY if you wish to use directive instead**.
|
|
298
|
-
- **AngularJS**: [gridstack-angular](https://github.com/kdietrich/gridstack-angular)
|
|
299
|
-
- **Ember**: [ember-gridstack](https://github.com/yahoo/ember-gridstack)
|
|
300
|
-
- **knockout**: see [demo](https://gridstackjs.com/demo/knockout.html) using component, but check [custom bindings ticket](https://github.com/gridstack/gridstack.js/issues/465) which is likely better approach.
|
|
301
|
-
- **Rails**: [gridstack-js-rails](https://github.com/randoum/gridstack-js-rails)
|
|
302
|
-
- **React**: see [demo](https://gridstackjs.com/demo/react.html) with [src](https://github.com/gridstack/gridstack.js/tree/master/demo/react.html), or [react-gridstack-example](https://github.com/Inder2108/react-gridstack-example/tree/master/src/App.js), or read on what [hooks to use](https://github.com/gridstack/gridstack.js/issues/735#issuecomment-329888796)
|
|
303
|
-
- **Vue**: see [demo](https://gridstackjs.com/demo/vue3js.html) with [v3 src](https://github.com/gridstack/gridstack.js/tree/master/demo/vue3js.html) or [v2 src](https://github.com/gridstack/gridstack.js/tree/master/demo/vue2js.html)
|
|
304
|
-
- **Aurelia**: [aurelia-gridstack](https://github.com/aurelia-ui-toolkits/aurelia-gridstack), see [demo](https://aurelia-ui-toolkits.github.io/aurelia-gridstack/)
|
|
305
|
-
|
|
306
306
|
# Migrating
|
|
307
307
|
## Migrating to v0.6
|
|
308
308
|
|
package/dist/angular/README.md
CHANGED
|
@@ -9,7 +9,7 @@ I.E. don't use Angular templating to create children as that is harder to sync.
|
|
|
9
9
|
|
|
10
10
|
Code
|
|
11
11
|
|
|
12
|
-
```
|
|
12
|
+
```javascript
|
|
13
13
|
import { GridStackOptions, GridStackWidget } from 'gridstack';
|
|
14
14
|
import { GridstackComponent, nodesCB } from './gridstack.component';
|
|
15
15
|
|
|
@@ -30,8 +30,8 @@ public onChange(data: nodesCB) {
|
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
HTML
|
|
33
|
-
```
|
|
34
|
-
<gridstack [options]="gridOptions" (
|
|
33
|
+
```html
|
|
34
|
+
<gridstack [options]="gridOptions" (changeCB)="onChange($event)">
|
|
35
35
|
</gridstack>
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -40,7 +40,7 @@ For simple case where you control the children creation (gridstack doesn't do cr
|
|
|
40
40
|
|
|
41
41
|
Code
|
|
42
42
|
|
|
43
|
-
```
|
|
43
|
+
```javascript
|
|
44
44
|
import { GridStackOptions, GridStackWidget } from 'gridstack';
|
|
45
45
|
import { GridstackComponent, nodesCB } from './gridstack.component';
|
|
46
46
|
|
|
@@ -66,7 +66,7 @@ public identify(index: number, w: GridStackWidget) {
|
|
|
66
66
|
}
|
|
67
67
|
```
|
|
68
68
|
HTML
|
|
69
|
-
```
|
|
69
|
+
```html
|
|
70
70
|
<gridstack [options]="gridOptions" (changeCB)="onChange($event)">
|
|
71
71
|
<gridstack-item *ngFor="let n of items; trackBy: identify" [options]="n">
|
|
72
72
|
Item {{n.id}}
|
|
@@ -83,6 +83,7 @@ to build the demo, go to demo/angular and run `yarn` + `yarn start` and Navigate
|
|
|
83
83
|
|
|
84
84
|
- This wrapper needs v7.2+ to run as it needs the latest changes
|
|
85
85
|
- Code isn't compiled into a lib YET. You'll need to copy those files. Let me know (slack) if you are using it...
|
|
86
|
+
- BUG: content doesn't appear on new widget until widget is moved around (or another created that pushes it). Need to force angular detection changes...
|
|
86
87
|
|
|
87
88
|
## ngFor Caveats
|
|
88
89
|
- This wrapper handles well ngFor loops, but if you're using a trackBy function (as I would recommend) and no element id change after an update,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack-item.component.ts 7.
|
|
2
|
+
* gridstack-item.component.ts 7.3.0
|
|
3
3
|
* Copyright (c) 2022 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ChangeDetectionStrategy, Component, ElementRef, Input } from '@angular/core';
|
|
6
|
+
import { ChangeDetectionStrategy, Component, ElementRef, Input, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core';
|
|
7
7
|
import { GridItemHTMLElement, GridStackNode } from 'gridstack';
|
|
8
8
|
|
|
9
|
+
/** store element to Ng Class pointer back */
|
|
10
|
+
export interface GridItemCompHTMLElement extends GridItemHTMLElement {
|
|
11
|
+
_gridItemComp?: GridstackItemComponent;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* HTML Component Wrapper for gridstack items, in combination with GridstackComponent for parent grid
|
|
11
16
|
*/
|
|
@@ -13,15 +18,21 @@ import { GridItemHTMLElement, GridStackNode } from 'gridstack';
|
|
|
13
18
|
selector: 'gridstack-item',
|
|
14
19
|
template: `
|
|
15
20
|
<div class="grid-stack-item-content">
|
|
21
|
+
<!-- this is where you would create the right component based on some internal type or id. doing .content for demo purpose -->
|
|
16
22
|
{{options.content}}
|
|
17
23
|
<ng-content></ng-content>
|
|
24
|
+
<!-- where dynamic items go (like sub-grids) -->
|
|
25
|
+
<ng-template #container></ng-template>
|
|
18
26
|
</div>`,
|
|
19
27
|
styles: [`
|
|
20
28
|
:host { display: block; }
|
|
21
29
|
`],
|
|
22
30
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
23
31
|
})
|
|
24
|
-
export class GridstackItemComponent {
|
|
32
|
+
export class GridstackItemComponent implements OnDestroy {
|
|
33
|
+
|
|
34
|
+
/** container to append items dynamically */
|
|
35
|
+
@ViewChild('container', { read: ViewContainerRef, static: true}) public container?: ViewContainerRef;
|
|
25
36
|
|
|
26
37
|
/** list of options for creating/updating this item */
|
|
27
38
|
@Input() public set options(val: GridStackNode) {
|
|
@@ -36,13 +47,13 @@ export class GridstackItemComponent {
|
|
|
36
47
|
}
|
|
37
48
|
/** return the latest grid options (from GS once built, otherwise initial values) */
|
|
38
49
|
public get options(): GridStackNode {
|
|
39
|
-
return this.el.gridstackNode || this._options || {};
|
|
50
|
+
return this.el.gridstackNode || this._options || {el: this.el};
|
|
40
51
|
}
|
|
41
52
|
|
|
42
53
|
private _options?: GridStackNode;
|
|
43
54
|
|
|
44
55
|
/** return the native element that contains grid specific fields as well */
|
|
45
|
-
public get el():
|
|
56
|
+
public get el(): GridItemCompHTMLElement { return this.elementRef.nativeElement; }
|
|
46
57
|
|
|
47
58
|
/** clears the initial options now that we've built */
|
|
48
59
|
public clearOptions() {
|
|
@@ -50,5 +61,10 @@ export class GridstackItemComponent {
|
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
constructor(private readonly elementRef: ElementRef<GridItemHTMLElement>) {
|
|
64
|
+
this.el._gridItemComp = this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public ngOnDestroy(): void {
|
|
68
|
+
delete this.el._gridItemComp;
|
|
53
69
|
}
|
|
54
70
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack.component.ts 7.
|
|
2
|
+
* gridstack.component.ts 7.3.0
|
|
3
3
|
* Copyright (c) 2022 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { AfterContentInit, ChangeDetectionStrategy, Component,
|
|
6
|
+
import { AfterContentInit, ChangeDetectionStrategy, Component, ContentChildren, ElementRef, EventEmitter, Input,
|
|
7
7
|
NgZone, OnDestroy, OnInit, Output, QueryList, ViewChild, ViewContainerRef } from '@angular/core';
|
|
8
8
|
import { Subject } from 'rxjs';
|
|
9
9
|
import { takeUntil } from 'rxjs/operators';
|
|
10
|
-
import {
|
|
10
|
+
import { GridHTMLElement, GridItemHTMLElement, GridStack, GridStackNode, GridStackOptions, GridStackWidget } from 'gridstack';
|
|
11
11
|
|
|
12
|
-
import { GridstackItemComponent } from './gridstack-item.component';
|
|
12
|
+
import { GridItemCompHTMLElement, GridstackItemComponent } from './gridstack-item.component';
|
|
13
13
|
|
|
14
14
|
/** events handlers emitters signature for different events */
|
|
15
15
|
export type eventCB = {event: Event};
|
|
@@ -17,6 +17,11 @@ export type elementCB = {event: Event, el: GridItemHTMLElement};
|
|
|
17
17
|
export type nodesCB = {event: Event, nodes: GridStackNode[]};
|
|
18
18
|
export type droppedCB = {event: Event, previousNode: GridStackNode, newNode: GridStackNode};
|
|
19
19
|
|
|
20
|
+
/** store element to Ng Class pointer back */
|
|
21
|
+
export interface GridCompHTMLElement extends GridHTMLElement {
|
|
22
|
+
_gridComp?: GridstackComponent;
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
/**
|
|
21
26
|
* HTML Component Wrapper for gridstack, in combination with GridstackItemComponent for the items
|
|
22
27
|
*/
|
|
@@ -24,7 +29,7 @@ export type droppedCB = {event: Event, previousNode: GridStackNode, newNode: Gri
|
|
|
24
29
|
selector: 'gridstack',
|
|
25
30
|
template: `
|
|
26
31
|
<!-- content to show when when grid is empty, like instructions on how to add widgets -->
|
|
27
|
-
<ng-content select="[
|
|
32
|
+
<ng-content select="[empty-content]" *ngIf="isEmpty"></ng-content>
|
|
28
33
|
<!-- where dynamic items go -->
|
|
29
34
|
<ng-template #container></ng-template>
|
|
30
35
|
<!-- where template items go -->
|
|
@@ -48,27 +53,30 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
|
48
53
|
public get options(): GridStackOptions { return this._grid?.opts || this._options || {}; }
|
|
49
54
|
|
|
50
55
|
/** true while ng-content with 'no-item-content' should be shown when last item is removed from a grid */
|
|
51
|
-
@Input() public
|
|
56
|
+
@Input() public isEmpty?: boolean;
|
|
52
57
|
|
|
53
58
|
/** individual list of GridStackEvent callbacks handlers as output
|
|
54
59
|
* otherwise use this.grid.on('name1 name2 name3', callback) to handle multiple at once
|
|
55
60
|
* see https://github.com/gridstack/gridstack.js/blob/master/demo/events.js#L4
|
|
61
|
+
*
|
|
62
|
+
* Note: camel casing and 'CB' added at the end to prevent @angular-eslint/no-output-native
|
|
63
|
+
* eg: 'change' would trigger the raw CustomEvent so use different name.
|
|
56
64
|
*/
|
|
57
|
-
@Output() public
|
|
58
|
-
@Output() public
|
|
59
|
-
@Output() public
|
|
60
|
-
@Output() public
|
|
61
|
-
@Output() public
|
|
62
|
-
@Output() public
|
|
63
|
-
@Output() public
|
|
64
|
-
@Output() public
|
|
65
|
-
@Output() public
|
|
66
|
-
@Output() public
|
|
67
|
-
@Output() public
|
|
68
|
-
@Output() public
|
|
65
|
+
@Output() public addedCB = new EventEmitter<nodesCB>();
|
|
66
|
+
@Output() public changeCB = new EventEmitter<nodesCB>();
|
|
67
|
+
@Output() public disableCB = new EventEmitter<eventCB>();
|
|
68
|
+
@Output() public dragCB = new EventEmitter<elementCB>();
|
|
69
|
+
@Output() public dragStartCB = new EventEmitter<elementCB>();
|
|
70
|
+
@Output() public dragStopCB = new EventEmitter<elementCB>();
|
|
71
|
+
@Output() public droppedCB = new EventEmitter<droppedCB>();
|
|
72
|
+
@Output() public enableCB = new EventEmitter<eventCB>();
|
|
73
|
+
@Output() public removedCB = new EventEmitter<nodesCB>();
|
|
74
|
+
@Output() public resizeCB = new EventEmitter<elementCB>();
|
|
75
|
+
@Output() public resizeStartCB = new EventEmitter<elementCB>();
|
|
76
|
+
@Output() public resizeStopCB = new EventEmitter<elementCB>();
|
|
69
77
|
|
|
70
78
|
/** return the native element that contains grid specific fields as well */
|
|
71
|
-
public get el():
|
|
79
|
+
public get el(): GridCompHTMLElement { return this.elementRef.nativeElement; }
|
|
72
80
|
|
|
73
81
|
/** return the GridStack class */
|
|
74
82
|
public get grid(): GridStack | undefined { return this._grid; }
|
|
@@ -76,21 +84,19 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
|
76
84
|
private _options?: GridStackOptions;
|
|
77
85
|
private _grid?: GridStack;
|
|
78
86
|
private loaded?: boolean;
|
|
79
|
-
private outsideAddRemove?: AddRemoveFcn;
|
|
80
87
|
private ngUnsubscribe: Subject<void> = new Subject();
|
|
81
88
|
|
|
82
89
|
constructor(
|
|
83
|
-
private readonly
|
|
84
|
-
private readonly elementRef: ElementRef<
|
|
85
|
-
private readonly resolver: ComponentFactoryResolver,
|
|
90
|
+
private readonly zone: NgZone,
|
|
91
|
+
private readonly elementRef: ElementRef<GridCompHTMLElement>,
|
|
86
92
|
) {
|
|
93
|
+
this.el._gridComp = this;
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
public ngOnInit(): void {
|
|
90
97
|
// inject our own addRemove so we can create GridItemComponent instead of simple divs
|
|
91
98
|
const opts: GridStackOptions = this._options || {};
|
|
92
|
-
|
|
93
|
-
opts.addRemoveCB = this._addRemoveCB.bind(this);
|
|
99
|
+
opts.addRemoveCB = GridstackComponent._addRemoveCB;
|
|
94
100
|
|
|
95
101
|
// init ourself before any template children are created since we track them below anyway - no need to double create+update widgets
|
|
96
102
|
this.loaded = !!this.options?.children?.length;
|
|
@@ -100,7 +106,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
|
100
106
|
|
|
101
107
|
/** wait until after all DOM is ready to init gridstack children (after angular ngFor and sub-components run first) */
|
|
102
108
|
public ngAfterContentInit(): void {
|
|
103
|
-
this.
|
|
109
|
+
this.zone.runOutsideAngular(() => {
|
|
104
110
|
// track whenever the children list changes and update the layout...
|
|
105
111
|
this.gridstackItems?.changes
|
|
106
112
|
.pipe(takeUntil(this.ngUnsubscribe))
|
|
@@ -116,6 +122,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
|
116
122
|
this.ngUnsubscribe.complete();
|
|
117
123
|
this.grid?.destroy();
|
|
118
124
|
delete this._grid;
|
|
125
|
+
delete this.el._gridComp;
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
/**
|
|
@@ -135,38 +142,44 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
|
135
142
|
/** check if the grid is empty, if so show alternative content */
|
|
136
143
|
public checkEmpty() {
|
|
137
144
|
if (!this.grid) return;
|
|
138
|
-
this.
|
|
145
|
+
this.isEmpty = !this.grid.engine.nodes.length;
|
|
139
146
|
}
|
|
140
147
|
|
|
141
148
|
/** get all known events as easy to use Outputs for convenience */
|
|
142
149
|
private hookEvents(grid?: GridStack) {
|
|
143
150
|
if (!grid) return;
|
|
144
151
|
grid
|
|
145
|
-
.on('added', (event: Event, nodes: GridStackNode[]) => this.
|
|
146
|
-
.on('change', (event: Event, nodes: GridStackNode[]) => this.
|
|
147
|
-
.on('disable', (event: Event) => this.
|
|
148
|
-
.on('drag', (event: Event, el: GridItemHTMLElement) => this.
|
|
149
|
-
.on('dragstart', (event: Event, el: GridItemHTMLElement) => this.
|
|
150
|
-
.on('dragstop', (event: Event, el: GridItemHTMLElement) => this.
|
|
151
|
-
.on('dropped', (event: Event, previousNode: GridStackNode, newNode: GridStackNode) => this.
|
|
152
|
-
.on('enable', (event: Event) => this.
|
|
153
|
-
.on('removed', (event: Event, nodes: GridStackNode[]) => this.
|
|
154
|
-
.on('resize', (event: Event, el: GridItemHTMLElement) => this.
|
|
155
|
-
.on('resizestart', (event: Event, el: GridItemHTMLElement) => this.
|
|
156
|
-
.on('resizestop', (event: Event, el: GridItemHTMLElement) => this.
|
|
152
|
+
.on('added', (event: Event, nodes: GridStackNode[]) => this.zone.run(() => { this.checkEmpty(); this.addedCB.emit({event, nodes}); }))
|
|
153
|
+
.on('change', (event: Event, nodes: GridStackNode[]) => this.zone.run(() => this.changeCB.emit({event, nodes})))
|
|
154
|
+
.on('disable', (event: Event) => this.zone.run(() => this.disableCB.emit({event})))
|
|
155
|
+
.on('drag', (event: Event, el: GridItemHTMLElement) => this.zone.run(() => this.dragCB.emit({event, el})))
|
|
156
|
+
.on('dragstart', (event: Event, el: GridItemHTMLElement) => this.zone.run(() => this.dragStartCB.emit({event, el})))
|
|
157
|
+
.on('dragstop', (event: Event, el: GridItemHTMLElement) => this.zone.run(() => this.dragStopCB.emit({event, el})))
|
|
158
|
+
.on('dropped', (event: Event, previousNode: GridStackNode, newNode: GridStackNode) => this.zone.run(() => this.droppedCB.emit({event, previousNode, newNode})))
|
|
159
|
+
.on('enable', (event: Event) => this.zone.run(() => this.enableCB.emit({event})))
|
|
160
|
+
.on('removed', (event: Event, nodes: GridStackNode[]) => this.zone.run(() => { this.checkEmpty(); this.removedCB.emit({event, nodes}); }))
|
|
161
|
+
.on('resize', (event: Event, el: GridItemHTMLElement) => this.zone.run(() => this.resizeCB.emit({event, el})))
|
|
162
|
+
.on('resizestart', (event: Event, el: GridItemHTMLElement) => this.zone.run(() => this.resizeStartCB.emit({event, el})))
|
|
163
|
+
.on('resizestop', (event: Event, el: GridItemHTMLElement) => this.zone.run(() => this.resizeStopCB.emit({event, el})))
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
/** called by GS when a new item needs to be created, which we do as a Angular component, or deleted (skip) */
|
|
160
|
-
private _addRemoveCB(
|
|
167
|
+
private static _addRemoveCB(parent: GridCompHTMLElement | HTMLElement, w: GridStackWidget | GridStackOptions, add: boolean, isGrid: boolean): HTMLElement | undefined {
|
|
161
168
|
if (add) {
|
|
162
|
-
if (!
|
|
169
|
+
if (!parent) return;
|
|
163
170
|
// create the grid item dynamically - see https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
171
|
+
if (isGrid) {
|
|
172
|
+
const gridItemComp = (parent.parentElement as GridItemCompHTMLElement)._gridItemComp;
|
|
173
|
+
const grid = gridItemComp?.container?.createComponent(GridstackComponent)?.instance;
|
|
174
|
+
if (grid) grid.options = w as GridStackOptions;
|
|
175
|
+
return grid?.el;
|
|
176
|
+
} else {
|
|
177
|
+
// TODO: use GridStackWidget to define what type of component to create as child, or do it in GridstackItemComponent template...
|
|
178
|
+
const gridComp = (parent as GridCompHTMLElement)._gridComp;
|
|
179
|
+
const gridItem = gridComp?.container?.createComponent(GridstackItemComponent)?.instance;
|
|
180
|
+
return gridItem?.el;
|
|
181
|
+
}
|
|
168
182
|
}
|
|
169
|
-
// if (this.outsideAddRemove) this.outsideAddRemove(g, w, add);
|
|
170
183
|
return;
|
|
171
184
|
}
|
|
172
185
|
}
|
package/dist/dd-base-impl.d.ts
CHANGED
package/dist/dd-base-impl.js
CHANGED
package/dist/dd-base-impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dd-base-impl.js","sourceRoot":"","sources":["../src/dd-base-impl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,MAAsB,eAAe;IAArC;QAME,gBAAgB;QACN,mBAAc,GAEpB,EAAE,CAAC;IA0BT,CAAC;IAlCC,mHAAmH;IACnH,IAAW,QAAQ,KAAgB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IASpD,EAAE,CAAC,KAAa,EAAE,QAAuB;QAC9C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IACxC,CAAC;IAEM,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAEM,MAAM;QACX,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,YAAY,CAAC,SAAiB,EAAE,KAAY;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACzE,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF;AAnCD,0CAmCC","sourcesContent":["/**\n * dd-base-impl.ts 7.
|
|
1
|
+
{"version":3,"file":"dd-base-impl.js","sourceRoot":"","sources":["../src/dd-base-impl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,MAAsB,eAAe;IAArC;QAME,gBAAgB;QACN,mBAAc,GAEpB,EAAE,CAAC;IA0BT,CAAC;IAlCC,mHAAmH;IACnH,IAAW,QAAQ,KAAgB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IASpD,EAAE,CAAC,KAAa,EAAE,QAAuB;QAC9C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IACxC,CAAC;IAEM,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAEM,MAAM;QACX,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,YAAY,CAAC,SAAiB,EAAE,KAAY;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACzE,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF;AAnCD,0CAmCC","sourcesContent":["/**\n * dd-base-impl.ts 7.3.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nexport type EventCallback = (event: Event) => boolean|void;\nexport abstract class DDBaseImplement {\n /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n protected _disabled: boolean; // initial state to differentiate from false\n /** @internal */\n protected _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n public enable(): void {\n this._disabled = false;\n }\n\n public disable(): void {\n this._disabled = true;\n }\n\n public destroy(): void {\n delete this._eventRegister;\n }\n\n public triggerEvent(eventName: string, event: Event): boolean|void {\n if (!this.disabled && this._eventRegister && this._eventRegister[eventName])\n return this._eventRegister[eventName](event);\n }\n}\n\nexport interface HTMLElementExtendOpt<T> {\n el: HTMLElement;\n option: T;\n updateOption(T): DDBaseImplement;\n}\n"]}
|
package/dist/dd-draggable.d.ts
CHANGED
package/dist/dd-draggable.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* dd-draggable.ts 7.
|
|
3
|
+
* dd-draggable.ts 7.3.0
|
|
4
4
|
* Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -16,8 +16,8 @@ class DDDraggable extends dd_base_impl_1.DDBaseImplement {
|
|
|
16
16
|
this.el = el;
|
|
17
17
|
this.option = option;
|
|
18
18
|
// get the element that is actually supposed to be dragged by
|
|
19
|
-
let
|
|
20
|
-
this.dragEl = el.classList.contains(
|
|
19
|
+
let handleName = option.handle.substring(1);
|
|
20
|
+
this.dragEl = el.classList.contains(handleName) ? el : el.querySelector(option.handle) || el;
|
|
21
21
|
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
|
|
22
22
|
this._mouseDown = this._mouseDown.bind(this);
|
|
23
23
|
this._mouseMove = this._mouseMove.bind(this);
|
|
@@ -87,10 +87,9 @@ class DDDraggable extends dd_base_impl_1.DDBaseImplement {
|
|
|
87
87
|
// also check for content editable
|
|
88
88
|
if (e.target.closest('[contenteditable="true"]'))
|
|
89
89
|
return true;
|
|
90
|
+
// REMOVE: why would we get the event if it wasn't for us or child ?
|
|
90
91
|
// make sure we are clicking on a drag handle or child of it...
|
|
91
92
|
// Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)
|
|
92
|
-
//
|
|
93
|
-
// REMOVE: why would we get the event if it wasn't for us or child ?
|
|
94
93
|
// let className = this.option.handle.substring(1);
|
|
95
94
|
// let el = e.target as HTMLElement;
|
|
96
95
|
// while (el && !el.classList.contains(className)) { el = el.parentElement; }
|
package/dist/dd-draggable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dd-draggable.js","sourceRoot":"","sources":["../src/dd-draggable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAyC;AACzC,mCAAgC;AAChC,iDAAuE;AAGvE,yCAAmF;AA0BnF,yBAAyB;AAEzB,MAAa,WAAY,SAAQ,8BAAe;IAwB9C,YAAY,EAAe,EAAE,SAAyB,EAAE;QACtD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,6DAA6D;QAC7D,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5F,+GAA+G;QAC/G,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI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YACrB,UAAU,EAAE,CAAE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,GAAG,YAAY;YAC9D,SAAS,EAAE,CAAE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,GAAG,GAAG,YAAY;YAC5D,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,MAAM,EAAE,YAAY,CAAC,MAAM;SAC5B,CAAC;IACJ,CAAC;IAED,8DAA8D;IACvD,EAAE;QACP,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;QAC5C,MAAM,eAAe,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACnD,OAAO;YACL,QAAQ,EAAE;gBACR,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,eAAe,CAAC,GAAG;gBACrC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI;aACzC;YACD;;;cAGE;SACH,CAAC;IACJ,CAAC;;AAvWH,kCAwWC;AArVC,uEAAuE;AACtD,2BAAe,GAAG,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["/**\n * dd-draggable.ts 7.2.2\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { Utils } from './utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData } from './types';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, touchend, touchmove, touchstart, pointerdown } from './dd-touch';\n\n// TODO: merge with DDDragOpt ?\nexport interface DDDraggableOpt {\n appendTo?: string | HTMLElement;\n handle?: string;\n helper?: string | HTMLElement | ((event: Event) => HTMLElement);\n // containment?: string | HTMLElement; // TODO: not implemented yet\n // revert?: string | boolean | unknown; // TODO: not implemented yet\n // scroll?: boolean; // native support by HTML5 drag drop, can't be switch to off actually\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n drag?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\ntype DDDragEvent = 'drag' | 'dragstart' | 'dragstop';\n\n// let count = 0; // TEST\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDraggableOpt> {\n public el: HTMLElement;\n public option: DDDraggableOpt;\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n protected mouseDownEvent: MouseEvent;\n /** @internal */\n protected dragOffset: DragOffset;\n /** @internal */\n protected dragElementOriginStyle: Array<string>;\n /** @internal */\n protected dragEl: HTMLElement;\n /** @internal true while we are dragging an item around */\n protected dragging: boolean;\n /** @internal */\n protected parentOriginStylePosition: string;\n /** @internal */\n protected helperContainment: HTMLElement;\n /** @internal properties we change during dragging, and restore back */\n protected static originStyleProp = ['transition', 'pointerEvents', 'position', 'left', 'top', 'minWidth', 'willChange'];\n /** @internal pause before we call the actual drag hit collision code */\n protected dragTimeout: number;\n\n constructor(el: HTMLElement, option: DDDraggableOpt = {}) {\n super();\n this.el = el;\n this.option = option;\n // get the element that is actually supposed to be dragged by\n let className = option.handle.substring(1);\n this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n this.enable();\n }\n\n public on(event: DDDragEvent, callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: DDDragEvent): void {\n super.off(event);\n }\n\n public enable(): void {\n if (this.disabled === false) return;\n super.enable();\n this.dragEl.addEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.dragEl.addEventListener('touchstart', touchstart);\n this.dragEl.addEventListener('pointerdown', pointerdown);\n // this.dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment\n }\n this.el.classList.remove('ui-draggable-disabled');\n this.el.classList.add('ui-draggable');\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.dragEl.removeEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.dragEl.removeEventListener('touchstart', touchstart);\n this.dragEl.removeEventListener('pointerdown', pointerdown);\n }\n this.el.classList.remove('ui-draggable');\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n delete this.dragTimeout;\n if (this.dragging) this._mouseUp(this.mouseDownEvent);\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDraggableOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal call when mouse goes down before a dragstart happens */\n protected _mouseDown(e: MouseEvent): boolean {\n // don't let more than one widget handle mouseStart\n if (DDManager.mouseHandled) return;\n if (e.button !== 0) return true; // only left click\n\n // make sure we are not clicking on known object that handles mouseDown (TODO: make this extensible ?) #2054\n const skipMouseDown = ['input', 'textarea', 'button', 'select', 'option'];\n const name = (e.target as HTMLElement).nodeName.toLowerCase();\n if (skipMouseDown.find(skip => skip === name)) return true;\n // also check for content editable\n if ((e.target as HTMLElement).closest('[contenteditable=\"true\"]')) return true;\n\n // make sure we are clicking on a drag handle or child of it...\n // Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)\n //\n // REMOVE: why would we get the event if it wasn't for us or child ?\n // let className = this.option.handle.substring(1);\n // let el = e.target as HTMLElement;\n // while (el && !el.classList.contains(className)) { el = el.parentElement; }\n // if (!el) return;\n this.mouseDownEvent = e;\n delete this.dragging;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack\n document.addEventListener('mousemove', this._mouseMove, true); // true=capture, not bubble\n document.addEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.dragEl.addEventListener('touchmove', touchmove);\n this.dragEl.addEventListener('touchend', touchend);\n }\n\n e.preventDefault();\n // preventDefault() prevents blur event which occurs just after mousedown event.\n // if an editable content has focus, then blur must be call\n if(document.activeElement) (document.activeElement as HTMLElement).blur();\n\n DDManager.mouseHandled = true;\n return true;\n }\n\n /** @internal method to call actual drag event */\n protected _callDrag(e: DragEvent): void {\n if (!this.dragging) return;\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n }\n\n /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */\n protected _mouseMove(e: DragEvent): boolean {\n // console.log(`${count++} move ${e.x},${e.y}`)\n let s = this.mouseDownEvent;\n\n if (this.dragging) {\n this._dragFollow(e);\n // delay actual grid handling drag until we pause for a while if set\n if (DDManager.pauseDrag) {\n const pause = Number.isInteger(DDManager.pauseDrag) ? DDManager.pauseDrag as number : 100;\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n this.dragTimeout = window.setTimeout(() => this._callDrag(e), pause);\n } else {\n this._callDrag(e);\n }\n } else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {\n /**\n * don't start unless we've moved at least 3 pixels\n */\n this.dragging = true;\n DDManager.dragElement = this;\n // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)\n let grid = (this.el as GridItemHTMLElement).gridstackNode?.grid;\n if (grid) {\n DDManager.dropElement = (grid.el as DDElementHost).ddElement.ddDroppable;\n } else {\n delete DDManager.dropElement;\n }\n this.helper = this._createHelper(e);\n this._setupHelperContainmentStyle();\n this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstart' });\n\n this._setupHelperStyle(e);\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.triggerEvent('dragstart', ev);\n }\n e.preventDefault(); // needed otherwise we get text sweep text selection as we drag around\n return true;\n }\n\n /** @internal call when the mouse gets released to drop the item at current location */\n protected _mouseUp(e: MouseEvent): void {\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.dragEl.removeEventListener('touchmove', touchmove, true);\n this.dragEl.removeEventListener('touchend', touchend, true);\n }\n if (this.dragging) {\n delete this.dragging;\n\n // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)\n if (DDManager.dropElement?.el === this.el.parentElement) {\n delete DDManager.dropElement;\n }\n\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper === this.el) {\n this._removeHelperStyle();\n } else {\n this.helper.remove();\n }\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!\n }\n this.triggerEvent('dragstop', ev);\n\n // call the droppable method to receive the item\n if (DDManager.dropElement) {\n DDManager.dropElement.drop(e);\n }\n }\n delete this.helper;\n delete this.mouseDownEvent;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n delete DDManager.mouseHandled;\n e.preventDefault();\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n protected _createHelper(event: DragEvent): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(event);\n } else if (this.option.helper === 'clone') {\n helper = Utils.cloneNode(this.el);\n }\n if (!document.body.contains(helper)) {\n Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);\n }\n if (helper === this.el) {\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n }\n return helper;\n }\n\n /** @internal set the fix position of the dragged item */\n protected _setupHelperStyle(e: DragEvent): DDDraggable {\n this.helper.classList.add('ui-draggable-dragging');\n // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593\n const style = this.helper.style;\n style.pointerEvents = 'none'; // needed for over items to get enter/leave\n // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (done in CSS as well)\n style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)\n style.width = this.dragOffset.width + 'px';\n style.height = this.dragOffset.height + 'px';\n style.willChange = 'left, top';\n style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'\n this._dragFollow(e); // now position it\n style.transition = 'none'; // show up instantly\n setTimeout(() => {\n if (this.helper) {\n style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal restore back the original style before dragging */\n protected _removeHelperStyle(): DDDraggable {\n this.helper.classList.remove('ui-draggable-dragging');\n let node = (this.helper as GridItemHTMLElement)?.gridstackNode;\n // don't bother restoring styles if we're gonna remove anyway...\n if (!node?._isAboutToRemove && this.dragElementOriginStyle) {\n let helper = this.helper;\n // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.\n // TODO: this also removes resizing animation which doesn't have this issue, but others.\n // Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,\n // then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'\n // is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)\n let transition = this.dragElementOriginStyle['transition'] || null;\n helper.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973\n DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);\n setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal updates the top/left position to follow the mouse */\n protected _dragFollow(e: DragEvent): void {\n let containmentRect = { left: 0, top: 0 };\n // if (this.helper.style.position === 'absolute') { // we use 'fixed'\n // const { left, top } = this.helperContainment.getBoundingClientRect();\n // containmentRect = { left, top };\n // }\n const style = this.helper.style;\n const offset = this.dragOffset;\n style.left = e.clientX + offset.offsetLeft - containmentRect.left + 'px';\n style.top = e.clientY + offset.offsetTop - containmentRect.top + 'px';\n }\n\n /** @internal */\n protected _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.helper.style.position !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal */\n protected _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n const testEl = document.createElement('div');\n Utils.addElStyles(testEl, {\n opacity: '0',\n position: 'fixed',\n top: 0 + 'px',\n left: 0 + 'px',\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n });\n parent.appendChild(testEl);\n const testElPosition = testEl.getBoundingClientRect();\n parent.removeChild(testEl);\n xformOffsetX = testElPosition.left;\n xformOffsetY = testElPosition.top;\n // TODO: scale ?\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width,\n height: targetOffset.height\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui(): DDUIData {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: offset.top - containmentRect.top,\n left: offset.left - containmentRect.left\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dd-draggable.js","sourceRoot":"","sources":["../src/dd-draggable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAyC;AACzC,mCAAgC;AAChC,iDAAuE;AAGvE,yCAAmF;AA0BnF,yBAAyB;AAEzB,MAAa,WAAY,SAAQ,8BAAe;IAwB9C,YAAY,EAAe,EAAE,SAAyB,EAAE;QACtD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,6DAA6D;QAC7D,IAAI,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7F,+GAA+G;QAC/G,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEM,EAAE,CAAC,KAAkB,EAAE,QAAoC;QAChE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAEM,GAAG,CAAC,KAAkB;QAC3B,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,MAAM;QACX,IAAI,IAAI,CAA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I,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACnD,OAAO;YACL,QAAQ,EAAE;gBACR,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,eAAe,CAAC,GAAG;gBACrC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI;aACzC;YACD;;;cAGE;SACH,CAAC;IACJ,CAAC;;AAvWH,kCAwWC;AArVC,uEAAuE;AACtD,2BAAe,GAAG,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["/**\n * dd-draggable.ts 7.3.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { Utils } from './utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData } from './types';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, touchend, touchmove, touchstart, pointerdown } from './dd-touch';\n\n// TODO: merge with DDDragOpt ?\nexport interface DDDraggableOpt {\n appendTo?: string | HTMLElement;\n handle?: string;\n helper?: string | HTMLElement | ((event: Event) => HTMLElement);\n // containment?: string | HTMLElement; // TODO: not implemented yet\n // revert?: string | boolean | unknown; // TODO: not implemented yet\n // scroll?: boolean; // native support by HTML5 drag drop, can't be switch to off actually\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n drag?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\ntype DDDragEvent = 'drag' | 'dragstart' | 'dragstop';\n\n// let count = 0; // TEST\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDraggableOpt> {\n public el: HTMLElement;\n public option: DDDraggableOpt;\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n protected mouseDownEvent: MouseEvent;\n /** @internal */\n protected dragOffset: DragOffset;\n /** @internal */\n protected dragElementOriginStyle: Array<string>;\n /** @internal */\n protected dragEl: HTMLElement;\n /** @internal true while we are dragging an item around */\n protected dragging: boolean;\n /** @internal */\n protected parentOriginStylePosition: string;\n /** @internal */\n protected helperContainment: HTMLElement;\n /** @internal properties we change during dragging, and restore back */\n protected static originStyleProp = ['transition', 'pointerEvents', 'position', 'left', 'top', 'minWidth', 'willChange'];\n /** @internal pause before we call the actual drag hit collision code */\n protected dragTimeout: number;\n\n constructor(el: HTMLElement, option: DDDraggableOpt = {}) {\n super();\n this.el = el;\n this.option = option;\n // get the element that is actually supposed to be dragged by\n let handleName = option.handle.substring(1);\n this.dragEl = el.classList.contains(handleName) ? el : el.querySelector(option.handle) || el;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n this.enable();\n }\n\n public on(event: DDDragEvent, callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: DDDragEvent): void {\n super.off(event);\n }\n\n public enable(): void {\n if (this.disabled === false) return;\n super.enable();\n this.dragEl.addEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.dragEl.addEventListener('touchstart', touchstart);\n this.dragEl.addEventListener('pointerdown', pointerdown);\n // this.dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment\n }\n this.el.classList.remove('ui-draggable-disabled');\n this.el.classList.add('ui-draggable');\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.dragEl.removeEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.dragEl.removeEventListener('touchstart', touchstart);\n this.dragEl.removeEventListener('pointerdown', pointerdown);\n }\n this.el.classList.remove('ui-draggable');\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n delete this.dragTimeout;\n if (this.dragging) this._mouseUp(this.mouseDownEvent);\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDraggableOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal call when mouse goes down before a dragstart happens */\n protected _mouseDown(e: MouseEvent): boolean {\n // don't let more than one widget handle mouseStart\n if (DDManager.mouseHandled) return;\n if (e.button !== 0) return true; // only left click\n\n // make sure we are not clicking on known object that handles mouseDown (TODO: make this extensible ?) #2054\n const skipMouseDown = ['input', 'textarea', 'button', 'select', 'option'];\n const name = (e.target as HTMLElement).nodeName.toLowerCase();\n if (skipMouseDown.find(skip => skip === name)) return true;\n // also check for content editable\n if ((e.target as HTMLElement).closest('[contenteditable=\"true\"]')) return true;\n\n // REMOVE: why would we get the event if it wasn't for us or child ?\n // make sure we are clicking on a drag handle or child of it...\n // Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)\n // let className = this.option.handle.substring(1);\n // let el = e.target as HTMLElement;\n // while (el && !el.classList.contains(className)) { el = el.parentElement; }\n // if (!el) return;\n\n this.mouseDownEvent = e;\n delete this.dragging;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack\n document.addEventListener('mousemove', this._mouseMove, true); // true=capture, not bubble\n document.addEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.dragEl.addEventListener('touchmove', touchmove);\n this.dragEl.addEventListener('touchend', touchend);\n }\n\n e.preventDefault();\n // preventDefault() prevents blur event which occurs just after mousedown event.\n // if an editable content has focus, then blur must be call\n if (document.activeElement) (document.activeElement as HTMLElement).blur();\n\n DDManager.mouseHandled = true;\n return true;\n }\n\n /** @internal method to call actual drag event */\n protected _callDrag(e: DragEvent): void {\n if (!this.dragging) return;\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n }\n\n /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */\n protected _mouseMove(e: DragEvent): boolean {\n // console.log(`${count++} move ${e.x},${e.y}`)\n let s = this.mouseDownEvent;\n\n if (this.dragging) {\n this._dragFollow(e);\n // delay actual grid handling drag until we pause for a while if set\n if (DDManager.pauseDrag) {\n const pause = Number.isInteger(DDManager.pauseDrag) ? DDManager.pauseDrag as number : 100;\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n this.dragTimeout = window.setTimeout(() => this._callDrag(e), pause);\n } else {\n this._callDrag(e);\n }\n } else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {\n /**\n * don't start unless we've moved at least 3 pixels\n */\n this.dragging = true;\n DDManager.dragElement = this;\n // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)\n let grid = (this.el as GridItemHTMLElement).gridstackNode?.grid;\n if (grid) {\n DDManager.dropElement = (grid.el as DDElementHost).ddElement.ddDroppable;\n } else {\n delete DDManager.dropElement;\n }\n this.helper = this._createHelper(e);\n this._setupHelperContainmentStyle();\n this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstart' });\n\n this._setupHelperStyle(e);\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.triggerEvent('dragstart', ev);\n }\n e.preventDefault(); // needed otherwise we get text sweep text selection as we drag around\n return true;\n }\n\n /** @internal call when the mouse gets released to drop the item at current location */\n protected _mouseUp(e: MouseEvent): void {\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.dragEl.removeEventListener('touchmove', touchmove, true);\n this.dragEl.removeEventListener('touchend', touchend, true);\n }\n if (this.dragging) {\n delete this.dragging;\n\n // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)\n if (DDManager.dropElement?.el === this.el.parentElement) {\n delete DDManager.dropElement;\n }\n\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper === this.el) {\n this._removeHelperStyle();\n } else {\n this.helper.remove();\n }\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!\n }\n this.triggerEvent('dragstop', ev);\n\n // call the droppable method to receive the item\n if (DDManager.dropElement) {\n DDManager.dropElement.drop(e);\n }\n }\n delete this.helper;\n delete this.mouseDownEvent;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n delete DDManager.mouseHandled;\n e.preventDefault();\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n protected _createHelper(event: DragEvent): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(event);\n } else if (this.option.helper === 'clone') {\n helper = Utils.cloneNode(this.el);\n }\n if (!document.body.contains(helper)) {\n Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);\n }\n if (helper === this.el) {\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n }\n return helper;\n }\n\n /** @internal set the fix position of the dragged item */\n protected _setupHelperStyle(e: DragEvent): DDDraggable {\n this.helper.classList.add('ui-draggable-dragging');\n // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593\n const style = this.helper.style;\n style.pointerEvents = 'none'; // needed for over items to get enter/leave\n // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (done in CSS as well)\n style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)\n style.width = this.dragOffset.width + 'px';\n style.height = this.dragOffset.height + 'px';\n style.willChange = 'left, top';\n style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'\n this._dragFollow(e); // now position it\n style.transition = 'none'; // show up instantly\n setTimeout(() => {\n if (this.helper) {\n style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal restore back the original style before dragging */\n protected _removeHelperStyle(): DDDraggable {\n this.helper.classList.remove('ui-draggable-dragging');\n let node = (this.helper as GridItemHTMLElement)?.gridstackNode;\n // don't bother restoring styles if we're gonna remove anyway...\n if (!node?._isAboutToRemove && this.dragElementOriginStyle) {\n let helper = this.helper;\n // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.\n // TODO: this also removes resizing animation which doesn't have this issue, but others.\n // Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,\n // then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'\n // is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)\n let transition = this.dragElementOriginStyle['transition'] || null;\n helper.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973\n DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);\n setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal updates the top/left position to follow the mouse */\n protected _dragFollow(e: DragEvent): void {\n let containmentRect = { left: 0, top: 0 };\n // if (this.helper.style.position === 'absolute') { // we use 'fixed'\n // const { left, top } = this.helperContainment.getBoundingClientRect();\n // containmentRect = { left, top };\n // }\n const style = this.helper.style;\n const offset = this.dragOffset;\n style.left = e.clientX + offset.offsetLeft - containmentRect.left + 'px';\n style.top = e.clientY + offset.offsetTop - containmentRect.top + 'px';\n }\n\n /** @internal */\n protected _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.helper.style.position !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal */\n protected _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n const testEl = document.createElement('div');\n Utils.addElStyles(testEl, {\n opacity: '0',\n position: 'fixed',\n top: 0 + 'px',\n left: 0 + 'px',\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n });\n parent.appendChild(testEl);\n const testElPosition = testEl.getBoundingClientRect();\n parent.removeChild(testEl);\n xformOffsetX = testElPosition.left;\n xformOffsetY = testElPosition.top;\n // TODO: scale ?\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width,\n height: targetOffset.height\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui(): DDUIData {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: offset.top - containmentRect.top,\n left: offset.left - containmentRect.left\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n"]}
|
package/dist/dd-droppable.d.ts
CHANGED