UNPKG

@kcirtaptrick/framer-motion

Version:

A simple and powerful React animation library

26 lines (23 loc) 759 B
import { addUniqueItem, removeItem } from '../../utils/array.mjs'; import { compareByDepth } from './compare-by-depth.mjs'; var FlatTree = /** @class */ (function () { function FlatTree() { this.children = []; this.isDirty = false; } FlatTree.prototype.add = function (child) { addUniqueItem(this.children, child); this.isDirty = true; }; FlatTree.prototype.remove = function (child) { removeItem(this.children, child); this.isDirty = true; }; FlatTree.prototype.forEach = function (callback) { this.isDirty && this.children.sort(compareByDepth); this.isDirty = false; this.children.forEach(callback); }; return FlatTree; }()); export { FlatTree };