Skip to content
Mottie edited this page Nov 15, 2013 · 26 revisions

Sections: Default Options | Standard Page Setup | Movable Type Setup | Wordpress Setup | Minimum jQuery Version

$('#slider')
  .anythingSlider({
    // Appearance
    theme               : "default", // Theme name
    mode                : "horiz",   // Set mode to "horizontal", "vertical" or "fade" (only first letter needed); replaces vertical option
    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
    aspectRatio         : null,      // Valid values: null, true, a float e.g. 1.5 (or as 3/2) or a ratio in a string e.g. '3:2'
    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 and adds slideshow functionality

    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         : "»", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
    backText            : "«", // 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
    allowRapidChange    : false,           // If true, allow rapid changing of the active pane, instead of ignoring activity during animation

    // Video
    resumeOnVideoEnd    : true,      // If true & the slideshow is active & a supported video is playing, it will pause the autoplay until the video is complete
    resumeOnVisible     : true,      // If true the video will resume playing (if previously paused, except for YouTube iframe - known issue); if false, the video remains paused.
    isVideoPlaying      : function(base){ return false; } // return true if video is playing or false if not - used by video extension

    // deprecated - use the video extension `wmode` option now
    // addWmodeToObject : "opaque",  // If your slider has an embedded object, the script will automatically add a wmode parameter with this setting
  })
  // initialize the video extension, as desired (new v1.9)
  .anythingSliderVideo({
    // video id prefix; suffix from $.fn.anythingSliderVideo.videoIndex
    videoId         : 'asvideo',
    // this option replaces the `addWmodeToObject` option in the main plugin
    wmode           : "opaque",
    // auto load YouTube api script
    youtubeAutoLoad : true,
    // YouTube iframe parameters, for a full list see:
    // https://developers.google.com/youtube/player_parameters#Parameters
    youtubeParams   : {
      modestbranding : 1,
      iv_load_policy : 3,
      fs : 1,
      wmode: 'opaque' // this is set by the wmode option above, so no need to include it here
    }
  });

Add the following inside the <head></head> of your page. Note: AnythingSlider requires jQuery 1.4+ to work properly.

<!-- jQuery (required) -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<!-- Optional plugins -->
<script src="js/jquery.easing.1.2.js"></script>
<script src="js/swfobject.js"></script>

<!-- Anything Slider -->
<link rel="stylesheet" href="css/anythingslider.css">
<script src="js/jquery.anythingslider.js"></script>

<!-- Add the stylesheet(s) you are going to use here. All stylesheets are included below, remove the ones you don't use. -->
<link rel="stylesheet" href="css/theme-metallic.css">
<link rel="stylesheet" href="css/theme-minimalist-round.css">
<link rel="stylesheet" href="css/theme-minimalist-square.css">
<link rel="stylesheet" href="css/theme-construction.css">
<link rel="stylesheet" href="css/theme-cs-portfolio.css">

<!-- AnythingSlider optional extensions -->
<script src="js/jquery.anythingslider.fx.js"></script>
<script src="js/jquery.anythingslider.video.js"></script>

<!-- Required -->
<script>
$(function(){
 $('#slider')
   .anythingSlider() // add any non-default options here
   .anythingSliderVideo(); // only add this if your slider includes supported videos (new v1.9)
});
</script>

Example HTML

 <ul id="slider">
  <li><div class="text">Put anything you want here</div></li>
  <li><img src="image1.jpg" /></li>
  <li><object>...</object></li>
  <li>
   <div class="list">
    <h4>Title</h4>
    <ul>
     <li>List item #1</li>
     <li>List item #2</li>
    </ul>
   </div>
  </li>
 </ul>

or in AnythingSlider version 1.5.19+ this HTML will work:

<div id="slider">
  <div><!-- slide content --></div>
  <div><!-- slide content --></div>
  <div><!-- slide content --></div>
</div>
  • Ken Edwards (meancode) made a plugin to make it easy to install and use AnythingSlider!
  • Follow the Installation and plugin setup sections in the mt-plugin-anythingslider readme.
  • Jacob Dubail (jacobdubail on github) has made a plugin to make installing AnythingSlider easy in WordPress!
  • Intallation:
    • You can install AnythingSlider for WordPress directly from the WordPress admin panel.
      • Visit the Plugins/Add New page and search for 'AnythingSlider for WordPress'.
      • Click to automatically install.
      • Once installed and activated visit the AnythingSlider admin page (Settings/AnythingSlider) to customize the global AnythingSlider settings.
    • If you're old school, you can download the plugin, upload the files into the wp-content/plugins directory of your server via FTP, and then visit the Plugins page of the admin panel to activate it.
  • AnythingSlider version 1.7.5 no longer supports jQuery 1.3.2. So if your site uses 1.3.2, you'll have to download an older version. The current minimum jQuery version is 1.4.2, but please use the newest version as there are still some known problems with versions 1.5 and older.
  • By default, AnythingSlider was written to work with jQuery version 1.4+. But if you must use jQuery 1.3.2, then open the "jquery.anythingslider.js" file in an editor and uncomment out the last section.
/* AnythingSlider works with works with jQuery 1.4+, but you can add the code below to AnythingSlider
   versions older than 1.7.2 to make the code work with jQuery 1.3.2. You'll have to manually add the
   code below to the minified copy if needed */
 // Copied from jQuery 1.4.4 to make AnythingSlider backwards compatible to jQuery 1.3.2
 if (typeof jQuery.fn.delay === 'undefined') {
  jQuery.fn.extend({
   delay: function( time, type ) {
    time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; type = type || "fx";
    return this.queue( type, function() { var elem = this; setTimeout(function() { jQuery.dequeue( elem, type ); }, time ); });
   }
  });
 }
  • Also note that jQuery versions older than 1.5 have an issue with sliders wider than 10,000 pixels (see the FAQ for more details).