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

Fix auto-resize for Validate and Explore page #3649

Merged
merged 31 commits into from
Dec 2, 2024

Conversation

jsomeara
Copy link
Collaborator

@jsomeara jsomeara commented Sep 9, 2024

Resolves #3626

This PR fixes the auto-resize functionality that was recently broken in a chrome update of the zoom css property. It achieves this with an iframe that contains a simplified version of the explore or validate page, and then scales the iframe using the transform: scale() css property. Using an iframe preserves the proper mouse positions of the pano labels. It is compatible with all major browsers I've tested. I anticipate that it'll work with Safari, but currently untested due to me lacking a Mac.

Note: This is currently a draft because I have not yet started the validate page. I think it's better to hold off on that until we're happy with the explore page. Using lessons learned from that one page, I can then apply the same technique to the validate page.

  • Explore page
  • Validate page
Video
auto.resize.explore.page.mp4
Testing instructions

See here

Things to check before submitting the PR
  • I've written a descriptive PR title.
  • I've added/updated comments for large or confusing blocks of code.

@jsomeara jsomeara self-assigned this Sep 9, 2024
@jsomeara jsomeara marked this pull request as ready for review September 9, 2024 06:17
@jsomeara jsomeara marked this pull request as draft September 9, 2024 06:18
@misaugstad
Copy link
Member

Interesting... I'm not sure what's different about having the dev console either closed or in a separate window, but in that case the resizing doesn't seem to be working as expected! Looks like it worked like your video when I had the dev console docked to the side like you did though.

Peek.2024-09-11.10-28.mp4

@jsomeara
Copy link
Collaborator Author

Should be good now! I previously thought that the auto-resize was only supposed to be applied horizontally, not vertically. My bad!

@jsomeara
Copy link
Collaborator Author

Added a listener that passes through iframe URL changes to the parent document!

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding some comments to the code so that we can get it pretty clean before moving on to adding this to the Validate page!

I only managed to find one more issue: there is code in the navbar that references the (formerly global) svl object that is now hidden within the iframe. For example, I get some errors to the console if I sign up for a new account through the navbar on the Explore page now.

Since I haven't really been able to break this in any other fundamental way, I think that we're ready to move on to adding this to the Validate page as well! Would you agree?

app/controllers/AuditController.scala Outdated Show resolved Hide resolved
app/views/explore.scala.html Outdated Show resolved Hide resolved
app/views/exploreWrapper.scala.html Outdated Show resolved Hide resolved
app/views/exploreWrapper.scala.html Outdated Show resolved Hide resolved
public/javascripts/common/wrapperFrame.js Outdated Show resolved Hide resolved
public/javascripts/common/wrapperFrame.js Outdated Show resolved Hide resolved
public/javascripts/common/wrapperFrame.js Outdated Show resolved Hide resolved
@jsomeara
Copy link
Collaborator Author

I only managed to find one more issue: there is code in the navbar that references the (formerly global) svl object that is now hidden within the iframe. For example, I get some errors to the console if I sign up for a new account through the navbar on the Explore page now.

This should be fixed now. The svl and InitialMissionInstruction properties are now passed through.

Also fixed the other issues you mentioned in the review.

I think that we're ready to move on to adding this to the Validate page as well! Would you agree?

Agreed! I'll be doing that in my next set of commits.

@jsomeara
Copy link
Collaborator Author

jsomeara commented Sep 22, 2024

And it's now included in the validate page!! (Ready for review)

Edit: Also added to new validate beta


// Get the width and height of the content inside the iframe.
const contentWidth = contentElement.clientWidth;
const contentHeight = contentElement.clientHeight + 60; // Add 100px for extra padding.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, if I remove the +100 then part of the UI is cut off on the bottom. Not a big deal because we can play around with the values to get what we want, but ideally the math here would work as we expect!
Screenshot from 2024-09-30 14-34-43

I assume that part of this has to do with how we are adding padding-top to the body element? But not totally sure. Would be nice to have the padding-top make some sense, as I'm not really sure how it works or how it is supposed to right now!

