Dezinerfolio

dfSmooth Scroll

Your rating: None Average: 4.1 (258 votes)
Virtual Img: 
One Line Description: 
A simple smooth scroll light-weight JS

We are again back with another interesting miniature javascript called the “df Smooth Scroll“. This script is also one of the smallest Smooth Scrolling Javascripts after our Simple Accordions.

  • Simplest to implement
  • One of the smallest Javascript 1024 bytes
  • Cross-Browser compatible
  • Includes the source file too…

We always see that we have atleast one image on every post of ours… but for this script we were too confused to go about the image and finally put up the above one (sorry if it pains your eyes cos its motion blurred )

Usage: This script is too simple to understand and use. Nothing but playing with Anchor Tags. Include the Javascript and you are set to smoooooooooth scroll…

AttachmentSizeHitsLast download
dfSmooth Scroll5.66 KB587045 min 35 sec ago

Comments

Anonymous's picture

Very nice scroller. I customised it to use id attribute of the tag instead of name, it then validates to xhtml1.1.
Used on our site
http://www.zoneix.net

Steve (not verified)
Sat, 07/04/2009 - 16:50
Anonymous's picture

Awesome. so easy, just paste the code directly above in your html file, and include the two java script files in the associated folder. Works every time, unlike some other versions I'd been trying. Thanks!
(unfortunately, I noticed the scroller does not work when links are withing dynamic menus)

J-NYC (not verified)
Tue, 06/23/2009 - 10:02
Anonymous's picture

Absolutely awesome! Much simpler than mooscroll love it love it love it thank you!

Kyleigh (not verified)
Mon, 06/08/2009 - 18:56
Anonymous's picture

Hello. Great bit o' Javascript. Have applied it to my simple website (www.themoreiblog) and I was wondering if someone could help me. If you click "archive" on my website, you are smooth scrolled down to the right anchor, but it positions it at the foot of the browser, rather than at the top. Please -- any ideas would be much appreciated. Cheers all.

PJV2097 (not verified)
Fri, 06/05/2009 - 20:37
Anonymous's picture

How can i use it to scroll down a hidden overflow div?

alex boudreau (not verified)
Sun, 05/31/2009 - 00:14
Anonymous's picture

Great script.. but didn't work for the latest version of opera.. can someone solve the problem?

dope259 (not verified)
Fri, 05/29/2009 - 12:28
Anonymous (not verified)
Wed, 05/27/2009 - 13:47
Anonymous's picture

For those who need the decrypted code: ;-)

Scroller={speed:10,offsetParent:function(d){offsetParent=d.offsetTop;if(d.offsetParent){while(d=d.offsetParent){offsetParent+=d.offsetTop}}return offsetParent},scrollTop:function(){body=document.body;d=document.documentElement;if(body&&body.scrollTop){return body.scrollTop}if(d&&d.scrollTop){return d.scrollTop}if(window.pageYOffset){return window.pageYOffset}return 0},attachEvent:function(a,b,d){if(a.addEventListener){return a.addEventListener(b,d,false)}if(a.attachEvent){return a.attachEvent("on"+b,d)}},end:function(e){if(window.event){window.event.cancelBubble=true;window.event.returnValue=false;return}if(e.preventDefault&&e.stopPropagation){e.preventDefault();e.stopPropagation()}},scroll:function(d){i=window.innerHeight||document.documentElement.clientHeight;h=document.body.scrollHeight;a=Scroller.scrollTop();if(d>a){if(h-d>i){a+=Math.ceil((d-a)/Scroller.speed)}else{a+=Math.ceil((d-a-(h-d))/Scroller.speed)}}else{a=a+(d-a)/Scroller.speed}window.scrollTo(0,a);if(a==d||Scroller.offsetTop==a){clearInterval(Scroller.interval)}Scroller.offsetTop=a},init:function(){Scroller.attachEvent(window,"load",Scroller.load)},load:function(){a=document.getElementsByTagName("a");Scroller.end(this);window.onscroll;for(i=0;i

Anonymous (not verified)
Wed, 05/27/2009 - 13:36
Anonymous's picture

Great little script. One thing - I want the page to open at lets say the middle anchor rather then the top. How do I do this ?

Gra (not verified)
Mon, 05/18/2009 - 15:22
Anonymous's picture

nice post!

Thanks,
congtythietkewebsite.com

Cong Nguyen (not verified)
Wed, 05/13/2009 - 13:12

Post new comment

The content of this field is kept private and will not be shown publicly.

Visualize