##### Original By Chris Coyier, expanded upon by many others

# AnythingSlider

Theme:

- ### Other Information

  - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla aliquet accumsan eros, et iaculis massa fringilla auctor.
  - Proin a mi ante, ut lobortis risus. Sed fringilla augue sed enim faucibus eget aliquam tellus ultricies.
  - Morbi a magna eu ligula scelerisque lobortis vel non nisi.
  - Aliquam condimentum libero eget elit ultrices sit amet ullamcorper felis gravida.

- ### Queenie's Killer Tomato Bagel Sandwich

  #### Ingredients

  - 1 bagel, split and toasted
  - 2 tablespoons cream cheese
  - 1 roma (plum) tomatoes, thinly sliced
  - salt and pepper to taste
  - 4 leaves fresh basil

- > In awe I watched the waxing moon ride across the zenith of the heavens like an ambered chariot towards the ebon void of infinite space wherein the tethered belts of Jupiter and Mars hang forever festooned in their orbital majesty. And as I looked at all this I thought... I must put a roof on this lavatory.
  > -- Les Dawson

- > Life is conversational. Web design should be the same way. On the web, you’re talking to someone you’ve probably never met – so it’s important to be clear and precise. Thus, well structured navigation and content organization goes hand in hand with having a good conversation.

  - Chikezie Ejiasi

## Features

