written on:3 Apr, 2008 by Alen Grakalic
Easy Scroll: Accessible Content Scroller
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
![]()
It has been a while since I presented some unobtrusive (hopefully useful) JavaScript function. Recently I have been working on a project that demanded content scrolling, so instead of reaching out for some heavy unobtrusive solutions, I decided to write my own function. As I was developing it I kept simplifying it so I came down to what I am presenting today - Easy Scroll v1.0, an accessible, unobtrusive content scroller.
I am not using any JS libraries with Easy Scroll. Although I enjoy jQuery a lot, I believe that it is important to code in "regular" JS, just not to forget it :)
So, Easy Scroll is standalone, lightweight script that is very easily applicable.
Take a look at the demo | Download Easy Scroll v1.0
Features
Easy Scroll is capable of scrolling any type of content by using unobtrusive JavaScript. It has up and down scroll options and reset button that places your content in the default position.
It also features double speed. When buttons are rolled over, slow scrolling starts. When buttons are pressed, speed increases.
Ok, let's get it going
To start with Easy Scroll download the script, and link it to your document by placing this line of code inside the head tag:
<script type="text/javascript" src="easyscroll/easyscroll.js"></script>
You'll also need a div with custom id (default is "myContent"). Then you should put some content in it of course :)
<div id="myContent"> <!-- YOUR CONTENT HERE --> </div>
Believe it or not, as far as the markup is concerned, that's it!
The script takes it over from here.
It creates another div id="easyscroll" and places your content div inside and takes care of the absolute positioning, scroll buttons and scrolling.
Setting things up
You might want to set the variables in the JavaScript. When you open easyscroll.js you'll notice these variables in config area
var id = "myContent";
This id matches the one you have in your html file for content div. If you wish to change it, you must do it in both html and JavaScript
var nav = ["Scroll Up", "Scroll Down", "Reset"];
Text that appears inside of each scroll button.
var navId = ["btnUp", "btnDown", "btnReset"];
These are optional id's for scroll buttons in case you want to apply some specific CSS for each.
var speed = 5;
Movement speed. The larger the number the faster the scrolling will be.
var height = 200;
Desired height of the Easy Scroll area.
Use css to style the content area. Oh yes, buttons are rendered as unordered list. Use css to style those too :)
About the author:
Designer, developer and a passionate standardista with large experience in all types of front-end work. Started to get involved with web in 1999. and turned freelance in 2005., the same year he started Css Globe. Alen's work has been featured on numerous css galleries including famous Css Zen Garden official list. Available for contract work.
Enjoyed the article?
Subscribe to our RSS feed or share it with your friends.
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed

