@atlaskit/motion
Version:
A set of utilities to apply motion in your application.
41 lines (40 loc) • 1.59 kB
TypeScript
import type { MotionDuration, MotionEasing } from '@atlaskit/tokens/css-type-schema';
import { type CallbackRef } from '../utils/use-element-ref';
type ResizingDimension = 'width' | 'height' | 'both';
export interface ResizingOpts {
/**
* Which dimension(s) to animate. One of `'width'`, `'height'`, or `'both'`.
*/
dimension: ResizingDimension;
/**
* Duration of the resize transition as a design token CSS variable.
*
* Accepts a `MotionDuration` token value, e.g. `token('motion.duration.medium')`.
*/
duration: MotionDuration;
/**
* Easing of the resize transition as a design token CSS variable.
*
* Accepts a `MotionEasing` token value, e.g. `token('motion.easing.inout.bold')`.
*/
easing: MotionEasing;
/**
* Callback fired once the resize animation has completed,
* or when a pending resize is suppressed. With observed resizing, unchanged renders do not
* fire this callback.
*/
onFinishMotion?: () => void;
/**
* Callback fired immediately before a resize animation starts, while the element is still at
* its natural layout with no transition styles applied. Measurements taken here reflect the
* size the element will settle at, rather than an intermediate animation frame.
*
* Not called on the initial render, under reduced motion,
* or when the dimension(s) did not change (no animation was needed).
*/
onStartMotion?: () => void;
}
export declare const useResizing: (opts: ResizingOpts) => {
ref: CallbackRef;
};
export {};