Blame view

天文台pc/tianwentai-ui/node_modules/motion-dom/dist/es/projection/utils/flat-tree.mjs 635 Bytes
bc518174   王天杨   提交两个项目文件
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
  import { addUniqueItem, removeItem } from 'motion-utils';
  import { compareByDepth } from './compare-by-depth.mjs';
  
  class FlatTree {
      constructor() {
          this.children = [];
          this.isDirty = false;
      }
      add(child) {
          addUniqueItem(this.children, child);
          this.isDirty = true;
      }
      remove(child) {
          removeItem(this.children, child);
          this.isDirty = true;
      }
      forEach(callback) {
          this.isDirty && this.children.sort(compareByDepth);
          this.isDirty = false;
          this.children.forEach(callback);
      }
  }
  
  export { FlatTree };
  //# sourceMappingURL=flat-tree.mjs.map