Add refresh functionality
Browse files- index.html +2 -1
- src/driver.ts +11 -2
- src/style.css +1 -1
    	
        index.html
    CHANGED
    
    | @@ -141,6 +141,7 @@ | |
| 141 | 
             
                <button id="without-element-btn">No Element</button>
         | 
| 142 | 
             
                <button id="is-active-btn">Is Active?</button>
         | 
| 143 | 
             
                <button id="activate-check-btn">Activate and Check</button>
         | 
|  | |
| 144 | 
             
                <button id="destroy-btn">Destroy</button>
         | 
| 145 | 
             
              </div>
         | 
| 146 |  | 
| @@ -302,7 +303,6 @@ npm install driver.js</pre | |
| 302 | 
             
              document.getElementById("highlight-btn").addEventListener("click", () => {
         | 
| 303 | 
             
                driver({
         | 
| 304 | 
             
                  animate: true,
         | 
| 305 | 
            -
                  showButtons: false,
         | 
| 306 | 
             
                  popoverOffset: 10,
         | 
| 307 | 
             
                }).highlight({
         | 
| 308 | 
             
                  element: "h2",
         | 
| @@ -311,6 +311,7 @@ npm install driver.js</pre | |
| 311 | 
             
                    description: "A lightweight, no-dependency JavaScript engine to drive user's focus.",
         | 
| 312 | 
             
                    side: "bottom",
         | 
| 313 | 
             
                    align: "start",
         | 
|  | |
| 314 | 
             
                  },
         | 
| 315 | 
             
                });
         | 
| 316 | 
             
              });
         | 
|  | |
| 141 | 
             
                <button id="without-element-btn">No Element</button>
         | 
| 142 | 
             
                <button id="is-active-btn">Is Active?</button>
         | 
| 143 | 
             
                <button id="activate-check-btn">Activate and Check</button>
         | 
| 144 | 
            +
                <button id="modify-refresh">Modify Active + Refresh</button>
         | 
| 145 | 
             
                <button id="destroy-btn">Destroy</button>
         | 
| 146 | 
             
              </div>
         | 
| 147 |  | 
|  | |
| 303 | 
             
              document.getElementById("highlight-btn").addEventListener("click", () => {
         | 
| 304 | 
             
                driver({
         | 
| 305 | 
             
                  animate: true,
         | 
|  | |
| 306 | 
             
                  popoverOffset: 10,
         | 
| 307 | 
             
                }).highlight({
         | 
| 308 | 
             
                  element: "h2",
         | 
|  | |
| 311 | 
             
                    description: "A lightweight, no-dependency JavaScript engine to drive user's focus.",
         | 
| 312 | 
             
                    side: "bottom",
         | 
| 313 | 
             
                    align: "start",
         | 
| 314 | 
            +
                    showButtons: true,
         | 
| 315 | 
             
                  },
         | 
| 316 | 
             
                });
         | 
| 317 | 
             
              });
         | 
    	
        src/driver.ts
    CHANGED
    
    | @@ -2,7 +2,7 @@ import { destroyPopover, Popover } from "./popover"; | |
| 2 | 
             
            import { destroyStage } from "./stage";
         | 
| 3 | 
             
            import { destroyEvents, initEvents } from "./events";
         | 
| 4 | 
             
            import { Config, configure, getConfig } from "./config";
         | 
| 5 | 
            -
            import { destroyHighlight, highlight } from "./highlight";
         | 
| 6 | 
             
            import { destroyEmitter, listen } from "./emitter";
         | 
| 7 |  | 
| 8 | 
             
            import "./style.css";
         | 
| @@ -52,10 +52,19 @@ export function driver(options: Config = {}) { | |
| 52 |  | 
| 53 | 
             
              return {
         | 
| 54 | 
             
                isActive: () => getState("isInitialized") || false,
         | 
|  | |
|  | |
|  | |
| 55 | 
             
                drive: (steps: DriveStep[]) => console.log(steps),
         | 
| 56 | 
             
                highlight: (step: DriveStep) => {
         | 
| 57 | 
             
                  init();
         | 
| 58 | 
            -
                  highlight( | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 59 | 
             
                },
         | 
| 60 | 
             
                destroy,
         | 
| 61 | 
             
              };
         | 
|  | |
| 2 | 
             
            import { destroyStage } from "./stage";
         | 
| 3 | 
             
            import { destroyEvents, initEvents } from "./events";
         | 
| 4 | 
             
            import { Config, configure, getConfig } from "./config";
         | 
| 5 | 
            +
            import { destroyHighlight, highlight, refreshActiveHighlight } from "./highlight";
         | 
| 6 | 
             
            import { destroyEmitter, listen } from "./emitter";
         | 
| 7 |  | 
| 8 | 
             
            import "./style.css";
         | 
|  | |
| 52 |  | 
| 53 | 
             
              return {
         | 
| 54 | 
             
                isActive: () => getState("isInitialized") || false,
         | 
| 55 | 
            +
                refresh: () => {
         | 
| 56 | 
            +
                  refreshActiveHighlight();
         | 
| 57 | 
            +
                },
         | 
| 58 | 
             
                drive: (steps: DriveStep[]) => console.log(steps),
         | 
| 59 | 
             
                highlight: (step: DriveStep) => {
         | 
| 60 | 
             
                  init();
         | 
| 61 | 
            +
                  highlight({
         | 
| 62 | 
            +
                    ...step,
         | 
| 63 | 
            +
                    popover: step.popover ? {
         | 
| 64 | 
            +
                      showButtons: false,
         | 
| 65 | 
            +
                      ...step.popover!,
         | 
| 66 | 
            +
                    } : undefined,
         | 
| 67 | 
            +
                  });
         | 
| 68 | 
             
                },
         | 
| 69 | 
             
                destroy,
         | 
| 70 | 
             
              };
         | 
    	
        src/style.css
    CHANGED
    
    | @@ -59,7 +59,7 @@ | |
| 59 | 
             
              margin: 0;
         | 
| 60 | 
             
            }
         | 
| 61 |  | 
| 62 | 
            -
            .driver-popover-title + .driver-popover-description {
         | 
| 63 | 
             
              margin-top: 5px;
         | 
| 64 | 
             
            }
         | 
| 65 |  | 
|  | |
| 59 | 
             
              margin: 0;
         | 
| 60 | 
             
            }
         | 
| 61 |  | 
| 62 | 
            +
            .driver-popover-title[style*="block"] + .driver-popover-description {
         | 
| 63 | 
             
              margin-top: 5px;
         | 
| 64 | 
             
            }
         | 
| 65 |  |