MCPcopy Create free account
hub / github.com/microsoft/SandDance / getNextState

Function getNextState

docs/app/js/sanddance-app.js:42108–42125  ·  view source on GitHub ↗
(props, currentState, getElementToMeasureDimension, newContainerDimension)

Source from the content-addressed store, hash-verified

42106 });
42107 }
42108 function getNextState(props, currentState, getElementToMeasureDimension, newContainerDimension) {
42109 // If there is no new container width/height or data to measure, there is no need for a new state update
42110 if (newContainerDimension === undefined && currentState.dataToMeasure === undefined) return undefined;
42111 if (newContainerDimension) {
42112 // If we know the last container size and we rendered data at that width/height, we can do an optimized render
42113 if (_containerDimension && currentState.renderedData && !currentState.dataToMeasure) return (0, _tslib.__assign)((0, _tslib.__assign)({}, currentState), _updateContainerDimension(newContainerDimension, props.data, currentState.renderedData, props.onGrowData));
42114 // If we are just setting the container width/height for the first time, we can't do any optimizations
42115 _containerDimension = newContainerDimension;
42116 }
42117 var nextState = (0, _tslib.__assign)((0, _tslib.__assign)({}, currentState), {
42118 measureContainer: false
42119 });
42120 if (currentState.dataToMeasure) {
42121 if (currentState.resizeDirection === "grow" && props.onGrowData) nextState = (0, _tslib.__assign)((0, _tslib.__assign)({}, nextState), _growDataUntilItDoesNotFit(currentState.dataToMeasure, props.onGrowData, getElementToMeasureDimension, props.onReduceData));
42122 else nextState = (0, _tslib.__assign)((0, _tslib.__assign)({}, nextState), _shrinkContentsUntilTheyFit(currentState.dataToMeasure, props.onReduceData, getElementToMeasureDimension));
42123 }
42124 return nextState;
42125 }
42126 /** Function that determines if we need to render content for measurement based on the measurement cache contents. */ function shouldRenderDataForMeasurement(dataToMeasure) {
42127 if (!dataToMeasure || _measurementCache.getCachedMeasurement(dataToMeasure) !== undefined) return false;
42128 return true;

Callers

nothing calls this directly

Calls 3

Tested by

no test coverage detected