Replies: 1 comment
-
|
I am not sure what is going on but on my deployment (using github pages, latest commit on my main branch) it works fine (https://lobis.github.io/fractal-explorer/). There is no issue. However I cannot get the mouse issue to disappear on my local build, even though they are on the same commit and I have done a clean build (or so I think). There is probably some silly mistake somewhere I cannot find, please don't lose any time on this (I cannot remove the discussion). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am writing this project as a way to learn rust graphics programming. I want to build a graphical application that can be run on web and as an executable.
I have had many troubles getting the canvas to be the right size on the web target. After reading useful posts such as this one and some tinkering I finally got it working as I want (or so I think). I would like to have the canvas be the same size in pixels as my browser window, so it fits tightly without any scroll bars needed.
I manage to do this via the following code:
I would expect the line
window.set_inner_size(PhysicalSize::new(width, height));to be enough to correctly size the canvas, however it's not the case. Thewidth/heightattributes of the html element are not the same as thestyleheight/width.I manually solve this by explicitly setting them on
set_css_text.My html page body in case the css is causing problems:
This solution mostly works, the resizing seems to be ok. However I would love to know if they is a simpler / better / recommended solution for this problem, as this feels a bit sketchy.
The problem with this solution is that after the
set_css_textcall the mouse position is not returning useful values.Accessing the mouse position from the
WindowEvent::CursorMoved { position, .. } => { ... ]on the event loop does not return the correct values, it stops before reaching the max value equal to the size of the canvas. If I remove theset_css_textcall, then the canvas is larger than the browser and a scroll bar is needed, however in this case the mouse position works as intended.I guess if I remove the
set_css_textcall mouse position will work correctly, however I haven't been able to correctly size the canvas without it. I would appreciate any help.Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions