Skip to content

Commit

Permalink
hacky post process fix for scroll issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arcadeperfect committed Nov 27, 2024
1 parent 397de2f commit d50672e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions fix_bindings.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// force build again
// force build again again

use bevy::gltf::{GltfExtras, GltfSceneExtras};
use bevy::prelude::Color;
Expand Down

0 comments on commit d50672e

Please sign in to comment.