No teasing, demo is here: https://test-play.softr.app/freeze-block You will understand exactly what it does… you just have to scroll to see the magic.
To be viewed on desktop! No point in using this on mobile so I prevented it to work on mobile
Now the custom codes to do it! Note that the header is not set as “Fixed”.
Note also that there is a little bug with my javascript that makes the scroll to top not perfect as the header starts to overlap the list details block… In order to fix this, very simple workaround: below your header, add a custom code block, without anything inside and set the padding top and bottom to 7xs (almost the minimum). It will solve it perfectly
In the header code of the page settings (CSS and styles, of course!):
With the following update inside the JavaScript part of the code (so everything in the footer code of the page settings), you will be able to change the width of the list-details block on scroll (I found that the width on scroll was a little too wide with the previous code). AND you will be able to choose the position of the list details block on scroll (center, left or right).
Way better to let your users see the right information in the other blocks when scrolling.
This is fanastic! I am trying to make the background of the floating block transparent / opacity of 0, but am having issues doing so. Do you have any suggestions?
Don’t ask me more because it was hell on earth to get to something correct .
It is not perfect as the whole list details gets the transparency, but I’m not able to do more.
Mhh…tried it in Chrome and on an iPad and indeed works very nice.
Maybe got something to do with me resizing Safari to half screen, and after that it didn’t work in Safari anymore - even after resizing to full-screen again.
Nevertheless, awesome custom code!
Yes, I made the code to not work on mobile size: any screen or window size below 640px will make the code disable, as explained in the first post.
(This type of design is not made for mobile, the added value is for desktop)
You can stop this limitation by removing the line if (window.innerWidth >= 640) {
Hey @matthieu_chateau,
This looks amazing!
Unfortunately, I’m having trouble assigning the custom code to the static “Simple Text” block myself. After a couple of tries to change the list-details1 block name in your code to the name of my block I went the other way around and tried renaming the Softr block itself to “list-details1” and keeping the code as is, all without success. Does it only work with list details block or can you tell anything else I’m missing?
Hi,
I made the test with the static block “simple text”, it works perfectly.
Note that this code is not made to be used on mobile.
The <style> part of the code must be inserted in the header code of the page settings
The <script> part of the must be inserted in the footer code of the page settings
The code works in relation with the header. So your header must have the same name/Id in the code. Specifically this line: const header = document.querySelector(‘header’);
It is ‘header’ beacause my header has this name
Copy paste the codes by changing it to list-details1 doesn’t change anything, except less work for you (so that might be better). If your header has a different name, you can do the same
Hi @matthieu_chateau,
Thank you, changing the header block name to ‘header’ fixed it!
What I find strange though is that if the header block has any other name than ‘header’ e.g. ‘header-test’ and I put ‘header-test’ into the line
Yes, this is because you would also need to change other parts of the code with ‘header-test’. Basically all where the header name is used as a selector.