ani625 on 3 Apr, 2008 wrote:
And btw, Link updated on delicious.
cssglobe on 3 Apr, 2008 wrote:
b0li on 3 Apr, 2008 wrote:
greetings
kerberoS on 3 Apr, 2008 wrote:
WebTecker on 3 Apr, 2008 wrote:
cssglobe on 3 Apr, 2008 wrote:
Tomas M on 3 Apr, 2008 wrote:
can be used for left/top scrolling ?
cssglobe on 3 Apr, 2008 wrote:
Germán on 3 Apr, 2008 wrote:
davidwalsh on 4 Apr, 2008 wrote:
Steph on 4 Apr, 2008 wrote:
Thanks Alen!
Chad Smith on 4 Apr, 2008 wrote:
Derek on 4 Apr, 2008 wrote:
cssglobe on 4 Apr, 2008 wrote:
ani625 on 4 Apr, 2008 wrote:
cssglobe on 4 Apr, 2008 wrote:
Roman Lokhov on 5 Apr, 2008 wrote:
But don't you think that to use offsetHeight and offsetTop is very slow? Especially if the "myContent" have many content (images, flash)?
webfruits on 6 Apr, 2008 wrote:
cssglobe on 6 Apr, 2008 wrote:
Philly Dude on 9 Apr, 2008 wrote:
emre on 11 Apr, 2008 wrote:
how can I replace "graphic" instead of texts...
I mean; I want add UP and DOWN ARROW to the leftside of my div...
can I do that with this script?
cssglobe on 11 Apr, 2008 wrote:
Alberto on 13 Apr, 2008 wrote:
Thanks, great job.
AndreiZorrov on 13 Apr, 2008 wrote:
I searched for a very long time
mexx63 on 17 Apr, 2008 wrote:
Thanks
cssglobe on 17 Apr, 2008 wrote:
Mya on 17 Apr, 2008 wrote:
Deborah on 22 Apr, 2008 wrote:
dj
Juvenn on 22 Apr, 2008 wrote:
Krystal on 23 Apr, 2008 wrote:
Daddo on 29 Apr, 2008 wrote:
I think I'll be using it soon on my sites...
:-D
Aaron Mc Adam on 6 May, 2008 wrote:
graham on 7 May, 2008 wrote:
However, I'm wondering how to add two blocks of scrolling text at different points on a page. If it uses ids, is this even possible?
weremoose on 10 May, 2008 wrote:
Pete on 13 May, 2008 wrote:
Jim on 15 May, 2008 wrote:
victoria on 23 May, 2008 wrote:
I am a beginner too...can't figure out what webfruits did.
victoria on 29 May, 2008 wrote:
Here is the page I'm using it on http://www.pslarchitects.com/projects.html
fracto on 29 May, 2008 wrote:
Thank you very much!! Good job!
Tim Wye on 5 Jun, 2008 wrote:
Jacob on 6 Jun, 2008 wrote:
But, Is it possible to make it scroll horizontally instead?
- Jacob
Matias on 11 Jun, 2008 wrote:
Rainer on 2 Jul, 2008 wrote:
Simon Dempsey on 5 Jul, 2008 wrote:
I notice a number ppl struggling witht the hover over image function (as per Webfruits site) - this is done with css people - check out this code from my style sheet:
#btnUp{
background-image: url(../images/global/scroll-up_off.gif);
background-repeat: no-repeat;
float: left;
height: 9px;
width: 67px;
margin-right: 4px;
}
#btnUp.over {
background-image: url(../images/global/scroll-up_on.gif);
background-repeat: no-repeat;
text-decoration:none;
}
#btnDown{
background-image: url(../images/global/scroll-down_off.gif);
background-repeat: no-repeat;
float: left;
height: 9px;
width: 67px;
margin-right: 4px;
}
#btnDown.over {
background-image: url(../images/global/scroll-down_on.gif);
background-repeat: no-repeat;
text-decoration:none;
}
Great job again Alen!
nodosur on 6 Jul, 2008 wrote:
Chrissy on 9 Jul, 2008 wrote:
Gabor on 10 Jul, 2008 wrote:
If you want to use image buttons instead of text buttons do the following:
1. Change script var nav to: var nav = ["", "", ""];
2. Take out the line: background in style in #easyscrollnav li
3. Add this lines to style:
#btnUp{
background:url(your_image.jpg)no-repeat 0 0;
}
#btnDown{
background:url(your_image.jpg)no-repeat 0 0;
}
Dempo on 11 Jul, 2008 wrote:
Saboravallarta on 11 Jul, 2008 wrote:
dario on 15 Jul, 2008 wrote:
But if i'd like insert more than one?
Is it possible?
Michael on 18 Jul, 2008 wrote:
If you'll notice in the html, the div for the scrolling content is labeled as an ID, not a CLASS, ergo, one per page.
Which is not to say that some tweak to the js might allow for multilple IDs of different names. I'm not sure of the liklihood or not, just a thought. Perhaps the author might chime in.
Oh, and thanks for a very nice implementation.
Owain on 1 Aug, 2008 wrote:
Im trying to use easyscroll in the same way as the webfruits site. where the buttons are down the right side of the content area...
The site im currently working on has a scroll bar by using the overflow css property.. Does anyone know anywhere online which shows you how to position the buttons to the right?
Jorgen Farum Jensen on 1 Aug, 2008 wrote:
container.style.padding = "1em"
This doesn't seem to work. I'm sure there must be a way, but how?
Steph on 3 Aug, 2008 wrote:
Still wish I could switch the buttons though - but still good scroller!
JanB on 8 Aug, 2008 wrote:
Be allows prepared for users like me ;)
Subscribe
Join 5000+ subscribers and receive our content instantly.
Subscribe to our feed
Follow us on Twitter
Want to be the first to know when a new article is published?
Follow us on Twitter
Sponsors
PSD to HTML
Look Professional with FreshBooks
Sitegrinder 2 Photoshop Plugin
PSD to HTML
Cart45 Shopping Cart Software
Convert Design to XHTML/CSS
Online Bookmark Manager
Advertise here
Recent Articles
Recent Community News