Scroll view test
This commit is contained in:
parent
9395104dfb
commit
f85af953f0
|
|
@ -76,3 +76,41 @@ jobs:
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
- name: Run cargo fmt
|
- name: Run cargo fmt
|
||||||
run: cargo fmt --all -- --check
|
run: cargo fmt --all -- --check
|
||||||
|
web_build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: ${{ github.ref || github.run_id }}
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: wasm32-unknown-unknown
|
||||||
|
- name: Install wasm bindgen
|
||||||
|
uses: baptiste0928/cargo-install@v2
|
||||||
|
with:
|
||||||
|
crate: wasm-bindgen-cli
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --release --example simple --target wasm32-unknown-unknown && wasm-bindgen --out-dir ./out/ --target web ../target/wasm32-unknown-unknown/release/examples/simple.wasm
|
||||||
|
- name: Copy
|
||||||
|
working-directory: ./bevy_forge
|
||||||
|
run: cp -R assets out/ && cp wasm/* out/ && ls -R out
|
||||||
|
- name: Push
|
||||||
|
uses: s0/git-publish-subdir-action@develop
|
||||||
|
env:
|
||||||
|
SQUASH_HISTORY: true
|
||||||
|
REPO: self
|
||||||
|
BRANCH: gh-pages # The branch name where you want to push the assets
|
||||||
|
FOLDER: ./bevy_forge/out # The directory where your assets are generated
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token
|
||||||
|
MESSAGE: "Build: ({sha}) {msg}" # The commit message
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@
|
||||||
name = "bevy_simple_scroll_view"
|
name = "bevy_simple_scroll_view"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
exclude = [".github/","wasm/"]
|
||||||
|
categories = ["game-development", "gui"]
|
||||||
|
keywords = ["bevy","ui"]
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Scroll view</title>
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
text-align: center;
|
||||||
|
margin: auto 0;
|
||||||
|
background-color: #292F36;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas {
|
||||||
|
filter: drop-shadow(#04b5cd 0 0 10px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="module">
|
||||||
|
import './restart-audio-context.js'
|
||||||
|
import init from './simple.js'
|
||||||
|
|
||||||
|
init().catch((error) => {
|
||||||
|
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
// taken from https://developer.chrome.com/blog/web-audio-autoplay/#moving-forward
|
||||||
|
(function () {
|
||||||
|
// An array of all contexts to resume on the page
|
||||||
|
const audioContextList = [];
|
||||||
|
|
||||||
|
// An array of various user interaction events we should listen for
|
||||||
|
const userInputEventNames = [
|
||||||
|
'click',
|
||||||
|
'contextmenu',
|
||||||
|
'auxclick',
|
||||||
|
'dblclick',
|
||||||
|
'mousedown',
|
||||||
|
'mouseup',
|
||||||
|
'pointerup',
|
||||||
|
'touchend',
|
||||||
|
'keydown',
|
||||||
|
'keyup',
|
||||||
|
];
|
||||||
|
|
||||||
|
// A proxy object to intercept AudioContexts and
|
||||||
|
// add them to the array for tracking and resuming later
|
||||||
|
self.AudioContext = new Proxy(self.AudioContext, {
|
||||||
|
construct(target, args) {
|
||||||
|
const result = new target(...args);
|
||||||
|
audioContextList.push(result);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// To resume all AudioContexts being tracked
|
||||||
|
function resumeAllContexts(event) {
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
audioContextList.forEach(context => {
|
||||||
|
if (context.state !== 'running') {
|
||||||
|
context.resume();
|
||||||
|
} else {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// If all the AudioContexts have now resumed then we
|
||||||
|
// unbind all the event listeners from the page to prevent
|
||||||
|
// unnecessary resume attempts
|
||||||
|
if (count == audioContextList.length) {
|
||||||
|
userInputEventNames.forEach(eventName => {
|
||||||
|
document.removeEventListener(eventName, resumeAllContexts);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We bind the resume function for each user interaction
|
||||||
|
// event on the page
|
||||||
|
userInputEventNames.forEach(eventName => {
|
||||||
|
document.addEventListener(eventName, resumeAllContexts);
|
||||||
|
});
|
||||||
|
})();
|
||||||
Loading…
Reference in New Issue