Answer the question
In order to leave comments, you need to log in
Two scripts not working together?
I have two scripts side by side:
$(window).scroll(function(e){
parallax();
});
function parallax(){
var scrolled = $(window).scrollTop();
$('#lk-conteyner').css('background-position-y',+(scrolled*0.5)+'px');
}
$(window).scroll(function(e){
parallax();
});
function parallax(){
var scrolled = $(window).scrollTop();
$('.Robort_svg svg').css('top',-(scrolled*0.2)+'px');
}
Answer the question
In order to leave comments, you need to log in
your version is not at all gentlemanly: with each scroll event, a new event handler will be hung on window.
$(window).scroll(parallax);
var lkContainer = $('#lk-conteyner');
var robotSVG = $('.Robort_svg svg');
function parallax() {
var scrolled = $(window).scrollTop();
lkContainer.css('background-position-y',+(scrolled*0.5)+'px');
robotSVG.css('top',-(scrolled*0.2)+'px');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question