I have a problem with my jQuery plugin, I want to show the footer in a certain way right before the end of the page. To do this, I get the actual lower position and compare it with the height of the whole body.
But there is a jQuery function height () problem return bad value. For example, I know that the site has a height of 5515px, but the function returns me a value: 8142px
I am using the mCustomScrollbar plugin in several places on the page and I think this may cause a problem. I cannot turn it off because there are elements on the page that require good results.
My code is:
(function($){
$.fn.scrollingElements = function(){
var height = $(window).height();
var max_height = $(document).height();
var prev_top = $(window).scrollTop();
var prev_bottom = top + height;
$(window).scroll(function(){
var top = $(window).scrollTop();
var bottom = top + height;
console.log(max_height, bottom);
if(prev_top < height && top > height){
}
if(prev_top > height && top < height){
}
if(prev_top < 2*height && top > 2*height){
}
if(prev_top > 2*height && top < 2*height){
}
if(prev_bottom < max_height - 100 && bottom > max_height - 100){
}
if(prev_bottom > max_height - 100 && bottom < max_height - 100){
}
prev_top = top;
prev_bottom = bottom;
});
$(window).resize(function(){
height = $(window).height();
});
}
})(jQuery);
:
$(document).height() document.body.clientHeight . $('body'). Height() .