Skip to content

Commit

Permalink
refactor(core): change drag element detection to data attr, fixes #1656
Browse files Browse the repository at this point in the history
… (#1659)
  • Loading branch information
lucasfernog committed Apr 29, 2021
1 parent df8bdcf commit 4f1e87f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .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.
3 changes: 2 additions & 1 deletion core/tauri/scripts/core.js
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion examples/api/public/build/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/api/public/build/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/api/src/App.svelte
Expand Up @@ -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">
Expand Down

0 comments on commit 4f1e87f

Please sign in to comment.