-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add inline graph setting for max distance (maxDegree) (#62)
- Loading branch information
1 parent
7a0612e
commit e043942
Showing
5 changed files
with
102 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const container = document.getElementById("user-input-container"); | ||
|
||
function chromeRangeInputFix() { | ||
// workaround for chrome concerning range inputs, | ||
// not allowing slider to be dragged. | ||
// See https://stackoverflow.com/q/69490604 | ||
// todo: is there a better solution? | ||
document.querySelectorAll('input[type="range"]').forEach((input) => { | ||
input.addEventListener("mousedown", () => | ||
window.getSelection().removeAllRanges() | ||
); | ||
}); | ||
} | ||
|
||
function initDistanceRangeInput(initialValue, handleChange) { | ||
const html = ` | ||
<label for="maxDistance">Max. distance</label> | ||
<input | ||
name="maxDistance" | ||
type="range" | ||
min="0" | ||
value="${initialValue}" | ||
max="5" | ||
step="1" | ||
> | ||
<output>${initialValue}</output> | ||
`; | ||
container.insertAdjacentHTML("beforeend", html); | ||
const input = container.querySelector("input[name='maxDistance']") | ||
input.addEventListener("input", function () { | ||
const output = this.nextElementSibling; | ||
output.value = this.value; | ||
}); | ||
input.addEventListener("change", function () { | ||
handleChange(this.valueAsNumber); | ||
}); | ||
} | ||
|
||
export function init(initDistanceValue, handleDistanceChange, handleRedraw) { | ||
chromeRangeInputFix(); | ||
initDistanceRangeInput(initDistanceValue, handleDistanceChange); | ||
document | ||
.getElementById("redrawButton") | ||
.addEventListener("click", handleRedraw); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters