Code Monkey home page Code Monkey logo

gifplayer's Introduction

gifplayer

Bower version

Customizable jquery plugin to play and stop animated gifs. Similar to 9gag's. New: Video support (webm, mp4)

###Basic Usage

  1. Add a preview of the gif or video file to your website
  2. Specify a ‘data-src’ attribute with the path to the animated gif or video, or simply have an image with the same name and the .gif extension in the same folder of the ‘preview’ image
  3. Include jquery.js, jquery.gifplayer.js and gifplayer.css on your site
  4. Call the .gifplayer() method for the desired images
<img class="gifplayer" src="media/banana.png" />
 
<script>
	$('.gifplayer').gifplayer();
</script>

###Options

Options can be setup in two ways:

  1. Setup as an object when initializing the plugin:
$('.banana').gifplayer({ label: 'play' });
  1. Setup as data attributes in the preview image:
<img class="banana" src="banana.png" data-label="play">
Option Values Default Allowed values
label A value for the label in the circle over the image ‘gif’
playOn Event that triggers playing the animated gif 'click' 'click', 'hover'
mode Load an animated gif file or a video 'gif' 'gif', 'video'
gif Source for the gif file Default option is the same name of the preview imagem replacing extension to .gif
mp4 Source for the mp4 video file (video mode) Default option is the same name of the preview imagem replacing extension to .mp4
webm Source for the webm video file (video mode) Default option is the same name of the preview imagem replacing extension to .webm
wait Would you wait until the animation file has been fully loaded to play, or start playing right away false true, false

###Methods (beta)

Use these methods to play and stop the player programatically

$('#banana').gifplayer('play');
$('#banana').gifplayer('stop');

###Events (beta)

Use events to do awesome things

$('#banana').gifplayer({
    onPlay: function(){
        console.log('GIF started',this);
    },
    onStop: function(){
        console.log('GIF stopped',this);
    },
});

gifplayer's People

Contributors

fmedinac avatar rubentd avatar vmari avatar

Watchers

 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.