From 198fabe15e2e878fe7175cef1287ac7b325f0794 Mon Sep 17 00:00:00 2001 From: milan Date: Thu, 27 Jun 2024 17:05:12 +0200 Subject: [PATCH] improve performance for tree DragDrop --- api/js/egw_action/EgwDragDropShoelaceTree.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/js/egw_action/EgwDragDropShoelaceTree.ts b/api/js/egw_action/EgwDragDropShoelaceTree.ts index 358b997da4..b854202d0a 100644 --- a/api/js/egw_action/EgwDragDropShoelaceTree.ts +++ b/api/js/egw_action/EgwDragDropShoelaceTree.ts @@ -10,7 +10,13 @@ import {EgwActionObjectInterface} from "./EgwActionObjectInterface"; import {egwActionObjectInterface} from "./egw_action"; import {Et2Tree} from "../etemplate/Et2Tree/Et2Tree"; -import {EGW_AI_DRAG_OUT, EGW_AI_DRAG_OVER, EGW_AO_STATE_FOCUSED, EGW_AO_STATE_SELECTED} from "./egw_action_constants"; +import { + EGW_AI_DRAG_ENTER, + EGW_AI_DRAG_OUT, + EGW_AI_DRAG_OVER, + EGW_AO_STATE_FOCUSED, + EGW_AO_STATE_SELECTED +} from "./egw_action_constants"; import {egwBitIsSet} from "./egw_action_common"; @@ -34,12 +40,14 @@ export class EgwDragDropShoelaceTree { aoi.doGetDOMNode = function () { return aoi.node; } + let timeout: NodeJS.Timeout; aoi.doTriggerEvent = function (_event) { - if (_event == EGW_AI_DRAG_OVER) + if (_event == EGW_AI_DRAG_ENTER) { + this.node.classList.add("draggedOver"); - setTimeout(() => { + timeout = setTimeout(() => { if (this.node.classList.contains("draggedOver")) { this.node.expanded = true @@ -49,6 +57,7 @@ export class EgwDragDropShoelaceTree { if (_event == EGW_AI_DRAG_OUT) { (this.node).classList.remove("draggedOver"); + clearTimeout(timeout) } return true }