2 Script: SmoothScroll.js
3 Contains <SmoothScroll>
11 Auto targets all the anchors in a page and display a smooth scrolling effect upon clicking them.
14 SmoothScroll requires an XHTML doctype.
17 options - the Fx.Scroll options (see: <Fx.Scroll>) plus links, a collection of elements you want your smoothscroll on. Defaults to document.links.
23 var SmoothScroll = Fx.Scroll.extend({
25 initialize: function(options){
26 this.parent(window, options);
27 this.links = (this.options.links) ? $$(this.options.links) : $$(document.links);
28 var location = window.location.href.match(/^[^#]*/)[0] + '#';
29 this.links.each(function(link){
30 if (link.href.indexOf(location) != 0) return;
31 var anchor = link.href.substr(location.length);
32 if (anchor && $(anchor)) this.useLink(link, anchor);
34 if (!window.webkit419) this.addEvent('onComplete', function(){
35 window.location.hash = this.anchor;
39 useLink: function(link, anchor){
40 link.addEvent('click', function(event){
42 this.toElement(anchor);
44 }.bindWithEvent(this));