ドキュメント/Changelog
3.1.0
Drags in other windows of the app — a popup, a detached panel, a Picture-in-Picture window — under the same provider.
npm i @vue-dnd-kit/core
Other windows of the app
An app may show part of itself in another window: a popup it opens with window.open, a
detached panel, a Document Picture-in-Picture window, rendered there with a teleport under the
same provider. Drags now work in that window as on the page. Open the wishlist in a window and
sort it there:
デモを読み込み中…
<script setup lang="ts">
import { DnDProvider } from '@vue-dnd-kit/core';
import Library from './Library.vue';
</script>
<template>
<!-- One provider for the page and the popup: the popup shows part of this app. -->
<DnDProvider>
<Library />
</DnDProvider>
</template>Hand the window to the provider when you open it:
const dnd = useDnD();
function detach() {
const popup = window.open('', 'inspector', 'popup,width=420,height=560')!;
const release = dnd.addWindow(popup); // listen there, until it closes
popup.addEventListener('pagehide', release);
target.value = popup.document.body; // <Teleport :to="target">…</Teleport>
}
- A drag runs in the window it started in: its viewport, its targets, its auto-scroll, the
overlay in its
<body>, its own frames. A page hidden behind the popup doesn't slow it down. - Items with
nativecross between the windows, carried by the browser's own drag and drop. A pointer or keyboard drag can't: the browser sends a window's input to that window only. - A component rendered into the window when it mounts is found on its own.
addWindowis for content a teleport moves there later, such as a panel that detaches. - The provider injects its styles there and lets go of the window when it closes.
- Sensors of your own listen in every window with
context.onWindow(setup).
See other windows of the app in the provider guide.
Also new in the docs
Upgrading
Nothing to change: no API you use changed. The library no longer checks DOM nodes with
instanceof, since another window's nodes are of that window's classes: an element of yours
passes the checks as before.
All changes
Features
- Drags work in other windows of the app:
useDnD().addWindow(view),SensorContext.onWindow(setup)(f956c9d)
The commits: core-v3.0.1...core-v3.1.0.