@studiometa/js-toolkit
Version:
A set of useful little bits of JavaScript to boost your project! 🚀
30 lines (29 loc) • 1.24 kB
TypeScript
import type { ServiceConfig, ServiceInterface } from './AbstractService.js';
import { AbstractService } from './AbstractService.js';
import type { Features } from '../Base/features.js';
export interface ResizeServiceProps<U extends Features['breakpoints'] = Features['breakpoints']> {
width: number;
height: number;
ratio: number;
orientation: 'square' | 'landscape' | 'portrait';
breakpoint: keyof U;
breakpoints: Array<keyof U>;
activeBreakpoints: Record<keyof U, boolean>;
}
export type ResizeServiceInterface<U extends Features['breakpoints'] = Features['breakpoints']> = ServiceInterface<ResizeServiceProps<U>>;
export declare class ResizeService<T extends Features['breakpoints'] = Features['breakpoints']> extends AbstractService<ResizeServiceProps<T>> {
static config: ServiceConfig;
breakpoints: T;
props: ResizeServiceProps<T>;
constructor(breakpoints: T);
/**
* Update props.
*/
updateProps(): ResizeServiceProps<T>;
onResizeDebounce: (...args: unknown[]) => void;
handleEvent(): void;
}
/**
* Use the resize service.
*/
export declare function useResize<T extends Features['breakpoints'] = Features['breakpoints']>(breakpoints?: T): ResizeServiceInterface<T>;