<script type="text/javascript">
$.fn.stickyfloat = function(options, lockBottom) {
var $obj = this;
var parentPaddingTop = parseInt($obj.parent().css('padding-top'));
var startOffset = $obj.parent().offset().top;
var opts = $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 200, lockBottom:true }, options);
$obj.css({ position: 'absolute' });
if(opts.lockBottom){
var bottomPos = $obj.parent().height() - $obj.height() + parentPaddingTop; //get the maximum scrollTop value
if( bottomPos < 0 )
bottomPos = 0;
}
$(window).scroll(function () {
$obj.stop();
var pastStartOffset = $(document).scrollTop() > opts.startOffset;
var objFartherThanTopPos = $obj.offset().top > startOffset;
var objBiggerThanWindow = $obj.outerHeight() < $(window).height();
if( (pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow ){
var newpos = ($(document).scrollTop() -startOffset + opts.offsetY );
if ( newpos > bottomPos )
newpos = bottomPos;
if ( $(document).scrollTop() < opts.startOffset )
newpos = parentPaddingTop;
$obj.animate({ top: newpos }, opts.duration );
}
});
};
$('#menu').stickyfloat({ duration: 400 });
</script>
Vēlos ielikt lapā menu slide kodu, bet visu saliekot (pievienojot jquery bibliotēku un uzliekto menu id="menu", ieejot lapā parādās - $obj.parent().offset() is null (no firebug consoles). Kā izlabot?
Question
laucinieks
Vēlos ielikt lapā menu slide kodu, bet visu saliekot (pievienojot jquery bibliotēku un uzliekto menu id="menu", ieejot lapā parādās - $obj.parent().offset() is null (no firebug consoles). Kā izlabot?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.