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:
Subscribe
Join 3800+ 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: You Design - We XHTML
Smashing Jobs
Sitegrinder 2 Photoshop Plugin
Look Professional with FreshBooks
PSD2HTML Slicing
FlashDen - The Best Flash Files
Convert Design to XHTML/CSS
Online Bookmark Manager
Advertise here
Recent Articles
Recent Community News