I think that in an ideal world, we would be able to specify what percentage of the area below the navbar is to be used as white space both above and below the UI... It's not really that important to be able to do this, but whenever I'm fully invested in a section of the code like this, I like to try to refactor a bit to make things make more sense for the future. So if it doesn't feel like a huge lift, any movement in that direction would be great to see!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I made those changes now!

@jsomeara
Copy link
Collaborator Author

My latest commit features the ability to specify vertical whitespace/padding through a global constant called PERCENT_VERTICAL_PADDING

@jsomeara jsomeara marked this pull request as ready for review November 23, 2024 01:41
@jsomeara
Copy link
Collaborator Author

Previous comment here (now deleted) stated that this was not ready to merge because it had not been added to validate page. Completely forgot that this PR actually had in fact been added to validate page. Sorry about that! So yes, this PR is ready to merge once we review and test.

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The padding looks different on each page even though the percentage is the same, because we have hard-coded top values for the top-most elements on each page that we've used to kinda make something that feels right in terms of padding. I realize that the "right" way to do this would be to get rid of that extra hard-coded "padding", but that has knock on effects; things like the mission complete screens use take into account the hard-coded number. So to fix this the right way, you'd have to go through and check in on all of our different screens that show up to adjust them after making a change. That's probably just not the best use of our time tbh. So maybe we just do the quick fix of having a PERCENT_VERTICAL_PADDING that is configured by page?
Peek 2024-11-25 16-19

Added two other comments in the code. We're almost done here!

public/stylesheets/wrapperFrame.css Outdated Show resolved Hide resolved
public/javascripts/SVValidate/src/Main.js Outdated Show resolved Hide resolved
@jsomeara
Copy link
Collaborator Author

jsomeara commented Nov 26, 2024

Does my most recent commit fix things or am I misinterpreting the issue?

Before:

image

After:

image

@misaugstad
Copy link
Member

Ahh, a big piece of the issue is that the NewValidateBeta page has way more space along the bottom as well!

@jsomeara
Copy link
Collaborator Author

Maybe we can just get rid of this space? I'll try it out - hoping it doesn't break things.

@jsomeara
Copy link
Collaborator Author

@misaugstad Removing the bottom space on newValidateBeta yields this:

image

It feels kinda weird because of how wide it becomes. Thoughts?

@misaugstad
Copy link
Member

I like it at first glance! Maybe once I start testing it out it'll feel too big. But then we can just increase the padding percentage! I feel like it looks weird when the padding at the bottom looks like it's 3x as big as the top padding

@jonfroehlich
Copy link
Member

jonfroehlich commented Nov 26, 2024 via email

@misaugstad
Copy link
Member

One thing to also consider (which is only what some related to this thread): can or should we reduce the size of the menu bat header when in a task (or even eliminate it all together?)

Interesting idea to fully remove it 🤔 I think I like what you had initially proposed in #3504 where we have a smaller version unless we're on the landing page. Or really it's just that it's smaller just in the tools... Not sure

@jsomeara
Copy link
Collaborator Author

jsomeara commented Nov 26, 2024

I think I improved the situation with newValidateBeta a bit but it still might not be perfect. When you get the chance, let me know what you think.

Screenshots:
image
image
image

@misaugstad
Copy link
Member

@jsomeara okay, ready to merge! Just made a couple small changes, like:

  1. Including /adminValidate in this whole thing. It was missing the navbar 😂
  2. Deletes a bit more unused code from the previous UI scaling method
  3. Adds back in the CSS for the mini footer. I forgot that it's actually being used on the mobile sing in/up pages! And Gallery for some reason?

@misaugstad misaugstad merged commit 96fbec0 into develop Dec 2, 2024
@misaugstad misaugstad deleted the 3626-auto-resize-explore-validate branch December 2, 2024 23:25
@misaugstad misaugstad mentioned this pull request Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate and Explore no longer automatically resizing
3 participants