- Panels are HTML Content (can be anything).
- Multiple AnythingSliders allowable per-page.
- Add or remove content, then easily update the slider.
- Themes can be applied to individual sliders.
- Infinite/Continuous sliding (always slides in the direction you are going, even at "last" slide). This can be disabled.
- Show multiple slides within AnythingSlider at once. *New in version 1.5.14*
- Expand the slider to fit inside of its container (so it now works with full width or any percentage width fluid layouts). *New in version 1.5.16*
- Optionally resize each panel (specified per panel in css).
- Optional Next / Previous Panel Arrows.
- Use keyboard navigation or tabs that are built and added dynamically (any number of panels).
- Link to specific slides or go forward or back one slide from static text links - go to Slide 4 (Quote #2) in second example.
- Each panel has a hashtag (can link directly to specific panels) or use the ID of an element inside the panel.
- Optional custom function for formatting navigation text.
- Auto-playing slideshow (optional feature, can start playing or stopped).
- Pauses slideshow on hover (optional).
- Optionally play the slideshow once through, stopping on the last page.
- Extend the script by binding to custom events, last triggered event: none
- Optional FX extension to add animation to panels elements as they scroll into and out of view. See the demo page.
- Optional Video extension allows video to pauses playing when not in view and resumes when in view (if files are hosted on the web). This currently works for YouTube, Vimeo and HTML5 video. *New in version 1.6*
- Works with jQuery 1.4.2+.

## Default Options

See the documentation for complete description of these options (appearance, navigation, slideshow, callbacks & events, video, interativity & misc).

>     $('#slider').anythingSlider({
>       // Appearance
>       theme               : "default", // Theme name
>       expand              : false,     // If true, the entire slider will expand to fit the parent element
>       resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport
>       vertical            : false,     // If true, all panels will slide vertically; they slide horizontally otherwise
>       showMultiple        : false,     // Set this value to a number and it will show that many slides at once
>       easing              : "swing",   // Anything other than "linear" or "swing" requires the easing plugin or jQuery UI

>       buildArrows         : true,      // If true, builds the forwards and backwards buttons
>       buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
>       buildStartStop      : true,      // If true, builds the start/stop button

>       appendForwardTo     : null,      // Append forward arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
>       appendBackTo        : null,      // Append back arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
>       appendControlsTo    : null,      // Append controls (navigation + start-stop) to a HTML element (jQuery Object, selector or HTMLNode), if not null
>       appendNavigationTo  : null,      // Append navigation buttons to a HTML element (jQuery Object, selector or HTMLNode), if not null
>       appendStartStopTo   : null,      // Append start-stop button to a HTML element (jQuery Object, selector or HTMLNode), if not null

>       toggleArrows        : false,     // If true, side navigation arrows will slide out on hovering & hide @ other times
>       toggleControls      : false,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times

>       startText           : "Start",   // Start button text
>       stopText            : "Stop",    // Stop button text
>       forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
>       backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)
>       tooltipClass        : "tooltip", // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)

>       // Function
>       enableArrows        : true,      // if false, arrows will be visible, but not clickable.
>       enableNavigation    : true,      // if false, navigation links will still be visible, but not clickable.
>       enableStartStop     : true,      // if false, the play/stop button will still be visible, but not clickable. Previously "enablePlay"
>       enableKeyboard      : true,      // if false, keyboard arrow keys will not work for this slider.

>       // Navigation
>       startPanel          : 1,         // This sets the initial panel
>       changeBy            : 1,         // Amount to go forward or back when changing panels.
>       hashTags            : true,      // Should links change the hashtag in the URL?
>       infiniteSlides      : true,      // if false, the slider will not wrap & not clone any panels
>       navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
>       navigationSize      : false,     // Set this to the maximum number of visible navigation tabs; false to disable

>       // Slideshow options
>       autoPlay            : false,     // If true, the slideshow will start running; replaces "startStopped" option
>       autoPlayLocked      : false,     // If true, user changing slides will not stop the slideshow
>       autoPlayDelayed     : false,     // If true, starting a slideshow will delay advancing slides; if false, the slider will immediately advance to the next slide when slideshow starts
>       pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
>       stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page. This also stops the rewind effect when infiniteSlides is false.
>       playRtl             : false,     // If true, the slideshow will move right-to-left

>       // Times
>       delay               : 3000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
>       resumeDelay         : 15000,     // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
>       animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
>       delayBeforeAnimate  : 0,         // How long to pause slide animation before going to the desired slide (used if you want your "out" FX to show).

>       // Callbacks
>       onBeforeInitialize  : function(e, slider) {}, // Callback before the plugin initializes
>       onInitialized       : function(e, slider) {}, // Callback when the plugin finished initializing
>       onShowStart         : function(e, slider) {}, // Callback on slideshow start
>       onShowStop          : function(e, slider) {}, // Callback after slideshow stops
>       onShowPause         : function(e, slider) {}, // Callback when slideshow pauses
>       onShowUnpause       : function(e, slider) {}, // Callback when slideshow unpauses - may not trigger properly if user clicks on any controls
>       onSlideInit         : function(e, slider) {}, // Callback when slide initiates, before control animation
>       onSlideBegin        : function(e, slider) {}, // Callback before slide animates
>       onSlideComplete     : function(slider) {},    // Callback when slide completes; this is the only callback without an event "e" variable

>       // Interactivity
>       clickForwardArrow   : "click",         // Event used to activate forward arrow functionality (e.g. add jQuery mobile's "swiperight")
>       clickBackArrow      : "click",         // Event used to activate back arrow functionality (e.g. add jQuery mobile's "swipeleft")
>       clickControls       : "click focusin", // Events used to activate navigation control functionality
>       clickSlideshow      : "click",         // Event used to activate slideshow play/stop button

>       // Video
>       resumeOnVideoEnd    : true,      // If true & the slideshow is active & a supported video is playing, it will pause the autoplay until the video is complete
>       addWmodeToObject    : "opaque",  // If your slider has an embedded object, the script will automatically add a wmode parameter with this setting
>       isVideoPlaying      : function(base){ return false; } // return true if video is playing or false if not - used by video extension
>     });

## Known Issues

- Please refer to the documentation.

## Changelog

Only the latest versions will be shown here. See the full change log here.

### Version 1.7.16

- Ok, I didn't like changing the video option as it was below, so I moved the option into the core plugin. The option is now called `resumeOnVisible`.

### Version 1.7.15.1

- Fixed an issue in the video extension where watching a related YouTube video in the slider would cause javascript errors.
- Added another known issue with the video extension - Watching a related video breaks the ability if the slider to continue playing and pause the slideshow while playing these videos. This is because the iframe does not update the video URL and there is no way, that I know of, of determining which iframe is reporting a status change.
- Added a video option named `resumeVideo` which when false, does not continue playing a paused video. Change this option as follows (inside of a document ready call and before the slider is initialized):

      $.anythingSliderVideoDefaults.resumeVideo = false;

### Version 1.7.15

- Fix an issue with calling the navigation window function which isn't initialized when the number of tabs shown equals the `navigationSize` value. Fix for issue #209.

### Version 1.7.14

- Attempted to fix an issue with adding slider content based on the error reported in issue #207.
- Links in nested sliders should now work properly. Fix for issue #208.
- Changed YouTube video status updating, to hopefully fix issue #191. But I noticed a few other problems in Safari, so I will address those soon.
- Fixed a problem with setting the slider height if it was undefined, or set before the image completely loaded. This was introduced in v1.7.13.

