Pārlūkot izejas kodu

refactor(core): change drag element detection to data attr, fixes #1656 (#1659)

Lucas Fernandes Nogueira 4 gadi atpakaļ
vecāks
revīzija
4f1e87f87b

+ 5 - 0
.changes/drag-region-refactor.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Change draggable region element detection from `drag-region` class to `data-tauri-drag-region` attribute.

+ 2 - 1
core/tauri/scripts/core.js

@@ -189,7 +189,8 @@ if (!String.prototype.startsWith) {
 
   // drag region
   document.addEventListener('mousedown', (e) => {
-    if (e.target.classList.contains('drag-region') && e.buttons === 1) {
+    // start dragging if the element has a `tauri-drag-region` data attribute
+    if (e.target.dataset.tauriDragRegion === '' && e.buttons === 1) {
       window.__TAURI__.invoke('tauri', {
         __tauriModule: "Window",
         message: {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
examples/api/public/build/bundle.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
examples/api/public/build/bundle.js.map


+ 1 - 1
examples/api/src/App.svelte

@@ -80,7 +80,7 @@
 </script>
 
 <main>
-  <div class="flex row noselect just-around" style="margin=1em;">
+  <div class="flex row noselect just-around" style="margin=1em;" data-tauri-drag-region>
     <img src="tauri.png" height="60" on:click={onLogoClick} alt="logo" />
     <div>
       <a class="dark-link" target="_blank" href="https://tauri.studio/en/docs/getting-started/intro">

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels