getClosestOffsets<StateType> method
(double, double)
getClosestOffsets<StateType>(
- double offset,
- MultiStateSheetExtent<
StateType> extent
Finds the two closest snapping offsets to the given offset.
offset: The current offset of the sheet.extent: The current extent of the sheet.- Returns: A record of the closest offsets before and after the given offset.
Implementation
(double first, double last) getClosestOffsets<StateType>(
double offset,
MultiStateSheetExtent<StateType> extent,
) =>
cachedClosestOffsets.putIfAbsent(extent.offset, offset, () {
final double firstOffset = getFirstOffsetAfter(offset);
final double lastOffset = getLastOffsetBefore(offset);
return (
clampDouble(firstOffset, extent.minOffset, extent.maxOffset),
clampDouble(lastOffset, extent.minOffset, extent.maxOffset),
);
});