0.2.7 • Published 2 years ago

tauri-plugin-positioner-api v0.2.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Tauri plugin positioner

Crates.io Documentation MIT licensed

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!

License

MIT © Jonas Kruckenberg

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.3

2 years ago

0.2.4

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.0

2 years ago

0.0.0

2 years ago