tauri-plugin-positioner-api
v0.2.7
Published
Helps positioning your tauri windows.
Downloads
639
Readme
Tauri plugin positioner
A plugin for Tauri that helps position your windows at well-known locations.
This plugin is a port of electron-positioner for tauri.
Install
Rust
[dependencies]
tauri-plugin-positioner = "1.0"
JavaScript
pnpm add tauri-plugin-positioner
# or
npm install tauri-plugin-positioner
# or
yarn add tauri-plugin-positioner
Usage
You need to register the plugin first:
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_positioner::init())
.run(tauri::generate_context!())
.expect("failed to run app");
}
Now you can import the JavaScript API package and move the window:
import { move_window, Position } from 'tauri-plugin-positioner-api'
move_window(Position.TopRight)
Rust only
If you only intend on moving the window from rust code, you can import the Window
trait extension instead of registering the plugin:
Note:
Window.move_window
method must be called from a different thread!
use tauri_plugin_positioner::{WindowExt, Position};
fn main() {
tauri::Builder::default()
.setup(|app| {
let mut win = app.get_window("main").unwrap();
let _ = win.move_window(Position::TopRight);
Ok(())
})
.run(tauri::generate_context!())
.expect("failed to run app");
}
Contributing
PRs are welcome!