node_modules/framer-motion/dist/es/components/AnimateSharedLayout/utils/batcher.js
/**
 * Create a batcher to process VisualElements
 */
Create a batcher to process VisualElements
Create a batcher to process VisualElements
function createBatcher() {
    var queue = new Set();
    return {
        add: function (child) { return queue.add(child); },
        flush: function (_a) {
            var _b = _a === void 0 ? defaultHandler : _a, measureLayout = _b.measureLayout, layoutReady = _b.layoutReady, parent = _b.parent;
            var order = Array.from(queue).sort(compareByDepth);
            var resetAndMeasure = function () {
                order.forEach(function (child) { return child.resetTransform(); });
                order.forEach(measureLayout);
            };
            parent
                ? parent.withoutTransform(resetAndMeasure)
                : resetAndMeasure();
            order.forEach(layoutReady);
            order.forEach(function (child) {
                if (child.isPresent)
                    child.presence = Presence.Present;
            });
            flushSync.preRender();
            flushSync.render();
            queue.clear();
        },
    };
}
function createBatcher ( ) { var queue = new Set ( ) ; return { add : function ( child ) { return queue . add ( child ) ; } , flush : function ( _a ) { var _b = _a === void 0 ? defaultHandler : _a , measureLayout = _b . measureLayout , layoutReady = _b . layoutReady , parent = _b . parent ; var order = Array . from ( queue ) . sort ( compareByDepth ) ; var resetAndMeasure = function ( ) { order . forEach ( function ( child ) { return child . resetTransform ( ) ; } ) ; order . forEach ( measureLayout ) ; } ; parent ? parent . withoutTransform ( resetAndMeasure ) : resetAndMeasure ( ) ; order . forEach ( layoutReady ) ; order . forEach ( function ( child ) { if ( child . isPresent ) child . presence = Presence . Present ; } ) ; flushSync . preRender ( ) ; flushSync . render ( ) ; queue . clear ( ) ; } , } ; }
Create a batcher to process VisualElements
Create a batcher to process VisualElements
/**
                 * Write: Reset any transforms on children elements so we can read their actual layout
                 */ /**
                 * Read: Measure the actual layout
                 */ /**
             * Write: Notify the VisualElements they're ready for further write operations.
             */ /**
             * After all children have started animating, ensure any Entering components are set to Present.
             * If we add deferred animations (set up all animations and then start them in two loops) this
             * could be moved to the start loop. But it needs to happen after all the animations configs
             * are generated in AnimateSharedLayout as this relies on presence data
             */ /**
             * Starting these animations will have queued jobs on the frame loop. In some situations,
             * like when removing an element, these will be processed too late after the DOM is manipulated,
             * leaving a flash of incorrectly-projected content. By manually flushing these jobs
             * we ensure there's no flash.
             */