Hello I have this script and I want that
$(window).scroll(function(){
var FromTop = $(window).scrollTop(); //scroll margin from top
var RightWrapper = $('.right_wrapper').height(); // Right wrapper height
var Margin = false;
var ConentHeight = $('.content_wrapper').height() + RightWrapper; //content height
if(FromTop > 125 && RightWrapper < 500){
$('.right_wrapper').addClass('right-fixed-top');
Margin = true;
}else{
$('.right_wrapper').removeClass('right-fixed-top');
}
if(Margin){ // <<<<<<PROBLEM IS HERE each scroll
$('.content_wrapper').css({height:ConentHeight+'px'});
}
});
$('.content_wrapper').css({height:ConentHeight+'px'}); only first time.
Replace the value of Margin to false:
$(window).scroll(function(){
var FromTop = $(window).scrollTop(); //scroll margin from top
var RightWrapper = $('.right_wrapper').height(); // Right wrapper height
var Margin = false;
var ConentHeight = $('.content_wrapper').height() + RightWrapper; //content height
if(FromTop > 125 && RightWrapper < 500){
$('.right_wrapper').addClass('right-fixed-top');
Margin = true;
}else{
$('.right_wrapper').removeClass('right-fixed-top');
}
if(Margin){
$('.content_wrapper').css({height:ConentHeight+'px'});
Margin = false;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With