-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel.js
95 lines (92 loc) · 2.04 KB
/
level.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//上移一层
function moveBehind(){
if(!checkSelect()){
return;
}
//找到了需要调整的对象
let getItem=false;
let tmpMap=new Map();
let lastData=null;
objList.forEach(i => {
if(getItem){
tmpMap.set(i.id,i);
tmpMap.set(lastData.id,lastData);
getItem=false;
}
else{
if(i.id==currentID){
lastData=i;
getItem=true;
}
else{
tmpMap.set(i.id,i);
}
}
lastData=i;
});
objList=tmpMap;
drawSVG();
}
//下移一层
function moveFront(){
if(!checkSelect()){
return;
}
let checkFirst=false;
let tmpMap=new Map();
let lastData=null;
try{
objList.forEach(i=>{
if(!checkFirst){
//已经在最上级
if(i.id==currentID){
throw "";
}
console.log("d");
checkFirst=true;
}
//循环到需要移动的元素
//调整位置
console.log(i.id);
console.log(currentID);
if(i.id==currentID){
tmpMap.delete(lastData.id);
tmpMap.set(i.id,i);
tmpMap.set(lastData.id,lastData);
}
else{
tmpMap.set(i.id,i);
}
lastData=i;
});
objList=tmpMap;
drawSVG();
}
catch(e){
}
}
//移动到最上层
function moveTopLevel(){
if(!checkSelect()){
return;
}
let tmp=objList.get(currentID);
objList.delete(currentID);
objList.set(currentID,tmp);
drawSVG();
}
//移动到最底层
function moveLowestLevel(){
if(!checkSelect()){
return;
}
let tmp=objList.get(currentID);
objList.delete(currentID);
let tmpMap=new Map();
tmpMap.set(currentID,tmp);
objList.forEach(i=>{
tmpMap.set(i.id,i);
});
objList=tmpMap;
drawSVG();
}