Giter VIP home page Giter VIP logo

gfycat.js's Introduction

gfycat.js

Embed script to generate gfycat embeds on 3rd party websites.

The intent of this javascript is to provide a simple self cotained file that web publishers can use to easily include gfycat embeds on their websites.

By hosting it on github, users can request changes, contribute code, or fork a branch so that the embed process is adapted to actual real world needs.

Usage:

Include the .js on your website

Example(current file):

<script type"text/javascript" src="http://test.gfycat.com/gfycat_test_june25.js"></script>

Include an embed tag

Example:

<div class="gfyitem" data-title=true data-autoplay=false data-controls=true data-expand=false data-id="BestYellowishElephantseal" ></div> 

The key which the embed script looks for is class="gfyitem". The options are:

  • data-id: the gfycat id (required)
  • data-controls: whether or not to include controls for pause/speed/etc (default: false)
  • data-title: whether or not to include the title on hover over (default: false)
  • data-autoplay: whether or not to automatically start playback when the page loads (default: true)
  • data-expand: whether or not the video element should expand to fill the space of its container (default: false)

The files in this repository are broken down into two objects:

  • gfyCollection: this object is called on page load -- gfyCollection.init(). Its function is to find every gfycat embed on the page and create a gfyObject for it.
  • gfyObject: a new one of these is created for each gfycat embed. It contains all of the functions to generate the DOM and manipulate the video.

gfyCollection.init should be called on page load:

if(document.addEventListener)
    document.addEventListener("DOMContentLoaded",gfyCollection.init,false);
else
    document.attachEvent("onreadystatechange",gfyCollection.init);

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.