Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions jquery.lockfixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
max_height = $(document).height() - config.offset.bottom,
top = 0,
swtch = false,
pos_not_fixed = false;
pos_not_fixed = false,
el_right_float = el.css('float') === 'right';;

/* we prefer feature testing, too much hassle for the upside */
/* while prettier to use position: fixed (less jitter when scrolling) */
Expand All @@ -46,6 +47,9 @@
$(window).bind('scroll resize orientationchange load',el,function(e){
var el_height = el.outerHeight(),
scroll_top = $(window).scrollTop();

// check height on load event (specifically) due to elements being hidden on DOM ready - is this case, the height value is incorrect)
max_height = $(document).height() - config.offset.bottom;

//if we have a input focus don't change this (for ios zoom and stuff)
if(pos_not_fixed && document.activeElement && document.activeElement.nodeName === "INPUT"){
Expand All @@ -63,13 +67,13 @@
if (pos_not_fixed){
el.css({'marginTop': parseInt(((el_margin_top ? el_margin_top : 0) + (scroll_top - el_top - top) + 2 * config.offset.top),10)+'px'});
}else{
el.css({'position': 'fixed','top':(config.offset.top-top)+'px','width':el_width +"px"});
el.css({'position': 'fixed','top':(config.offset.top-top)+'px','width':el_width +"px",'left':el_right_float ? el_left + "px" : 'auto'});
}
}else{
el.css({'position': el_position,'top': el_position_top, 'width':el_width +"px", 'marginTop': (el_margin_top ? el_margin_top : 0)+"px"});
el.css({'position': el_position,'top': el_position_top, 'width':el_width +"px", 'marginTop': (el_margin_top ? el_margin_top : 0)+"px",'left':el_right_float ? el_left + "px" : 'auto'});
}
});
}
}
});
})(jQuery);
})(jQuery);