wheel-fortune
Version:
A lightweight, customizable spinning wheel component for web games and raffles
61 lines (56 loc) • 1.54 kB
TypeScript
export declare type SpinState = {
targetAngle: number;
callback?: () => void;
};
export declare type SwayOptions = {
amplitude?: number;
period?: number;
};
declare class WheelFortune {
private readonly options;
private rootElement;
private wheelElement;
private triggerElement;
private swayAnimation;
private swayingElement;
private finalRotation;
private readonly rotationCount;
private readonly duration;
private readonly overshootDeg;
private readonly returnDuration;
private readonly swayAmplitude;
private readonly swayPeriod;
private readonly rootClassName;
private readonly spinStates;
private currentSpinIndex;
private hasSpun;
private warmedUp;
private readonly onClick;
constructor(options: Readonly<WheelFortuneOptions>);
init(): void;
destroy(): void;
reset(): void;
private warmUp;
private decodeImages;
private runSpin;
private rotateWheelTo;
private startSway;
private stopSway;
private normalize;
private getCurrentRotation;
private cancelAnimations;
}
export { WheelFortune }
export default WheelFortune;
export declare type WheelFortuneOptions = {
rootSelector: string;
wheelSelector: string;
triggerSelector: string;
rotationCount?: number;
duration?: number;
overshootDeg?: number;
returnDuration?: number;
swayOptions?: SwayOptions;
spinStates?: SpinState[];
};
export { }