fix: 修复链队列问题

This commit is contained in:
黎智洲 2021-07-31 21:28:44 +08:00
parent dbb69b9e21
commit 0ef21a6268
4 changed files with 21 additions and 8 deletions

2
dist/sv.js vendored

File diff suppressed because one or more lines are too long

View File

@ -32,10 +32,18 @@ export const Util = {
* @param list
* @param fn
*/
removeFromList<T>(list: T[], fn: (item: T) => boolean) {
removeFromList<T>(list: T[], fn: (item: T) => boolean): T[] {
const res: T[] = [];
for(let i = 0; i < list.length; i++) {
fn(list[i]) && list.splice(i, 1) && i--;
if(fn(list[i])) {
let removeItem = list.splice(i, 1);
res.push(...removeItem);
i--;
}
}
return res;
},
/**

View File

@ -21,6 +21,8 @@ export const Animations = {
* @param animationConfig
*/
animate_append(model: Model, animationConfig: animationConfig) {
model.G6Item === null && console.log(model);
const G6Item = model.G6Item,
type = G6Item.getType(),
group = G6Item.getContainer(),

View File

@ -79,14 +79,17 @@ export class ViewManager {
freedGroup = layoutGroupTable.get(freedGroupName);
freedList.forEach(fItem => {
removeModels.push(...freedGroup.element.splice(freedGroup.element.findIndex(item => item.id === fItem.id), 1));
removeModels.push(...freedGroup.link.splice(freedGroup.link.findIndex(item => item.element.id === fItem.id || item.target.id === fItem.id)));
removeModels.push(...freedGroup.marker.splice(freedGroup.marker.findIndex(item => item.target.id === fItem.id)));
removeModels.push(
...Util.removeFromList(freedGroup.element, item => item.id === fItem.id),
...Util.removeFromList(freedGroup.link, item => item.element.id === fItem.id || item.target.id === fItem.id),
...Util.removeFromList(freedGroup.marker, item => item.target.id === fItem.id),
);
});
console.log(removeModels);
removeModels.map(model => {
const index = freedGroup.modelList.findIndex(item => item.id === model.id);
freedGroup.modelList.splice(index, 1);
Util.removeFromList(freedGroup.modelList, item => item.id === model.id);
});
return freedList;