rob@100: // Easing equation, borrowed from jQuery easing plugin rob@100: // http://gsgd.co.uk/sandbox/jquery/easing/ rob@100: jQuery.easing.easeOutQuart = function (x, t, b, c, d) { rob@100: return -c * ((t=t/d-1)*t*t*t - 1) + b; rob@100: }; rob@100: rob@100: jQuery(function( $ ){ rob@100: /** rob@100: * Most jQuery.serialScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option. rob@100: * @see http://flesler.demos.com/jquery/scrollTo/ rob@100: * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.serialScroll. rob@100: */ rob@100: rob@100: /** rob@100: * The plugin binds 6 events to the container to allow external manipulation. rob@100: * prev, next, goto, start, stop and notify rob@100: * You use them like this: $(your_container).trigger('next'), $(your_container).trigger('goto', [5]) (0-based index). rob@100: * If for some odd reason, the element already has any of these events bound, trigger it with the namespace. rob@100: */ rob@100: rob@100: /** rob@100: * IMPORTANT: this call to the plugin specifies ALL the settings (plus some of jQuery.ScrollTo) rob@100: * This is done so you can see them. You DON'T need to specify the commented ones. rob@100: * A 'target' is specified, that means that #screen is the context for target, prev, next and navigation. rob@100: */ rob@100: $('#screen').serialScroll({ rob@100: target:'#sections', rob@100: items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case ) rob@100: prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document) rob@100: next:'img.next',// Selector to the 'next' button (absolute too) rob@100: axis:'xy',// The default is 'y' scroll on both ways rob@100: navigation:'#navigation li a', rob@100: duration:500,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time) rob@100: force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes) rob@100: rob@100: //queue:false,// We scroll on both axes, scroll both at the same time. rob@100: //event:'click',// On which event to react (click is the default, you probably won't need to specify it) rob@100: //stop:false,// Each click will stop any previous animations of the target. (false by default) rob@100: //lock:true, // Ignore events if already animating (true by default) rob@100: //start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case ) rob@100: //cycle:true,// Cycle endlessly ( constant velocity, true is the default ) rob@100: //step:1, // How many items to scroll each time ( 1 is the default, no need to specify ) rob@100: //jump:false, // If true, items become clickable (or w/e 'event' is, and when activated, the pane scrolls to them) rob@100: //lazy:false,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering) rob@100: //interval:1000, // It's the number of milliseconds to automatically go to the next rob@100: constant:true, // constant speed rob@100: rob@100: onBefore:function( e, elem, $pane, $items, pos ){ rob@100: /** rob@100: * 'this' is the triggered element rob@100: * e is the event object rob@100: * elem is the element we'll be scrolling to rob@100: * $pane is the element being scrolled rob@100: * $items is the items collection at this moment rob@100: * pos is the position of elem in the collection rob@100: * if it returns false, the event will be ignored rob@100: */ rob@100: //those arguments with a $ are jqueryfied, elem isn't. rob@100: e.preventDefault(); rob@100: if( this.blur ) rob@100: this.blur(); rob@100: }, rob@100: onAfter:function( elem ){ rob@100: //'this' is the element being scrolled ($pane) not jqueryfied rob@100: } rob@100: }); rob@100: rob@100: /** rob@100: * No need to have only one element in view, you can use it for slideshows or similar. rob@100: * In this case, clicking the images, scrolls to them. rob@100: * No target in this case, so the selectors are absolute. rob@100: */ rob@100: rob@100: });