Dezinerfolio

dfSmooth Scroll

Your rating: None Average: 4.1 (174 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 KB454531 hour 59 min ago

Comments

Anonymous's picture

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

Kyleigh (not verified)
Mon, 06/08/2009 - 05:26
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 - 07:07
Anonymous's picture

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

alex boudreau (not verified)
Sat, 05/30/2009 - 10:44
Anonymous's picture

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

dope259 (not verified)
Thu, 05/28/2009 - 22:58
Anonymous (not verified)
Wed, 05/27/2009 - 00:17
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 - 00:06
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 - 01:52
Anonymous's picture

nice post!

Thanks,
congtythietkewebsite.com

Cong Nguyen (not verified)
Tue, 05/12/2009 - 23:42
Anonymous's picture

Can you smooth scroll two things at once? Like two iframes from the main page or the main page and an iframe? This is a feature that I haven't gotten to work with other frameworks.

pat (not verified)
Tue, 05/12/2009 - 17:24
Anonymous's picture

hi,
i was wondering, if smooth scroll works from FLASH (AS2).
I have a line getURL('#footer') - this does not work. Any ideas how could smooth scroll work from flash.

thanks.

Z Ali (not verified)
Wed, 04/22/2009 - 02:44

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.