5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 03:10:22 +08:00

If the element adds the data-rails-drag attribute, it can trigger the dbclick event. (#1317)

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
归位 2022-04-09 08:18:01 +08:00 committed by GitHub
parent 0c244b1ce4
commit 65a97a668e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,6 +60,10 @@ if (ENV === 0) {
delete window.wailsbindings; delete window.wailsbindings;
} }
var dragTimeOut;
var dragLastTime = 0;
var dbClickInterval = 100;
// Setup drag handler // Setup drag handler
// Based on code from: https://github.com/patr0nus/DeskGap // Based on code from: https://github.com/patr0nus/DeskGap
window.addEventListener('mousedown', (e) => { window.addEventListener('mousedown', (e) => {
@ -83,7 +87,14 @@ window.addEventListener('mousedown', (e) => {
break; break;
} }
} }
window.WailsInvoke("drag"); if (new Date().getTime() - dragLastTime < dbClickInterval) {
clearTimeout(dragTimeOut)
break;
}
dragTimeOut = setTimeout(function () {
window.WailsInvoke("drag");
}, dbClickInterval)
dragLastTime = new Date().getTime();
e.preventDefault(); e.preventDefault();
break; break;
} }