@atlaskit/pragmatic-drag-and-drop 0.20.0 → 0.22.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/CHANGELOG.md +47 -0
- package/constellation/index/about.mdx +1 -1
- package/dist/cjs/entry-point/util/preserve-offset-from-pointer.js +12 -0
- package/dist/cjs/util/custom-native-drag-preview/preserve-offset-from-pointer.js +31 -0
- package/dist/es2019/entry-point/util/preserve-offset-from-pointer.js +1 -0
- package/dist/es2019/util/custom-native-drag-preview/preserve-offset-from-pointer.js +27 -0
- package/dist/esm/entry-point/util/preserve-offset-from-pointer.js +1 -0
- package/dist/esm/util/custom-native-drag-preview/preserve-offset-from-pointer.js +25 -0
- package/dist/types/entry-point/types.d.ts +1 -1
- package/dist/types/entry-point/util/preserve-offset-from-pointer.d.ts +1 -0
- package/dist/types/util/custom-native-drag-preview/preserve-offset-from-pointer.d.ts +6 -0
- package/dist/types-ts4.5/entry-point/types.d.ts +1 -1
- package/dist/types-ts4.5/entry-point/util/preserve-offset-from-pointer.d.ts +1 -0
- package/dist/types-ts4.5/util/custom-native-drag-preview/preserve-offset-from-pointer.d.ts +6 -0
- package/package.json +2 -1
- package/util/preserve-offset-from-pointer/package.json +15 -0
- package/dist/cjs/version.json +0 -5
- package/dist/es2019/version.json +0 -5
- package/dist/esm/version.json +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @atlaskit/pragmatic-drag-and-drop
|
|
2
2
|
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`d644a68ddf6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d644a68ddf6) - Added a new `setCustomNativeDragPreview` `getOffset` utililiy: `preserveOffsetFromPointer`. `preserveOffsetFromPointer` mimics the default behaviour for non custom drag previews when starting a drag: the initial cursor position offset is preserved for a seamless drag and drop experience.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
11
|
+
import { preserveOffsetFromPointer } from '@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-from-pointer';
|
|
12
|
+
|
|
13
|
+
draggable({
|
|
14
|
+
element: myElement,
|
|
15
|
+
onGenerateDragPreview: ({ nativeSetDragImage, location, source }) => {
|
|
16
|
+
setCustomNativeDragPreview({
|
|
17
|
+
getOffset: preserveOffsetFromPointer({
|
|
18
|
+
sourceElement: source.element,
|
|
19
|
+
input: location.current.input,
|
|
20
|
+
}),
|
|
21
|
+
render: function render({ container }) {
|
|
22
|
+
/* ... */
|
|
23
|
+
},
|
|
24
|
+
nativeSetDragImage,
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 0.21.0
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- [`de7463c7096`](https://bitbucket.org/atlassian/atlassian-frontend/commits/de7463c7096) - Exposing some additional TypeScript types. These can be helpful when creating helper packages.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import type {
|
|
38
|
+
// These types are not needed for consumers
|
|
39
|
+
// They are mostly helpful for other packages
|
|
40
|
+
AllDragTypes,
|
|
41
|
+
MonitorArgs,
|
|
42
|
+
BaseEventPayload,
|
|
43
|
+
} from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- `AllDragTypes`: representation of all entities types in the system (eg element and file)
|
|
47
|
+
- `MonitorArgs<DragType extends AllDragTypes>`: the arguments that can be passed to a monitor
|
|
48
|
+
- `BaseEventPayload<DragType extends AllDragTypes>`: the shared properties in all events
|
|
49
|
+
|
|
3
50
|
## 0.20.0
|
|
4
51
|
|
|
5
52
|
### Minor Changes
|
|
@@ -49,7 +49,7 @@ import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
|
|
|
49
49
|
_Draggables_, _drop targets_ and _monitors_ return a cleanup function.
|
|
50
50
|
|
|
51
51
|
```ts
|
|
52
|
-
import { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
52
|
+
import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
53
53
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
54
54
|
|
|
55
55
|
const cleanup: CleanupFn = draggable({ element: myElement });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "preserveOffsetFromPointer", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _preserveOffsetFromPointer.preserveOffsetFromPointer;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _preserveOffsetFromPointer = require("../../util/custom-native-drag-preview/preserve-offset-from-pointer");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.preserveOffsetFromPointer = preserveOffsetFromPointer;
|
|
7
|
+
function preserveOffsetFromPointer(_ref) {
|
|
8
|
+
var sourceElement = _ref.sourceElement,
|
|
9
|
+
input = _ref.input;
|
|
10
|
+
return function (_ref2) {
|
|
11
|
+
var container = _ref2.container;
|
|
12
|
+
var sourceRect = sourceElement.getBoundingClientRect();
|
|
13
|
+
var containerRect = container.getBoundingClientRect();
|
|
14
|
+
var offsetX = Math.min(
|
|
15
|
+
// difference
|
|
16
|
+
input.clientX - sourceRect.x,
|
|
17
|
+
// don't let the difference be more than the width of the container,
|
|
18
|
+
// otherwise the pointer will be off the preview
|
|
19
|
+
containerRect.width);
|
|
20
|
+
var offsetY = Math.min(
|
|
21
|
+
// difference
|
|
22
|
+
input.clientY - sourceRect.y,
|
|
23
|
+
// don't let the difference be more than the height of the container,
|
|
24
|
+
// otherwise the pointer will be off the preview
|
|
25
|
+
containerRect.height);
|
|
26
|
+
return {
|
|
27
|
+
x: offsetX,
|
|
28
|
+
y: offsetY
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function preserveOffsetFromPointer({
|
|
2
|
+
sourceElement,
|
|
3
|
+
input
|
|
4
|
+
}) {
|
|
5
|
+
return ({
|
|
6
|
+
container
|
|
7
|
+
}) => {
|
|
8
|
+
const sourceRect = sourceElement.getBoundingClientRect();
|
|
9
|
+
const containerRect = container.getBoundingClientRect();
|
|
10
|
+
const offsetX = Math.min(
|
|
11
|
+
// difference
|
|
12
|
+
input.clientX - sourceRect.x,
|
|
13
|
+
// don't let the difference be more than the width of the container,
|
|
14
|
+
// otherwise the pointer will be off the preview
|
|
15
|
+
containerRect.width);
|
|
16
|
+
const offsetY = Math.min(
|
|
17
|
+
// difference
|
|
18
|
+
input.clientY - sourceRect.y,
|
|
19
|
+
// don't let the difference be more than the height of the container,
|
|
20
|
+
// otherwise the pointer will be off the preview
|
|
21
|
+
containerRect.height);
|
|
22
|
+
return {
|
|
23
|
+
x: offsetX,
|
|
24
|
+
y: offsetY
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function preserveOffsetFromPointer(_ref) {
|
|
2
|
+
var sourceElement = _ref.sourceElement,
|
|
3
|
+
input = _ref.input;
|
|
4
|
+
return function (_ref2) {
|
|
5
|
+
var container = _ref2.container;
|
|
6
|
+
var sourceRect = sourceElement.getBoundingClientRect();
|
|
7
|
+
var containerRect = container.getBoundingClientRect();
|
|
8
|
+
var offsetX = Math.min(
|
|
9
|
+
// difference
|
|
10
|
+
input.clientX - sourceRect.x,
|
|
11
|
+
// don't let the difference be more than the width of the container,
|
|
12
|
+
// otherwise the pointer will be off the preview
|
|
13
|
+
containerRect.width);
|
|
14
|
+
var offsetY = Math.min(
|
|
15
|
+
// difference
|
|
16
|
+
input.clientY - sourceRect.y,
|
|
17
|
+
// don't let the difference be more than the height of the container,
|
|
18
|
+
// otherwise the pointer will be off the preview
|
|
19
|
+
containerRect.height);
|
|
20
|
+
return {
|
|
21
|
+
x: offsetX,
|
|
22
|
+
y: offsetY
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { DropTargetRecord, Position, SourceCanStartArgs, Input, DragLocation, DragLocationHistory, CleanupFn, } from '../internal-types';
|
|
1
|
+
export type { DropTargetRecord, Position, SourceCanStartArgs, Input, DragLocation, DragLocationHistory, CleanupFn, AllDragTypes, MonitorArgs, BaseEventPayload, } from '../internal-types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { DropTargetRecord, Position, SourceCanStartArgs, Input, DragLocation, DragLocationHistory, CleanupFn, } from '../internal-types';
|
|
1
|
+
export type { DropTargetRecord, Position, SourceCanStartArgs, Input, DragLocation, DragLocationHistory, CleanupFn, AllDragTypes, MonitorArgs, BaseEventPayload, } from '../internal-types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/pragmatic-drag-and-drop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "The core Pragmatic drag and drop framework, optimized for performance.",
|
|
5
5
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
6
6
|
"author": "Atlassian Pty Ltd",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"./util/set-custom-native-drag-preview": "./src/entry-point/util/set-custom-native-drag-preview.ts",
|
|
47
47
|
"./util/offset-from-pointer": "./src/entry-point/util/offset-from-pointer.ts",
|
|
48
48
|
"./util/center-under-pointer": "./src/entry-point/util/center-under-pointer.ts",
|
|
49
|
+
"./util/preserve-offset-from-pointer": "./src/entry-point/util/preserve-offset-from-pointer.ts",
|
|
49
50
|
"./util/disable-native-drag-preview": "./src/entry-point/util/disable-native-drag-preview.ts",
|
|
50
51
|
"./util/scroll-just-enough-into-view": "./src/entry-point/util/scroll-just-enough-into-view.ts",
|
|
51
52
|
"./experimental/cross-window-element-adapter": "./src/entry-point/experimental/cross-with-element-adapter.ts"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-from-pointer",
|
|
3
|
+
"main": "../../dist/cjs/entry-point/util/preserve-offset-from-pointer.js",
|
|
4
|
+
"module": "../../dist/esm/entry-point/util/preserve-offset-from-pointer.js",
|
|
5
|
+
"module:es2019": "../../dist/es2019/entry-point/util/preserve-offset-from-pointer.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../../dist/types/entry-point/util/preserve-offset-from-pointer.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <4.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../../dist/types-ts4.5/entry-point/util/preserve-offset-from-pointer.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/cjs/version.json
DELETED
package/dist/es2019/version.json
DELETED