Add support for changing backdrop color
Browse files- index.html +10 -1
- src/config.ts +2 -0
- src/stage.ts +1 -1
index.html
CHANGED
|
@@ -141,7 +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="
|
| 145 |
<button id="destroy-btn">Destroy</button>
|
| 146 |
</div>
|
| 147 |
|
|
@@ -276,6 +276,15 @@ npm install driver.js</pre
|
|
| 276 |
alert(driver().isActive());
|
| 277 |
});
|
| 278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
document.getElementById("activate-check-btn").addEventListener("click", () => {
|
| 280 |
const driverObj = driver({
|
| 281 |
showButtons: false,
|
|
|
|
| 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="backdrop-color-btn">Backdrop Color</button>
|
| 145 |
<button id="destroy-btn">Destroy</button>
|
| 146 |
</div>
|
| 147 |
|
|
|
|
| 276 |
alert(driver().isActive());
|
| 277 |
});
|
| 278 |
|
| 279 |
+
document.getElementById("backdrop-color-btn").addEventListener("click", () => {
|
| 280 |
+
driver({
|
| 281 |
+
backdropColor: "blue",
|
| 282 |
+
opacity: 0.3,
|
| 283 |
+
}).highlight({
|
| 284 |
+
element: "#backdrop-color-btn",
|
| 285 |
+
});
|
| 286 |
+
});
|
| 287 |
+
|
| 288 |
document.getElementById("activate-check-btn").addEventListener("click", () => {
|
| 289 |
const driverObj = driver({
|
| 290 |
showButtons: false,
|
src/config.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { DriveStep } from "./driver";
|
|
| 2 |
|
| 3 |
export type Config = {
|
| 4 |
animate?: boolean;
|
|
|
|
| 5 |
smoothScroll?: boolean;
|
| 6 |
allowClose?: boolean;
|
| 7 |
opacity?: number;
|
|
@@ -26,6 +27,7 @@ export function configure(config: Config = {}) {
|
|
| 26 |
stageRadius: 5,
|
| 27 |
popoverOffset: 10,
|
| 28 |
showButtons: true,
|
|
|
|
| 29 |
...config,
|
| 30 |
};
|
| 31 |
}
|
|
|
|
| 2 |
|
| 3 |
export type Config = {
|
| 4 |
animate?: boolean;
|
| 5 |
+
backdropColor?: string;
|
| 6 |
smoothScroll?: boolean;
|
| 7 |
allowClose?: boolean;
|
| 8 |
opacity?: number;
|
|
|
|
| 27 |
stageRadius: 5,
|
| 28 |
popoverOffset: 10,
|
| 29 |
showButtons: true,
|
| 30 |
+
backdropColor: "#000",
|
| 31 |
...config,
|
| 32 |
};
|
| 33 |
}
|
src/stage.ts
CHANGED
|
@@ -135,7 +135,7 @@ function createStageSvg(stage: StageDefinition): SVGSVGElement {
|
|
| 135 |
|
| 136 |
stagePath.setAttribute("d", generateStageSvgPathString(stage));
|
| 137 |
|
| 138 |
-
stagePath.style.fill = "rgb(0,0,0)";
|
| 139 |
stagePath.style.opacity = `${getConfig("opacity")}`;
|
| 140 |
stagePath.style.pointerEvents = "auto";
|
| 141 |
stagePath.style.cursor = "auto";
|
|
|
|
| 135 |
|
| 136 |
stagePath.setAttribute("d", generateStageSvgPathString(stage));
|
| 137 |
|
| 138 |
+
stagePath.style.fill = getConfig("backdropColor") || "rgb(0,0,0)";
|
| 139 |
stagePath.style.opacity = `${getConfig("opacity")}`;
|
| 140 |
stagePath.style.pointerEvents = "auto";
|
| 141 |
stagePath.style.cursor = "auto";
|