May
Ultimate JavaScript Scroller and Slider
Posted by Michael in JavaScript, XHTMLThis versatile and lightweight JavaScript clocks in at less than 3.5kb unpacked. The above example is one of four scenarios I have demonstrated on the demo page.
To setup a scroll/slide area create a container with the following CSS properties…
position:relative; overflow:hidden; height:XXXpx;
Inside the scroll area container create another div that will house your actual content. It needs the positioned absolutely within the previous div. Each sliding or scrolling area on the page needs to have a unique ID for this div.
position:absolute;
Inside the content div you can need to create a section for each area of content, be it 1 or 50. For each section after the “prefix-” numerate the order from 1 onwards. The prefix (ie section, newssection, imgsection, etc) needs to be unique to the current sliding/scrolling container’s sections.
<div id="section-1" class="section"></div>
You can call functions to incrementally scroll up or down, scroll to a particular section and initiate autoscroll/cancel the autoscroll. Take a look at the source code for examples. You might also consider dynamically adding some currently static CSS properties such as overflow:hidden and the height to allow for better degradation without JavaScript support.
This script has been tested working in IE6/IE7, Firefox, Opera and Safari. Please report all bugs to michael@leigeber.com. This code is free for both personal and commercial projects.
Click here to download the source.
[...] Interesting approach… Published in Spotlight | Tags: CSS | Browse the Archives That’s all. Want more info? Inspiration?Subscribe to the Gallery, the full RSS feed or get it via Email. miloIIIIVII is a graphic and Web designer based in Munich, who works with clients to create exciting and cutting edge web design [...]
Scroller and Slider | milo on 07 May 2008 at 2:55 am