Hello,
is there a tutorial for a parallax effect?
Cheers and thank you
Rafael
ItĀ“s rlly a pity that Bricks doesnĀ“t seem to have basic options for parallax anymoreā¦
However, what I“ve been using so far is Rellax.
It“s fairly easy to setup and works great! Not sure if there“s an easier solution though. If someone has one, please let me know! Until then I“ll be using Rellax
Hi Soluna, do you have a quick how-to that explains how to add and use Rellax on a bricks website?
Hey
I“m so sorry⦠I usually write down my steps to reproduce what I did but for whatever reason I now can“t get it to work again⦠The parallax is happening but it looks really bad for me⦠I“ll spend a bit more time on it within the next days and see if I can make it work again. I“ve been trying for an hour now and I get an effect that pretty much is parallax but it“s not what you“d expect. The parallax behaviour is really weird.
So, I managed to get a working solution for me but without any external library. Just some Javscript. Here“s how I did it:
- Adding a section with a container inside.
CSS adjustments (either with manual CSS or in Bricks directly):
Section:
height: 600px;
position: relative;
overflow: hidden;
then I gave the section a class āparallaxā.
Container:
width: 100%;
min-height: 100vh;
position: absolute;
top: 0;
right: 0;
overflow: hidden;
Then I set the background image to the container:
- background-attachment: fixed
- background-position: custom: X-axis: center, Y-axis: -300px (you probably need to adjust this value, depending on your image).
Then give the container a class āparallax-containerā.
Then either add a āCodeā-widget or go to the page settings and under ācustom codeā add the following Javascript:
<script>
document.addEventListener('scroll', function() {
const parallaxContainer = document.querySelector('.parallax-container');
let scrollPosition = window.pageYOffset;
let yOffset = -300 + (scrollPosition * 0.5);
yOffset = Math.max(-300, Math.min(300, yOffset));
parallaxContainer.style.backgroundPositionY = `${yOffset}px`;
});
</script>
Here again: You probably need to adjust the values a bit.
That“s it
Make sure your background-image is big enough (enough height) cause in my first test it showed the border of the image when I scrolled.
I know it“s probably still not the best solution but I hope this helps a little bit.