6
May

This 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 for the demo.

Click here to download the source.



3 Diggs Spread This

16 Responses


[...] 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

Ultimate is not the proper word.
It should degrade a lot better with javascript turned off to deserve that word.
You should use javascript to set some css attribute.

Grab on 07 May 2008 at 7:26 am

@Grab - Per my post “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.”

Michael on 07 May 2008 at 7:49 am

[...] Очень интересно выглядит. Не буду расписывать, а просто дам ссылку. [...]

Блокнот » Blog Archive » JavaScript: Скролер и Слайдер on 07 May 2008 at 7:58 am

Thanks Michael, this is definitely something i am going to use on my site.

nice post :)

Phil on 07 May 2008 at 4:37 pm

[...] Источник: Блог Майкла Лейгебера. [...]

Универсальный слайдер | АяксЛайн.ру on 07 May 2008 at 4:56 pm

[...] 18)Ultimate JavaScript Scroller and Slider- This versatile and lightweight JavaScript makes it easy to scroll text blocks, create slideshows, slide between content, create tickers and more. [...]

30+ Javascript/Ajax Techniques for Sliders, Scrollers and Scrollbars on 07 May 2008 at 5:34 pm

[...] it easy to scroll text blocks, create slideshows, slide between content, create tickers and more.http://www.leigeber.com/2008/05/ultimate-javascript-scroller-and-slider/Free-Javascripts.com - 100s of free scriptsA database listing 100s of free javascripts that you may [...]

javascripts on 09 May 2008 at 5:19 pm

[...] Ultimate JavaScript Scroller and Slider - Web Development Blog [...]

JSPT - テキストnoスライド on 09 May 2008 at 7:43 pm

[...] 18)Ultimate JavaScript Scroller and Slider- 这种多用途的和轻量级的JavaScript可以很容易滚动文本块,制作幻灯片,投影片之间的内容,代号和创造更多。 [...]

30个 Ajax/Javscript 滑动门, 滚动栏和滚动条技术 | 帕兰映像 on 16 May 2008 at 4:50 am

thanx Michael. this is very useful clean and easy to use…. i wonder if it can be configurable like a loop… i mean. the after the last item loads the content again without scrolling up to the begining. it will be nice!

fullmental on 27 May 2008 at 11:33 am

@fullmetal - It could be and I might specifically create a script for that functionality before too long. The current script could be modified to update the DOM dynamically to create the continuous loop effect. Shoot me an email if you need the script soon and I will help you work it out. michael@leigeber.com

Michael on 27 May 2008 at 11:47 am

[...] Contenido deslizante. [...]

JavaScript sin frameworks / acualicio.us on 01 Jun 2008 at 11:57 pm

can this script be configured to autoplay the slideshow when the web page loads? i tried putting

onload=”autoScroll(’imgslider’,'imgsection’,5,true)”

on the <body> tag..
there’s an error..

any idea how to go about getting this right?

glove on 20 Jun 2008 at 9:28 pm

@glove - Sure, on the demo page the first example is doing just that. If you are still having a problem email me a link and I will take a look.

Michael on 22 Jun 2008 at 9:50 am

hi michael, great script!! I use it on http://www.martin-franssen.de/de/klienten/case-studies.php for displaying a scrollable list of news entries. everything’s fine exept a strange behaviour using the Internet Explorer 6: if you are scrolling using the two icons on the right side the text is going to be bolded od blurred… any suggestions?

bolleone on 24 Jun 2008 at 3:40 am
Trackback URI | Comments RSS

Leave a Reply

Subscribe to RSS Feed
Powered by FeedBurner
Recent Links
Tag Cloud