Git Product home page Git Product logo

deck.automatic.js's Introduction

deck.automatic.js

An extension for deck.js allowing you to set your presentation to run automatically, with a specified delay between slides.

Requirements

deck.js ... obviously.

How does it work

Once the extension is correctly loaded and you've inserted the appropriate control element (see How to use), the presentation will start playing automatically. Clicking on the control element will simply play/pause the presentation.

How to use

** You can have a look at the example in the repository to check it works, and how it works. **

  1. Install by copying the automatic folder from the repository to your deck.js extensions' folder.

  2. Load the extension's JS by loading the .../extensions/automatic/deck.automatic.js file in your HTML page.

  3. You may also want to add the CSS (.../extensions/automatic/deck.automatic.css), even if I'm pretty sure you'd better come with your own (styling is currently very basic).

  4. You may add a .deck-automatic-link element to your .deck-container element if you want a clickable play/pause button.

    For example, you can add: <div class='deck-automatic-link' title="Play/Pause">Play/Pause</div> at the end of your .deck-container element.

  5. Custom slide durations may be specified with a custom data-duration attribute specified in milliseconds (<div class="slide" data-duration="5000">content</div>). This attribute overrides the default slide duration. Negative values for either custom duration or default duration disable automatic advancing for the slides they apply to.

Configuration

The automatic extension follows deck.js' configuration way. It currently declares three options:

  1. startRunning: can be true or false. Determines if the presentation start running as soon as it is loaded, or waits for the user to click on the play/pause button.
  2. cycle: true or false. If true, the presentation goes back to slide 1 when it is running and it comes to the last slide.
  3. slideDuration: the default duration (in milliseconds) during which each slide is displayed.

You can set these options by adding the following code before the $.deck('.slide') line:

$.extend(true, $.deck.defaults, {

  // other options (core or extensions)

  automatic: {
  	startRunning: false, 	// true or false
  	cycle: false,			// true or false
  	slideDuration: 1000	// duration in milliseconds
  }
}

You can also change the classes used for the play/pause element through these options:

  classes: {
	automaticRunning: 'deck-automatic-running',
	automaticStopped: 'deck-automatic-stopped'
  },
		
  selectors: {
	automaticLink: '.deck-automatic-link'
  },

Functions

  • $.deck('play'): This function will start automatically playing the slideshow.
  • $.deck('pause'): This function will pause the slideshow, if playing.

Events

Three events can be emitted when the autoplay status changes.

  • deck.onPlay: This event is triggered when the slideshow is played.
  • deck.onPause: This event is triggered when the slideshow is paused.
  • deck.onPlayToggle: This event is triggered when the slideshow is either played or paused, and a boolean parameter is passed in with a value of true if the slideshow is now running or false if it is now paused.

TODO

  • Allow a secondary way of defining custom slide durations using classes instead of HTML 5 data- attribute (as discussed in issue #1).

License

MIT License

Author

Romain Champourlier

deck.automatic.js's People

Contributors

nemec avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.