I’ve made my site to work like a parallax effect, where elements coming inside and goes out on the next pause action. The size I’ve chosen is nice for my screen, but when it comes to a laptop, the bottom part is hidden. This is a major problem, as I need the full document to be inside the browser window (like shrink to fit). Or, even better, if it could open a new browser window based on my document’s size. I’ve tried to make a responsible layout, but everything is ruined. Elements outside my document appears and it’s a total mesh.
I thought that this script you wrote, could be the solution to my problem. I’ve pasted it in the head section but there is no result. Have I done something wrong?
Max thank you for the suggestion.
I’ve tried to control the site with the flexible layout pinning and sizing, but the result isn’t what I expect. In fact, by this way, the hidden elements that comes inside my document, appears and everything is ruined. I’ve tried to group all the scene contents and make it a mask (hidden), but with no positive result. If there is a script to fit my page to the browser’s window, it would be great.
Your document doesn't contain multiple layouts nor flexible layout, so @h_classen's script doesn't quite apply here/yet. I'm going to move this thread to its own topic.
This is the general approach you can take... hard to know how it went wrong for you without that version though! The explicit steps would be:
In the Scene Inspector, check the Width Scale 100% box and Height Scale 100% boxes.
Select all elements by pressing Command-A
Click the "Group" button in the toolbar
Now there's a group, but it is a bit bigger than the bounds of the scene since you have elements that extend over it. So you'll just want to use the scene editor to move the top/left/bottom/right boundaries of the group to match the scene.
Set the Group's Content Overflow in the Metrics Inspector to "Hidden"
Now we can tell this group how you want it to resize. With just the group selected, go to the Flexible Layout section of the Metrics Inspector. Turn on all the pins, and the resize boxes. You should end up with the preview being a blue box that always entirely fills the shape.
Now you'll want to check "Zoom contents" in the flexible layout settings. This tells the group to scale all the inner elements when resized.
And finally set the Scale behavior to "Shrink to fit" - this ensures the contents will always be shown, though may get a little smaller.
There's also some code that you can just paste in a manner similar to your first attempt that basically does the same thing, but for all scenes. You can find it here:
Hi @h_classen thank you for this and all your contributions.
It is possible to adapt this script to be a function inside the Hype document?
Generally, what are the caveats to consider/things to keep in mind when tryin to convert an head script to an inner function?
Either is good… I use your approach also very often!
Having a keyword removes the need to update a list but can lead to false positives with partial matches! Picking a keyword like (noresize) should fix that though.
@h_classen@MaxZieb
Thank you so much for this!!
Nevertheless I have a problem. I'm using WordPress with the Plugin "Tumult Hype Animation" for uploading OAM files. If I load up 2 files with this script on the same site, the second one does not work (div is blank).
Is this a known issue? Any ideas how to fix that?
Thank you!