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

Add a "shifting background" effect on mousemove #369

Open
wants to merge 154 commits into
base: master
Choose a base branch
from

Conversation

ezio-melotti
Copy link
Collaborator

This PR is a proof-of-concept/experiment that adds a "shifting background" effect on mousemove.
Since both background images show Mars and Earth as seen from space, I thought it would be cool to add a subtle shifting effect (tied to the mouse movement) as if the user was floating in space.

This is implemented by adding a mousemove callback at the top level (meaning that it will be active in all pages) and that might be expensive, even though it didn't seem to affect performances on my machine.

The shifting is also limited to one axis at a time. Currently the background image is set to cover the whole background and clipping part of the image if the viewport ratio doesn't match the image ratio. This basically means that the background image is automatically scaled to either have the same width or the same height of the viewport, with the longer side overflowing. This means that the shifting can only happen on the overflowing side and not on both sides at the same time.

I tried a few different approaches to make it work on both axis, but there doesn't seem to be an easy solution that covers all cases (in theory it could be done with some extra js).

While working on this I also noticed that after Mars or B2 are selected from the main menu, the new background doesn't replace the original one (which is applied to the <body>) but is added on top of it to the main content <div>. Even though this seems "wrong", it has the advantage that the top bar doesn't cover the upper part of the background image, so the current implementation might be ok (setting it in mounted might be better though). To keep the code simple in this PR, I changed the current implementation to always set the background on the <body>. (cc @merigrey)

This was just a quick late-night experiment, so I don't expect this PR to be merged, but if you like it I could address the aforementioned issues and merge it.

merigrey and others added 30 commits December 2, 2022 01:11
DRAFT: Menu added for B2 configuration
- Tweaks to fullscreen mode
- ChartJS 4.
- Various package updates
ezio-melotti and others added 13 commits February 10, 2023 12:07
* Move the `simdata` dir from `src/assets` to `public`.

* Rename var and clarify comment.

* Fix simdata dir in `run.sh`.

Co-authored-by: Grant <50287275+granawkins@users.noreply.github.com>

---------

Co-authored-by: Grant <50287275+granawkins@users.noreply.github.com>
Add `public/simdata` to `.gitignore`.
@ezio-melotti ezio-melotti added the enhancement A new enhancement or feature label Feb 18, 2023
@ezio-melotti ezio-melotti self-assigned this Feb 18, 2023
@merigrey
Copy link
Contributor

That's a really cool effect! Wish we could do it omnidirectionally, but I'm not sure how much extra work that would be.

RE loading the background onto , the issue I was seeing is that clicking into B2 then going back into the main menu causes the B2 background to persist until Mars is selected. Not a huge deal, but I avoided it by using the

option. If we want to load it onto , I think there's a way to set up a listener for any back-button presses and reset the image.

Base automatically changed from b2 to master April 2, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new enhancement or feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants