Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/content/docs/learn/window-customization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,42 @@ Create the main window and change its background color:
.run(tauri::generate_context!())
.expect("error while running tauri application");
}


## Detecting When Window Drag or Resize Has Stopped (Userland Example)

Tauri does not currently expose native “drag finished” or “resize finished” events
from the operating system. However, you can implement this behavior in userland
by listening to the continuously emitted `tauri://move` and `tauri://resize`
events and detecting when movement or resizing stops.

```ts
import { appWindow } from "@tauri-apps/api/window";

// Detect when window dragging stops
let dragTimer: number | null = null;
appWindow.listen("tauri://move", () => {
clearTimeout(dragTimer);
dragTimer = setTimeout(() => {
window.dispatchEvent(new CustomEvent("drag-stopped"));
}, 120);
});

// Detect when window resizing stops
let resizeTimer: number | null = null;
appWindow.listen("tauri://resize", () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
window.dispatchEvent(new CustomEvent("resize-stopped"));
}, 120);
});

// Usage example
window.addEventListener("drag-stopped", () => {
console.log("Window drag stopped");
});

window.addEventListener("resize-stopped", () => {
console.log("Window resize stopped");
});
```
Loading