Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue when scrolltofixed plugin switches to position: absolute

i'm having a problem using the scrolltofixed jquery plugin

https://github.com/bigspotteddog/ScrollToFixed

i use:

$('#tostick').scrollToFixed({  limit: $('#app-footer').offset().top - $('#tostick').height() - 20});  

my #tostick is inside a

 margin:0 auto

div container and as soon it hits the fixed footer and the script switches from fixed to absolute positioning it jumps out of the container because

left: 1107px

is applied, which is the distance to the left border of the browser window, instead of the left border of the centered div container. it tried to add:

offsetLeft: -$('#container').offset().left

which is completely ignored. thanks in advance for any tip!

like image 724
kritop Avatar asked Nov 04 '22 06:11

kritop


1 Answers

You need to give more info we don't know what #tostick is. Obviously we need the whole JS, and related html and css. Have you tried moving the entire container div it its only purpose is to have a style of margin:0 auto? Also you can do:

 $('#tostick').bind('unfixed', function() { $(this).css('left', ''); });//or what it needs to look right
   $('#tostick').bind('fixed', function() { $(this).css('left', '1107px'); });//switch back to what it was
like image 88
Neo Avatar answered Nov 07 '22 22:11

Neo