ソースを参照

improved drag n drop preview from filetree

Nicolas Cannasse 5 年 前
コミット
dc4b849918
1 ファイル変更11 行追加6 行削除
  1. 11 6
      hide/Ide.hx

+ 11 - 6
hide/Ide.hx

@@ -190,9 +190,9 @@ class Ide {
 		if( subView != null ) body.className +=" hide-subview";
 
 		// Listen to FileTree dnd
-		new Element(window.window.document).on("dnd_stop.vakata.jstree", function(e, data) {
+		function treeDragFun(data,drop) {
 			var nodeIds : Array<String> = cast data.data.nodes;
-			if(data.data.jstree == null) return;
+			if(data.data.jstree == null) return false;
 			for( ft in getViews(hide.view.FileTree) ) {
 				var paths = [];
 				@:privateAccess {
@@ -206,11 +206,16 @@ class Ide {
 				if(paths.length == 0)
 					continue;
 				var view = getViewAt(mouseX, mouseY);
-				if(view != null) {
-					view.onDragDrop(paths, true);
-					return;
-				}
+				if(view != null)
+					return view.onDragDrop(paths, drop);
 			}
+			return false;
+		}
+		new Element(window.window.document).on("dnd_move.vakata.jstree", function(e, data:Dynamic) {
+			(data.helper:hide.Element).css(treeDragFun(data,false) ? { filter : "brightness(120%)", opacity : 1 } : { filter : "", opacity : 0.5 });
+		});
+		new Element(window.window.document).on("dnd_stop.vakata.jstree", function(e, data) {
+			treeDragFun(data,true);
 		});
 
 		// dispatch global keys based on mouse position