Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

simple jquery help - amend this...

Featured Replies

Hi,

 

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

 

http://css-tricks.com/scrollfollow-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.com/questions/4716795/help-with-scroll-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!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.