### Version 1.7.13

- Updated the plugin so that if panel sizes aren't defined in the css, it will default to the slider size. This should fix the problem with the slider initializing with a zero width or height.
- Added a "targetPage" callback variable which contains the targeted page number; "$targetPage" still contains the jQuery object of the targeted page. This can be used in event or callbacks:

      $('#slider').bind('slide_begin', function(event, slider){
        console.debug( 'The target page is #' + slider.targetPage );
        console.debug( 'The title of the target page is: ' + slider.$targetPage.find('h1').text() );
        // Do something else
      });

  Note that the targetPage variable contains the correct page before the slider animates, whereas "slider.currentPage" contains the current slide and is not updated until after the animation completes. See the "Callback Arguments" section in the wiki documents for a full list.

### Version 1.7.12

- Clicking links inside of a slide when mulitple slides are showing will no longer change the slider. Fix for issue #187.
- Updated how the navigation width was calculated when `navigationSize` is set so the new tabs-light and tabs-dark themes tab widths are calculated a bit more accurately - but it's still not perfect.

### Version 1.7.11.5

- Updated the AnythingSlider css file to restore the overflow setting after the slider has initialized. Fix for issue #183. Thanks sawmac!
- This fixes a problem created in the previous update.

### Version 1.7.11.4

- Updated the AnythingSlider css file to include the flash of unstyled content (FOUC) method 1 from the FAQ page

### Version 1.7.11.3

- Updated the FX extension
  - When the `animationTime` is set to zero, the "fade" out effect occurred immediately. The fx extension has been updated to use the default time instead.
  - Updated the fade FX demo to use `delayBeforeAnimate` to allow the current image to fade out before transitioning.

### Version 1.7.11.2

- Added a local copy of jQuery with fallback.

### Version 1.7.11.1

- Fixed a problem with the "fade" fx. See issue #171.
  - In older versions, the size parameter was ignored; but with the changes in 1.7.11, it became required and now follows the same format as all of the other effects.
  - The value is actually an opacity to use and must be included if adding a time or easing effect.

        // '.selector' : [ 'fade', 'opacity', 'time', 'easing' ]
        '.selector' : [ 'fade', '', 500, 'easeInOutCirc' ] // opacity number between 0 and 1 (default is 1, so using '' will set the value to 1)

### Version 1.7.11

- Updated the FX extension:
  - Added `grow` option that allows for growing text - like in the movies! *popcorn*
  - Allow ability to set multiple sizes for the grow and expand fx by simply separating the two values with a comma. If only one value is present, the fx will use that value (left side of the comma) as described below.

        // '.selector' : [ 'effect(s)', 'distance/size', 'time', 'easing' ]
        '.selector' : [ 'grow', '24px, 80px' ]   // 'original text size, fx size'
        '.selector' : [ 'expand', '10%, 100%' ], // 'fx size, original size'

  - The difference between grow and expand is that grow changes the font size whereas expand changes the width and height.
  - Added ability to set the `fade` ending opacity.

        // '.selector' : [ 'effect(s)', 'distance/size', 'time', 'easing' ]
        '.selector' : [ 'fade', '0.8' ] // opacity number between 0 and 1

  - Changed the intro fx from being initialized immediately to occurring when the page has finished loading.
- Fixed a problem that occurs when `resizeContents` is false and the slide content has padding and/or margins.

### Version 1.7.10

- Fixed a problem where setting the `animationTime` to zero would not trigger any callbacks, thus preventing the FX extension from working.

### Version 1.7.9

- Added `vertical` option
  - When true, all of the content in the slider will scroll vertically.
  - Included up & down keyboard keys to navigate, but only when the vertical option is true.
  - The `showMultiple` option does not currently work when the content is vertical. I may fix this in future versions.
  - Thanks to Caroline-Elisa for the suggestion - in issue #166.
- AnythingSlider will now accept an ID or classname to target a specific panel in the slider. Callbacks can also be included. Here is an example:

      // original method
      $('#slider').anythingSlider(4);

      // additional method
      $('#slider').anythingSlider('#quotes');

- Updated FX extension
  - Fixed a problem with the "expand" effect in the FX extension where the height would not change in some browsers.
  - Added `outFxBind` and `inFxBind` options which set which AnythingSlider callbacks are used. This might be more useful if binding FX on slide begin so the element is already animating when the slide comes into view.