Web Design Forum: simple jquery help - amend this... - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

simple jquery help - amend this...

#1 User is offline   lsj1987 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 17
  • Joined: 22-December 11
  • Reputation: 1
  • Gender:Male
  • Location:Wales
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 29 January 2012 - 03:20 PM

Hi,

Basically, I have put a sidebar which slides with the content of a web page following:

http://css-tricks.co...follow-sidebar/

Worked good, but an issue I had was that as the sidebar is quite long (contains facebook like box) when it reached the bottom of the page it destroyed my footer layout...so I added this amended jquery:

http://stackoverflow...-follow-sidebar

It doesn't destroy my footer, but the sidebar basically comes down, say 600px, more than the left content (due to the length of the sidebar i quess) shown on the attachment...

$(function() {

    var $sidebar   = $("#scroll-menu"),
        $window    = $(window),
        $footer    = $("#footer"), // use your footer ID here
        offset     = $sidebar.offset(),
        foffset    = $footer.offset(),
        threshold  = foffset.top - $sidebar.height(); // may need to tweak
        topPadding = 15;

    $window.scroll(function() {
        if ($window.scrollTop() > threshold) {
            $sidebar.stop().animate({
                marginTop: threshold
            });
        } else if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            });
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });

});



I'm assuming I need to add something here:

threshold  = foffset.top - $sidebar.height(); // may need to tweak


Any help would be great!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users