docs: add maximize toggle to window_customization guide (#2132)

This commit is contained in:
Amr Bashir 2021-06-30 20:32:38 +02:00 committed by GitHub
parent 3e6f34160d
commit 373e2ba318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,11 +8,9 @@ Tauri provides lots of options for customizing the look and feel of your app's w
There are three ways to change the window configuration: There are three ways to change the window configuration:
TODO: LINKS
- [Through tauri.conf.json](https://tauri.studio/en/docs/api/config/#tauri.windows) - [Through tauri.conf.json](https://tauri.studio/en/docs/api/config/#tauri.windows)
- [Through the JS API] - [Through the JS API](https://tauri.studio/en/docs/api/js/classes/window.windowmanager)
- [Through the Window in Rust] - [Through the Window in Rust](https://tauri.studio/en/docs/api/js/classes/window.windowmanager)
## Creating a Custom Titlebar ## Creating a Custom Titlebar
@ -76,7 +74,6 @@ Note that you may need to move the rest of your content down so that the titleba
Finally, you'll need to make the buttons work: Finally, you'll need to make the buttons work:
TODO: TOGGLE MAXIMIZE
```js ```js
import { appWindow } from '@tauri-apps/api/window' import { appWindow } from '@tauri-apps/api/window'
@ -85,7 +82,7 @@ document
.addEventListener('click', () => appWindow.minimize()) .addEventListener('click', () => appWindow.minimize())
document document
.getElementById('titlebar-maximize') .getElementById('titlebar-maximize')
.addEventListener('click', () => appWindow.maximize()) .addEventListener('click', async () => await appWindow.isMaximized() ? appWindow.unmaximmize() : appWindow.maximize())
document document
.getElementById('titlebar-close') .getElementById('titlebar-close')
.addEventListener('click', () => appWindow.close()) .addEventListener('click', () => appWindow.close())