i am looking solution for solve my problem about fixed div when scroll until this same div. I can create script like this:
$(window).scroll(function() {
if ($(document).scrollTop() > 10) {
$('.divv').addClass('fixed-top');
} else {
$('.divv').removeClass('fixed-top');
}
});
but script it's only for precise px, i want make fixed div when hit this div, because the content above it's dinamic and change dimensions.
My new working script:
var elementMap = $('.map-box').offset();
var elementHeight = $('.calc-height').offset();
var elementdiffBott = elementHeight.top - $('.map-box').height();
$(window).scroll(function(){
//alert(elementdiffBott);
if($(window).scrollTop() > elementMap.top){
var mapWidth = $('.map-box').width();
$('.map-box').addClass('gmap-fixed').css('width',mapWidth);
} else {
$('.map-box').removeClass('gmap-fixed');
} if($(window).scrollTop() > elementdiffBott){
$('.map-box').removeClass('gmap-fixed');
}
});