Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMLMesh: hover on button elements in VR #25927

Open
vincentfretin opened this issue Apr 25, 2023 · 2 comments
Open

HTMLMesh: hover on button elements in VR #25927

vincentfretin opened this issue Apr 25, 2023 · 2 comments
Milestone

Comments

@vincentfretin
Copy link
Contributor

Description

Style :hover on button elements doesn't work in VR. That's because window.getComputedStyle( element ) doesn't get updated once you are in a immersive-vr session.

Solution

Save the hover styles before entering VR, so we can apply the correct style on mouseenter/mouseleave by adding a hover class on the button.
For this to work, you need to have some css rules like that :

button:hover,
button.hover {
  background-color: red
}

Alternatives

You can modify on the fly all the loaded stylesheets to add the button.hover variant like it has been done on other aframe ui components, but I find that very intrusive.

Additional context

I create this issue for visibility. I did some months ago a PR on aframe-htmlmesh AdaRoseCannon/aframe-htmlmesh#9 to implement this. This works great, but could be generalized to other elements than button, and use something different than using data attributes to keep a list of css properties with their value. I'm not planning to work on it right now. If you have suggestions, you can comment on the PR.

@mrdoob
Copy link
Owner

mrdoob commented Apr 26, 2023

That's because window.getComputedStyle( element ) doesn't get updated once you are in a immersive-vr session.

Oh, that's annoying...

@mrdoob mrdoob added this to the r153 milestone Apr 26, 2023
@Mugen87 Mugen87 modified the milestones: r153, r154 Jun 1, 2023
@mrdoob mrdoob modified the milestones: r154, r155 Jun 29, 2023
@mrdoob mrdoob modified the milestones: r155, r156 Jul 27, 2023
@mrdoob mrdoob modified the milestones: r156, r157 Aug 31, 2023
@mrdoob mrdoob modified the milestones: r157, r158 Sep 28, 2023
@remmel
Copy link
Contributor

remmel commented Oct 1, 2023

FYI, I had same needs in my https://www.metalograms.com/demo/ project and I also adds .hover class on items listening to mouse events when mouse is really hover.

@mrdoob mrdoob modified the milestones: r158, r159 Oct 27, 2023
@mrdoob mrdoob modified the milestones: r159, r160 Nov 30, 2023
@mrdoob mrdoob modified the milestones: r160, r161 Dec 22, 2023
@mrdoob mrdoob modified the milestones: r161, r162 Jan 31, 2024
@mrdoob mrdoob modified the milestones: r162, r163 Feb 29, 2024
@mrdoob mrdoob modified the milestones: r163, r164 Mar 29, 2024
@mrdoob mrdoob modified the milestones: r164, r165 Apr 25, 2024
@mrdoob mrdoob modified the milestones: r165, r166 May 31, 2024
@mrdoob mrdoob modified the milestones: r166, r167 Jun 28, 2024
@mrdoob mrdoob modified the milestones: r167, r168 Jul 25, 2024
@mrdoob mrdoob modified the milestones: r168, r169 Aug 30, 2024
@mrdoob mrdoob modified the milestones: r169, r170 Sep 26, 2024
@mrdoob mrdoob modified the milestones: r170, r171 Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants