UNPKG

lucky-canvas-z

Version:

一个基于原生 js 的(大转盘 / 九宫格 / 老虎机)抽奖插件

85 lines (84 loc) 2.79 kB
import { FontItemType, ImgItemType, BackgroundType, FontExtendType } from "./index"; export type PrizeFontType = FontItemType & FontExtendType & { textDirection?: "horizontal" | "vertical"; fontVisible?: boolean; }; export type ButtonFontType = FontItemType & {}; export type BlockImgType = ImgItemType & { rotate?: boolean; }; export type PrizeImgType = ImgItemType & {}; export type ButtonImgType = ImgItemType & {}; export type BlockType = { padding?: string; background?: BackgroundType; imgs?: Array<BlockImgType>; }; export type PrizeType = { range?: number; _computedAngle?: number; angle?: number; background?: BackgroundType; fonts?: Array<PrizeFontType>; imgs?: Array<PrizeImgType>; activeBackground?: string; activeBorder?: string; activeBorderWidth?: string; multipleSelectable?: boolean; activeFontColor?: ButtonFontType["fontColor"]; }; export type ButtonType = { radius?: string; pointer?: boolean; background?: BackgroundType; fonts?: Array<ButtonFontType>; imgs?: Array<ButtonImgType>; }; export type DefaultConfigType = { gutter?: string | number; offsetDegree?: number; speed?: number; speedFunction?: string; accelerationTime?: number; decelerationTime?: number; stopRange?: number; autoAngle?: boolean; canSelect?: boolean; }; export type DefaultStyleType = { background?: BackgroundType; fontColor?: PrizeFontType["fontColor"]; fontSize?: PrizeFontType["fontSize"]; fontStyle?: PrizeFontType["fontStyle"]; fontWeight?: PrizeFontType["fontWeight"]; lineHeight?: PrizeFontType["lineHeight"]; wordWrap?: PrizeFontType["wordWrap"]; lengthLimit?: PrizeFontType["lengthLimit"]; lineClamp?: PrizeFontType["lineClamp"]; activeBackground?: string; activeBorder?: string; activeBorderWidth?: string; multipleSelectable?: boolean; activeFontColor?: ButtonFontType["fontColor"]; circleRadius?: number; circleColor?: string; circleVisible?: boolean; textDirection?: "horizontal" | "vertical"; fontVisible?: boolean; opacity?: number; }; export type StartCallbackType = (e: MouseEvent) => void; export type EndCallbackType = (prize: object, index: number) => void; export type SelectCallbackType = (prizes: Array<number>) => void; export default interface LuckyWheelConfig { width: string | number; height: string | number; blocks?: Array<BlockType>; prizes?: Array<PrizeType>; buttons?: Array<ButtonType>; defaultConfig?: DefaultConfigType; defaultStyle?: DefaultStyleType; start?: StartCallbackType; end?: EndCallbackType; select?: SelectCallbackType; }