« back

jQuery ClickScroller Plugin

This is a simple jQuery plugin used to create a horizontal or vertical clicking scroll menu. It’s lightweight, simple and easy to customize as needed.

1. Setup

  • Download jQuery, and add it into the head of your document
  • Download the ClickScroller package, and add jquery.clickscroller.js into the head of your document
  • Optionally, grab the easing js (is included with the download package)

2. Write Some HTML

<div id="yourContainer">
	<ul>
		<li>A list item</li>
		<li>Another list item</li>
		<li>Another list item</li>
		<li>Etc...</li>
	</ul>
</div>
<a id="#clickscroll-more" href="#">More</a>
<a id="#clickscroll-less" href="#">Less</a>

3. Write some CSS

#yourContainer {
	height: 300px; /* REQUIRED FOR VERTICAL SCROLLING */
	width: 500px; /* REQUIRED FOR HORIZONTAL SCROLLING */
	overflow: hidden; /* DO NOT REMOVE */
	position: relative; /* DO NOT REMOVE */
}
#yourContainer ul {
	list-style: none;
	padding: 0;
	margin: 0;
	position: absolute;	/* DO NOT REMOVE */
}
#yourContainer ul li {
	padding: 0;
	margin: 0;
}

4. Write some Javascript (well jQuery)

$(function(){
	$('#yourContainer').clickScroll();
});

4. Customize

This is how you could setup a horizontal scroller using all the options, like in the demo

$('#yourContainer-horizontal').clickScroll({
	speed: 1000, // Scroll Speed
	easing: 'easeOutElastic', // Animation easing method
	lessBtn: '#scroll-left', // Custom ID of scroll button
	moreBtn: '#scroll-right', // Custom ID of scroll button
	btnFadeSpeed: 500, // Speed of button fading in/out when not end of scrolling is reached
	horizontal: true // Make it scroll Horizontally,
	autoHideNav: false // Don't hide the navigation controls automatically
});

You’ll also want to change you CSS so the list elements are floated or inline-block…

Other Notes

  • The plugin relies on an unordered list <ul> and list items <li> to be children of the container, if you use something else, it won’t work.
  • When horizontally scrolling, the width of the list will be automatically calculated and applied. If you’re changing the widths of list items dynamically, you might have to get creative in the source.
  • Don’t add your control links into the container.

Changelog

  • “autoHideNav” option added for control over navigation controls being automatically hidden/shown.

Download

Demo

[5] Comments
You can skip to the end and leave a response. Pinging is currently not allowed.

 

5 Comments

This plugin is fantastic! I’ve been search long and hard for a vertical news scroll with manual navigation. Many examples have autoscrolls that make it too confusing for some.

It would be good to see the ‘more’ link as a boolean too :)

I plan use also have an excerpt under the headline with a maximum number of characters followed by ‘… Read More’. Is this possible?

Thanks again for the plugin – I’ll be trying it out 1st thing tomorrow.

  • At: 1:43 am
  • On: 26 // 02 // 2010
  • By: Chris

I’m just playing about with the plugin – really liking it.
Is there a way I can get each scroll to ‘lock’ on to the 4 list items? i.e. so we dont see a cutt-off part of the next page’s list item?
Thanks :)

  • At: 1:34 pm
  • On: 26 // 02 // 2010
  • By: Chris

I would like both the ‘more’ and ‘back’ buttons to be always visible — not hidden when you are at the beginning or end of the list. Is this possible to change?

  • At: 2:31 am
  • On: 15 // 03 // 2010
  • By: Camila

@Camila: I have updated the plugin to include a “autoHideNav” boolean option. Just set it to false, and the ‘more’ and ‘back’ button will ramin in place, but just be disabled when the scrolling is at the beginning or end of the list. Check out the option in action on the horizontal example in the demo.

  • At: 4:07 am
  • On: 15 // 03 // 2010
  • By: Jeff

The clickscroller plugin seems to be disabling the preloading effects I have in my navigation. Could this be a problem with the javascript?

  • At: 4:28 pm
  • On: 17 // 03 // 2010
  • By: Camila

 Leave a Comment 


Archived Posts

Linkage