My problem is that i want to add the parallax effect (rellax
class) to the class home-content
when the screen size is above 810 px and remove it when its below. Plus, if possible i want to be able to add data-rellax-speed = "-4"
when rellax
is enabled.
The problem is that i have the error : rellax.js:141 Rellax: The elements you're trying to select don't exist.
Surelly because it does not find .relax
in HTML
Here is the HTML code of the section with .home-content
<section class="home content" id="home">
<div class="max-width">
<div class="home-content">
<div class="text-1 stagger1">👋 Bonjour, je suis</div>
<div class="text-2 stagger1">Eric</div>
<div class="text-3 stagger1">Et je suis un <span class="crimson" id="typing"></span></div>
<a class="stagger2" href="#contact">Me contacter</a>
</div>
</div>
</section>
Here is the JS so far (i am using Rellax.js in order to achieve parallax):
$(document).ready(function(){
// Parallax
var rellax = new Rellax('.rellax');
if(window.innerWidth < 810){
$('.home-content').removeClass('rellax');
}
})
$(window).resize(function(){
if(window.innerWidth < 810){
$('.home-content').removeClass('rellax');
}else{
$('.home-content').addClass('rellax');
}
});