UNPKG

rn-custom-style-sheet

Version:

React Native component to select a specific value from a range of values.

26 lines 977 B
export function getCurrentBreakpointIndex(values, screenWidth) { const dimensionValues = Object.values(values); let index = -1; for (let i = 0; i < dimensionValues.length; i++) { const vl = dimensionValues[i]; if (vl && vl === screenWidth) { index = i; break; } else if (vl && vl > screenWidth && i !== 0) { index = i - 1; break; } else if (vl && vl < screenWidth && i === dimensionValues.length - 1) { index = i; break; } } return index; } export function getBreakpointValueByIndex(values, breakpointIndex, guideLineBreakpoint) { const { values: breakpointValues } = guideLineBreakpoint; const valArray = Array.isArray(values) ? values : Object.keys(breakpointValues).map(point => values[point] || '').filter(point => point !== ''); return valArray[breakpointIndex] ?? valArray.slice(0, breakpointIndex + 1).filter(v => !(v === null || v === undefined)).pop(); } //# sourceMappingURL=Utility.js.map