Skip to content

Commit 94579af

Browse files
committed
Re-enable scrolling
AnyLogic captures mouse wheel and trackpad scroll. This change re-enables it.
1 parent b2efff3 commit 94579af

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

webtool/frontend/src/components/ConfigureAndSimulate.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ type ConfigAndSimulateProps = {
2424
startImmediately?: boolean,
2525
} & ComponentProps<"div">
2626

27+
/**
28+
* AnyLogic capture mouse wheel and trackpad scroll.
29+
* In our case we want to scroll the page like normal.
30+
*/
31+
function reEnableScroll() {
32+
const anyLogicElement = document.querySelector(`#${anylogicElementId} #svg-container`)
33+
if (!anyLogicElement) {
34+
console.error("Could not find AnyLogic element to re-enable scroll.")
35+
return
36+
}
37+
38+
// @ts-expect-error I don't know why this doesn't type check
39+
anyLogicElement.addEventListener("wheel", (e: WheelEvent) => {
40+
window.scrollBy(e.deltaX, e.deltaY)
41+
})
42+
}
43+
2744
export const ConfigureAndSimulate: FunctionComponent<ConfigAndSimulateProps> = ({
2845
initialPilot,
2946
startImmediately = Boolean(initialPilot),
@@ -58,6 +75,7 @@ export const ConfigureAndSimulate: FunctionComponent<ConfigAndSimulateProps> = (
5875
const sessionId = await savePilot(pilot)
5976
setShowSimulation(true)
6077
const newSimulation = await startSimulation(anylogicElementId, sessionId)
78+
reEnableScroll()
6179
setSimulation(newSimulation)
6280
await newSimulation.waitForCompletion()
6381
forceUpdate()

0 commit comments

Comments
 (0)