File size: 702 Bytes
aa3b624
 
 
6770eb3
aa3b624
 
 
 
 
 
 
8ff0f16
aa3b624
 
 
 
 
8ff0f16
aa3b624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { initEvents, destroyEvents } from "./events";
import { destroyHighlight, highlight } from "./highlight";
import { destroyStage } from "./stage";
import "./style.css";

export type DriveStep = {
  element?: string | Element;
};

export function driver() {
  function init() {
    document.body.classList.add("driver-active", "driver-fade");

    initEvents();
  }

  function destroy() {
    document.body.classList.remove("driver-active", "driver-fade");

    destroyEvents();
    destroyHighlight();
    destroyStage();
  }

  return {
    drive: (steps: DriveStep[]) => console.log(steps),
    highlight: (step: DriveStep) => {
      init();
      highlight(step);
    },
    destroy,
  };
}