UNPKG

react-native-sortables

Version:

Powerful Sortable Components for Flexible Content Reordering in React Native

93 lines (90 loc) 2.34 kB
"use strict"; const DEBUG_COLORS = { backgroundColor: '#CE00B5', borderColor: '#4E0044' }; export const handleMeasurementsVertical = (threshold, maxOverScrollOffset, touchOffset, scrollableMeasurements, containerMeasurements, debugRects, debugLine) => { 'worklet'; const { height: sH, pageY: sY } = scrollableMeasurements; const { height: cH, pageY: cY } = containerMeasurements; maxOverScrollOffset ??= threshold; const startDistance = sY + maxOverScrollOffset[0] - cY; const endDistance = cY + cH - (sY + sH - maxOverScrollOffset[1]); const startOverflow = sY + threshold[0] - (cY + touchOffset); const endOverflow = cY + touchOffset - (sY + sH - threshold[1]); if (debugRects) { debugRects.start.set({ ...DEBUG_COLORS, height: threshold[0], y: sY - cY }); debugRects.end.set({ ...DEBUG_COLORS, height: threshold[1], positionOrigin: 'bottom', y: sY - cY + sH }); } if (debugLine) { debugLine.set({ color: DEBUG_COLORS.backgroundColor, y: touchOffset }); } return { containerPosition: cY, endDistance, endOverflow, startDistance, startOverflow }; }; export const handleMeasurementsHorizontal = (threshold, maxOverScrollOffset, touchOffset, scrollableMeasurements, containerMeasurements, debugRects, debugLine) => { 'worklet'; const { pageX: sX, width: sW } = scrollableMeasurements; const { pageX: cX, width: cW } = containerMeasurements; maxOverScrollOffset ??= threshold; const startDistance = sX + maxOverScrollOffset[0] - cX; const endDistance = cX + cW - (sX + sW - maxOverScrollOffset[1]); const startOverflow = sX + threshold[0] - (cX + touchOffset); const endOverflow = cX + touchOffset - (sX + sW - threshold[1]); if (debugRects) { debugRects.start.set({ ...DEBUG_COLORS, width: threshold[0], x: sX - cX }); debugRects.end.set({ ...DEBUG_COLORS, positionOrigin: 'right', width: threshold[1], x: sX - cX + sW }); } if (debugLine) { debugLine.set({ color: DEBUG_COLORS.backgroundColor, x: touchOffset }); } return { containerPosition: cX, endDistance, endOverflow, startDistance, startOverflow }; }; //# sourceMappingURL=utils.js.map