File size: 1,052 Bytes
9bde4cc 836d49f 9bde4cc 1d8c3af 9bde4cc aafd6df ec183be 1d8c3af 9bde4cc 1d8c3af 836d49f ec183be 836d49f ec183be 836d49f 9bde4cc 836d49f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import { StageDefinition } from "./stage";
import { PopoverDOM } from "./popover";
import { DriveStep } from "./driver";
export type State = {
// Whether driver is initialized or not
isInitialized?: boolean;
// Index of the currently active step in driver tour
activeIndex?: number;
// Used to bounce the resize event
resizeTimeout?: number;
// Used while transitioning between stages
activeElement?: Element;
activeStep?: DriveStep;
previousElement?: Element;
previousStep?: DriveStep;
transitionCallback?: () => void;
activeStagePosition?: StageDefinition;
stageSvg?: SVGSVGElement;
popover?: PopoverDOM;
};
let currentState: State = {};
export function setState<K extends keyof State>(key: K, value: State[K]) {
currentState[key] = value;
}
export function getState(): State;
export function getState<K extends keyof State>(key: K): State[K];
export function getState<K extends keyof State>(key?: K) {
return key ? currentState[key] : currentState;
}
export function resetState() {
currentState = {};
}
|