Skip to content

Fluid width (responsive) videos module, 1KB, custom players, dynamic elements/XHR support.

License

Notifications You must be signed in to change notification settings

CaleyWalsh/fluidvids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fluidvids.js Build Status

Fluidvids is 1KB standalone module that provides a fluid solution for video embeds. By default Fluidvids supports YouTube and Vimeo, but you can easily add your own players. Fluidvids also provides support for dynamically injected (XHR/Ajax/createElement) videos.

Demo

Check out a demo of FluidVids.

Methods

init()

Pass in your configuration.

fluidvids.init({
  selector: 'iframe', // runs querySelectorAll()
  players: ['www.youtube.com', 'player.vimeo.com'] // players to support
});

Fluidvids internally constructs a strict Regular Expression which obides by your players Array, so ensure any new videos you add are added to players: []. This helps avoid any unwanted videos being parsed and provides flexibility for scaling easily.

apply()

Provides dynamic video support. Using apply() should only be done when you want to requery the DOM and look for newly added videos, such as document.createElement('iframe');. Fluidvids uses internal object caching to lookup init() configuration, so it's lightning fast.

// run after dynamic elements have been injected
// you'll need to run this each time you need it
fluidvids.apply();

Installing with Bower

Use the repository hook:

bower install https://github.com/toddmotto/fluidvids.git

Manual installation

Ensure you're using the files from the dist directory (contains compiled production-ready code). Ensure you place the script before the closing </body> tag.

<body>
  <!-- html above -->
  <script src="dist/fluidvids.js"></script>
  <script>
  // fluidvids module available
  </script>
</body>

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release history

  • 1.1.0
    • Add toJSON and fromJSON for stringify/parse methods
  • 1.0.0
    • Initial release

About

Fluid width (responsive) videos module, 1KB, custom players, dynamic elements/XHR support.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%