Files
ETB/ETB-FrontEnd/node_modules/framer-motion/dist/es/render/utils/flat-tree.mjs
Iliyan Angelov 306b20e24a Frontend start
2025-09-14 00:54:48 +03:00

25 lines
596 B
JavaScript

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 };