backtotop button

This commit is contained in:
Ruud
2012-01-22 00:11:03 +01:00
parent ddc05ea813
commit 08889d3241
2 changed files with 48 additions and 2 deletions
+26 -2
View File
@@ -5,7 +5,31 @@ Block.Navigation = new Class({
create: function(){
var self = this;
self.el = new Element('ul.navigation');
self.el = new Element('div.navigation').adopt(
self.nav = new Element('ul'),
self.backtotop = new Element('a.backtotop', {
'text': 'back to top',
'events': {
'click': function(){
window.scroll(0,0)
}
},
'tween': {
'duration': 100
}
})
)
new ScrollSpy({
min: 400,
onLeave: function(){
self.backtotop.fade('out')
},
onEnter: function(){
self.backtotop.fade('in')
}
})
},
addTab: function(tab){
@@ -13,7 +37,7 @@ Block.Navigation = new Class({
return new Element('li').adopt(
new Element('a', tab)
).inject(self.el)
).inject(self.nav)
}