Skip to content

Commit 4f1e87f

Browse files
authored
refactor(core): change drag element detection to data attr, fixes #1656 (#1659)
1 parent df8bdcf commit 4f1e87f

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

.changes/drag-region-refactor.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Change draggable region element detection from `drag-region` class to `data-tauri-drag-region` attribute.

core/tauri/scripts/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ if (!String.prototype.startsWith) {
189189

190190
// drag region
191191
document.addEventListener('mousedown', (e) => {
192-
if (e.target.classList.contains('drag-region') && e.buttons === 1) {
192+
// start dragging if the element has a `tauri-drag-region` data attribute
193+
if (e.target.dataset.tauriDragRegion === '' && e.buttons === 1) {
193194
window.__TAURI__.invoke('tauri', {
194195
__tauriModule: "Window",
195196
message: {

examples/api/public/build/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/public/build/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/src/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</script>
8181

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

0 commit comments

Comments
 (0)