drag.js 792 B

1234567891011121314151617
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. document.addEventListener("mousedown", (e) => {
  5. if (e.target.hasAttribute("data-tauri-drag-region") && e.button === 0) {
  6. // prevents text cursor
  7. e.preventDefault();
  8. // fix #2549: double click on drag region edge causes content to maximize without window sizing change
  9. // https://github.com/tauri-apps/tauri/issues/2549#issuecomment-1250036908
  10. e.stopImmediatePropagation();
  11. // start dragging if the element has a `tauri-drag-region` data attribute and maximize on double-clicking it
  12. const cmd = e.detail === 2 ? "internal_toggle_maximize" : "start_dragging";
  13. window.__TAURI_INVOKE__("plugin:window|" + cmd);
  14. }
  15. });