suspend-vue
Version:
一个悬浮窗组件,支持组件形式 / 自定义指令
49 lines (48 loc) • 1.42 kB
TypeScript
import { Ref } from "vue";
/**
* 用于标记组件
*/
export declare const SuspendBoxFlag = "suspend-box";
export declare type SuspendProps = {
/** 窗口模式 */
model?: "window" | "default";
/** 是否可以在 x / y 轴移动 */
move?: Partial<{
x: boolean;
y: boolean;
}>;
/** 是否开启吸附贴边功能 */
adsorption?: Partial<{
x: boolean;
y: boolean;
}>;
/** 初始位置 */
defaultSite?: Partial<{
x: string | number;
y: string | number;
top: string | number;
left: string | number;
}>;
/** 动画时长,为 0 则停止动画(默认为 ms ) */
delay?: number;
/** 点击 slot 内容区域是否可以拖动 */
contentMove?: boolean;
zIndex?: number;
};
export declare type SuspendCallbackOption = Partial<{
click: Function;
moveStart: Function;
moveEnd: Function;
}>;
/**
* @description: 用于实现一个拖拽组件
* @param {Ref} _suspendBox 目标dom
* @param {T} props 需要传入的一些配置项
* @param {Object} callback 一些回调函数
* @return {*}
*/
export default function useSuspend(targetDom: Ref<HTMLElement | undefined> | HTMLElement, props: SuspendProps, callback?: SuspendCallbackOption): {
unmount: () => void;
/** 重新获取 box 的样式 */
reset: () => void;
};