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;