Sha256: 57d81d9cbe3fd04821011897beec009b98fd44249e1377649f3a36029a82cfb9
Contents?: true
Size: 1.42 KB
Versions: 7
Compression:
Stored size: 1.42 KB
Contents
/* --- script: Fx.SmoothScroll.js name: Fx.SmoothScroll description: Class for creating a smooth scrolling effect to all internal links on the page. license: MIT-style license authors: - Valerio Proietti requires: - Core/Slick.Finder - /Fx.Scroll provides: [Fx.SmoothScroll] ... */ /*<1.2compat>*/var SmoothScroll = /*</1.2compat>*/Fx.SmoothScroll = new Class({ Extends: Fx.Scroll, options: { axes: ['x', 'y'] }, initialize: function(options, context){ context = context || document; this.doc = context.getDocument(); this.parent(this.doc, options); var win = context.getWindow(), location = win.location.href.match(/^[^#]*/)[0] + '#', links = $$(this.options.links || this.doc.links); 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); this.addEvent('complete', function(){ win.location.hash = this.anchor; this.element.scrollTo(this.to[0], this.to[1]); }, true); }, useLink: function(link, anchor){ link.addEvent('click', function(event){ var el = document.id(anchor) || this.doc.getElement('a[name=' + anchor + ']'); if (!el) return; event.preventDefault(); this.toElement(el, this.options.axes).chain(function(){ this.fireEvent('scrolledTo', [link, el]); }.bind(this)); this.anchor = anchor; }.bind(this)); return this; } });
Version data entries
7 entries across 7 versions & 1 rubygems