Skip to content

A jQuery plugin to enable smooth scrolling to a page anchor/id with a configurable offset.

License

Notifications You must be signed in to change notification settings

masonhale/jquery-offset-scroller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jquery-offset-scroller

A jQuery plugin to enable smooth scrolling to a page anchor/id with a configurable offset.

http://masonhale.github.io/jquery-offset-scroller

Demo

See jQuery offsetScroller on CodePen.

Options

  • offsetPixels - subtracted from target position. Default: 0
  • animationSpeed - milliseconds to reach target. Default: 500

Usage

<script>
  $(document).ready(function() {
    // update offsetPixels default to account for fixed position header
    $().offsetScroller.defaults.offsetPixels = 92;

    // add scroller for all '#anchor' links
    $('a[href*="#"]:not([href="#"])').offsetScroller();

    // auto scroll to #hash location on page load
    $().offsetScroller.scrollToHash(window.location.hash);
  });
</script>

License

MIT License

About

A jQuery plugin to enable smooth scrolling to a page anchor/id with a configurable offset.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published