Questions tagged [web-sys]
22 questions
3
votes
2 answers
expected `()`, found opaque type for async function
I am following a guide for setting up a WebRTC data-channel with web-sys. I can copy and paste the code and it compiles correctly. The start() function is async which makes it possible to await a JsFuture inside the main scope, however I am trying…

Kevin
- 3,096
- 2
- 8
- 37
3
votes
0 answers
web-sys define js_sys::Function
How do I define a js_sys::Function that must be used in get_current_position to get the users latitude and longitude coordinates?
I have the following
let navigator = web_sys::window().expect("Missing window").navigator();
let geolocation =…

Kevin
- 3,096
- 2
- 8
- 37
2
votes
0 answers
How to pass 64 bit float uniform to webgl shaders from wasm?
I'm currently attempting to interface with a webgl2 canvas from a WASM program using wasm_bindgen and the web_sys crate. I am passing two vectors into my fragment shader as uniforms however I cant determine how to send them as double precision. It…

Giraugh
- 116
- 6
2
votes
1 answer
How to make POST request with JSON body using web-sys in WebAssembly?
How to create POST request with JSON body using web-sys in WebAssembly?
This example below showing how to make GET request, I need to change opts.method("GET"); to opts.method("POST"); but how can i pass a JSON body to the reqeuest.
let mut opts…

obei
- 115
- 2
- 10
2
votes
1 answer
How to query and update the DOM with yew?
Is there any way to make DOM action via use_node_ref? or alternatively, how to do document.query_selector() in Rust using yew?
use web_sys::HtmlInputElement;
use yew::{
function_component, functional::*, html,
NodeRef,…

Ali Husham
- 816
- 10
- 31
1
vote
2 answers
How to invoke (Rust) web-sys AngleInstancedArrays?
https://developer.mozilla.org/en-US/docs/Web/API/ANGLE_instanced_arrays
Given WebGL2RenderingContext as gl.
We have gl.draw_arrays_instanced.
There is also a web-sys object: web_sys::AngleInstancedArrays with functions like…

kulicuu
- 15
- 5
1
vote
1 answer
How can I get a field of WebGlContextAttributes?
My case is like this, I just want to get the field of WebGlContextAttributes struct.
let antialias_info = gl.get_context_attributes().unwrap();
match antialias_info.antialias {
// ...
}
I get the following error:
attempted to take value of…

holy zheng
- 81
- 5
0
votes
1 answer
No click method defined on element when created via web_sys
In the JavaScript console, I can execute the following to create an element and demonstrate that it has a click method.
let input = document.createElement("input");
input.type = "file";
console.log(input.click);
// ƒ click() { [native code]…

Huckle
- 1,810
- 3
- 26
- 40
0
votes
1 answer
Is there any way to cast a Callback into FnMut(MouseEvent)?
I'm implementing material 3 from scratch with web_sys and writing some adapters for different frameworks among them yew.
I have implemented a basic structure for buttons something like this to use like this.
This works fine on web_sys but I'm trying…

al3x
- 589
- 1
- 4
- 16
0
votes
0 answers
animationcancel event fired off in Chrome but not in Firefox - CSSAnimation's playState property returns Finished
I'm using the web_sys crate in Rust to manually set a div's animation property:
let animation1 = format!("animation1 {}ms ease-in-out forwards", DURATION);
// html_element is type web_sys::HtmlElement
…

brianxk
- 63
- 1
- 6
0
votes
0 answers
How to `animate` an object using web-sys and js-sys
I've been trying to emulate this javascript code in a frontend framework and haven't been able to get much traction.
window.onpointermove = event => {
const { clientX, clientY } = event;
blob.animate({
left: `${clientX}px`,
top:…

financial_physician
- 1,672
- 1
- 14
- 34
0
votes
0 answers
Bevy - Render to wgpu::Texture
I am looking for an elegant and hopefully bevy-esque way of rendering to a wgpu::Texture. The reason is that I'm am implementing a WebXR libary and the WebXRFramebuffer must be rendered to in immersive XR.
let framebuffer = //get framebuffer from…

chantey
- 4,252
- 1
- 35
- 40
0
votes
1 answer
How to convert a string to Blob in web_sys?
I am trying to convert a string to blob using web_sys
let json_string = json::stringify(data);
let json_jsvalue = JsValue::from_str(&json_string);
let json_blob_result = Blob::new_with_str_sequence(&json_jsvalue);
let json_blob =…

Amiya Behera
- 2,210
- 19
- 32
0
votes
2 answers
How to select a file as bytes or text in Rust WASM?
I am trying to get the Vec or String (or more ideally a Blob ObjectURL) of a file uploaded as triggered by a button click.
I am guessing this will require an invisible somewhere in the DOM but I can't figure out how to leverage web_sys…

Durfsurn
- 105
- 5
0
votes
0 answers
Make DOM load in web_sys
How would I modify this to get the result below? The thing is there is no iterable. I am not sure what I am doing at this point as this code was AI generated. But my desired result it the js code snippet below.
use web_sys::{Element,…

collinsmarra
- 148
- 1
- 7