Add option to configure opacity
Browse files- index.html +20 -0
- src/config.ts +2 -0
- src/stage.ts +2 -1
index.html
CHANGED
|
@@ -81,6 +81,8 @@
|
|
| 81 |
<button id="simple-highlight-btn">Simple Highlight</button>
|
| 82 |
<button id="transition-highlight-btn">Multiple Highlight Calls</button>
|
| 83 |
<button id="disallow-close">Disallow Close</button>
|
|
|
|
|
|
|
| 84 |
<button id="tour-btn">Start Tour</button>
|
| 85 |
<button id="destroy-btn">Destroy</button>
|
| 86 |
</div>
|
|
@@ -105,6 +107,24 @@
|
|
| 105 |
driver({ animate: false }).highlight({ element: "ul" });
|
| 106 |
});
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
document
|
| 109 |
.getElementById("transition-highlight-btn")
|
| 110 |
.addEventListener("click", () => {
|
|
|
|
| 81 |
<button id="simple-highlight-btn">Simple Highlight</button>
|
| 82 |
<button id="transition-highlight-btn">Multiple Highlight Calls</button>
|
| 83 |
<button id="disallow-close">Disallow Close</button>
|
| 84 |
+
<button id="dark-highlight-btn">Super Dark Highlight</button>
|
| 85 |
+
<button id="dim-highlight-btn">Super Dim Highlight</button>
|
| 86 |
<button id="tour-btn">Start Tour</button>
|
| 87 |
<button id="destroy-btn">Destroy</button>
|
| 88 |
</div>
|
|
|
|
| 107 |
driver({ animate: false }).highlight({ element: "ul" });
|
| 108 |
});
|
| 109 |
|
| 110 |
+
document
|
| 111 |
+
.getElementById("dark-highlight-btn")
|
| 112 |
+
.addEventListener("click", () => {
|
| 113 |
+
driver({
|
| 114 |
+
animate: true,
|
| 115 |
+
opacity: 0.9,
|
| 116 |
+
}).highlight({ element: "ul" });
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
document
|
| 120 |
+
.getElementById("dim-highlight-btn")
|
| 121 |
+
.addEventListener("click", () => {
|
| 122 |
+
driver({
|
| 123 |
+
animate: true,
|
| 124 |
+
opacity: 0.2,
|
| 125 |
+
}).highlight({ element: ".buttons" });
|
| 126 |
+
});
|
| 127 |
+
|
| 128 |
document
|
| 129 |
.getElementById("transition-highlight-btn")
|
| 130 |
.addEventListener("click", () => {
|
src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
export type Config = {
|
| 2 |
animate?: boolean;
|
| 3 |
allowClose?: boolean;
|
|
|
|
| 4 |
};
|
| 5 |
|
| 6 |
let currentConfig: Config = {};
|
|
@@ -9,6 +10,7 @@ export function configure(config: Config = {}) {
|
|
| 9 |
currentConfig = {
|
| 10 |
animate: true,
|
| 11 |
allowClose: true,
|
|
|
|
| 12 |
...config,
|
| 13 |
};
|
| 14 |
}
|
|
|
|
| 1 |
export type Config = {
|
| 2 |
animate?: boolean;
|
| 3 |
allowClose?: boolean;
|
| 4 |
+
opacity?: number;
|
| 5 |
};
|
| 6 |
|
| 7 |
let currentConfig: Config = {};
|
|
|
|
| 10 |
currentConfig = {
|
| 11 |
animate: true,
|
| 12 |
allowClose: true,
|
| 13 |
+
opacity: 0.7,
|
| 14 |
...config,
|
| 15 |
};
|
| 16 |
}
|
src/stage.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { easeInOutQuad } from "./math";
|
| 2 |
import { onDriverClick } from "./events";
|
| 3 |
import { trigger } from "./hooks";
|
|
|
|
| 4 |
|
| 5 |
export type StageDefinition = {
|
| 6 |
x: number;
|
|
@@ -158,7 +159,7 @@ function createStageSvg(stage: StageDefinition): SVGSVGElement {
|
|
| 158 |
cutoutPath.setAttribute("d", generateSvgCutoutPathString(stage));
|
| 159 |
|
| 160 |
cutoutPath.style.fill = "rgb(0,0,0)";
|
| 161 |
-
cutoutPath.style.opacity =
|
| 162 |
cutoutPath.style.pointerEvents = "auto";
|
| 163 |
cutoutPath.style.cursor = "auto";
|
| 164 |
|
|
|
|
| 1 |
import { easeInOutQuad } from "./math";
|
| 2 |
import { onDriverClick } from "./events";
|
| 3 |
import { trigger } from "./hooks";
|
| 4 |
+
import { getConfig } from "./config";
|
| 5 |
|
| 6 |
export type StageDefinition = {
|
| 7 |
x: number;
|
|
|
|
| 159 |
cutoutPath.setAttribute("d", generateSvgCutoutPathString(stage));
|
| 160 |
|
| 161 |
cutoutPath.style.fill = "rgb(0,0,0)";
|
| 162 |
+
cutoutPath.style.opacity = `${getConfig("opacity")}`;
|
| 163 |
cutoutPath.style.pointerEvents = "auto";
|
| 164 |
cutoutPath.style.cursor = "auto";
|
| 165 |
|