Requires

Provides

Fx.SmoothScroll.js

Class for creating a smooth scrolling effect to all internal links on the page.

License:
MIT-style license
Authors:
Valerio Proietti

<1.2compat>

  1. 27
  2. 28
  3. 29
  4. 30
  5. 31
  6. 32
  7. 33
  8. 34
  9. 35
  10. 36
  11. 37
  12. 38
  13. 39
  14. 40
  15. 41
  16. 42
  17. 43
  18. 44
  19. 45
  20. 46
  21. 47
  22. 48
  23. 49
  24. 50
  25. 51
  26. 52
  27. 53
  28. 54
  29. 55
  30. 56
  31. 57
  32. 58
  33. 59
  34. 60
  35. 61
  36. 62
Extends: Fx.Scroll, initialize: function(options, context){ context = context || document; this.doc = context.getDocument(); var win = context.getWindow(); this.parent(this.doc, options); this.links = $$(this.options.links || this.doc.links); var location = win.location.href.match(/^[^#]*/)[0] + '#'; this.links.each(function(link){ if (link.href.indexOf(location) != 0) return; var anchor = link.href.substr(location.length); if (anchor) this.useLink(link, anchor); }, this); if (!(Browser.safari && Browser.version == 2)){ this.addEvent('complete', function(){ win.location.hash = this.anchor; }, true); } }, useLink: function(link, anchor){ var el; link.addEvent('click', function(event){ if (el !== false && !el) el = document.id(anchor) || this.doc.getElement('a[name=' + anchor + ']'); if (el){ event.preventDefault(); this.anchor = anchor; this.toElement(el).chain(function(){ this.fireEvent('scrolledTo', [link, el]); }.bind(this)); link.blur(); } }.bind(this)); } });