jquery.anchor.js 937 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*******
  2. *** Anchor Slider by Cedric Dugas ***
  3. *** Http://www.position-absolute.com ***
  4. Never have an anchor jumping your content, slide it.
  5. Don't forget to put an id to your anchor !
  6. You can use and modify this script for any project you want, but please leave this comment as credit.
  7. *****/
  8. $(document).ready(function() {
  9. $("a.anchorLink").anchorAnimate()
  10. });
  11. jQuery.fn.anchorAnimate = function(settings) {
  12. settings = jQuery.extend({
  13. speed : 1100
  14. }, settings);
  15. return this.each(function(){
  16. var caller = this
  17. $(caller).click(function (event) {
  18. event.preventDefault()
  19. var locationHref = window.location.href
  20. var elementClick = $(caller).attr("href")
  21. var destination = $(elementClick).offset().top;
  22. $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
  23. window.location.hash = elementClick
  24. });
  25. return false;
  26. })
  27. })
  28. }