UNPKG

@studiometa/js-toolkit

Version:

A set of useful little bits of JavaScript to boost your project! 🚀

29 lines (28 loc) • 1.08 kB
import type { NormalizedOffset } from './types.js'; /** * Normalize offset input. */ export declare function normalizeOffset(offsets: string): NormalizedOffset; /** * Parse the given offset. */ export declare function parseNamedOffset(offset: string | number): string | number; /** * Get an edge value given a start, size and offset value. */ export declare function getEdgeWithOffset(start: number, size: number, offset: string | number): number; type HorizontalOnlyRect = { x: number; width: number; }; type VerticalOnlyRect = { y: number; height: number; }; type HorizontalRect = HorizontalOnlyRect & Partial<VerticalOnlyRect>; type VerticalRect = Partial<HorizontalOnlyRect> & VerticalOnlyRect; /** * Get starting and ending edges for a given axis, a target sizings, a container sizings and their offset. */ export declare function getEdges<T extends 'x' | 'y'>(axis: T, targetSizes: T extends 'x' ? HorizontalRect : VerticalRect, containerSizes: T extends 'x' ? HorizontalRect : VerticalRect, offset: NormalizedOffset): [number, number]; export {};