From d50672ee20bfe0b279ba697474411b5b3d5e412d Mon Sep 17 00:00:00 2001 From: arcadeperfect Date: Tue, 26 Nov 2024 22:11:56 -0500 Subject: [PATCH] hacky post process fix for scroll issue --- build_wasm.sh | 4 ++-- fix_bindings.sh | 8 ++++++++ src/main.rs | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100755 fix_bindings.sh diff --git a/build_wasm.sh b/build_wasm.sh index ab8caf7..9195089 100755 --- a/build_wasm.sh +++ b/build_wasm.sh @@ -3,5 +3,5 @@ set -e cargo build --release --target wasm32-unknown-unknown wasm-bindgen --out-dir ./out/ --target web ./target/wasm32-unknown-unknown/release/bevy_vaporwave.wasm -sed -i 's/getObject(arg0).focus();/const scrollPos = window.scrollY; getObject(arg0).focus(); window.scrollTo(0, scrollPos);/' ./out/bevy_vaporwave.js - +# sed -i 's/getObject(arg0).focus();/const scrollPos = window.scrollY; getObject(arg0).focus(); window.scrollTo(0, scrollPos);/' ./out/bevy_vaporwave.js +./fix_bindings.sh diff --git a/fix_bindings.sh b/fix_bindings.sh new file mode 100755 index 0000000..1eafcf8 --- /dev/null +++ b/fix_bindings.sh @@ -0,0 +1,8 @@ +# Detect OS and use appropriate sed command +if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + sed -i '' 's/getObject(arg0).focus();/const scrollPos = window.scrollY; getObject(arg0).focus(); window.scrollTo(0, scrollPos);/' ./out/bevy_vaporwave.js +else + # Linux and others + sed -i 's/getObject(arg0).focus();/const scrollPos = window.scrollY; getObject(arg0).focus(); window.scrollTo(0, scrollPos);/' ./out/bevy_vaporwave.js +fi \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9341aed..10f57f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -// force build again +// force build again again use bevy::gltf::{GltfExtras, GltfSceneExtras}; use bevy::prelude::Color;