Giter Site home page Giter Site logo

sunnyday90210 / backgroundvideo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cyberjo50/backgroundvideo

0.0 1.0 0.0 34.41 MB

A lightweight parallax background video solution that behaves like the CSS3 property, background-size: cover

License: MIT License

CSS 4.51% JavaScript 95.49%

backgroundvideo's Introduction

backgroundVideo - v2.0.2

About

What is backgroundVideo?

backgroundVideo is a vanilla Javascript parallax (optional) plugin that turns your HTML5 <video> element into the CSS property background-size: cover, scaling to aspect ratio.

Working Examples

Within the examples folder, you will see demonstrations on how to implement the plugin.

Please note: parallax video is most effective on fixed position videos

Browser Support

HTML5 video supported browsers on desktop:

  • IE9+ / Edge
  • Chrome
  • Firefox
  • Safari
  • Opera

Please note this plugin will not work on mobile devices. This is due to restrictions on autoplay and performance. A responsive image is suggested as fallback.

How to use

For the most basic implementation, add the following to your html document:

<video class="bv-video"></video>

Ensuring that you are referencing the backgroundVideo.js file in your project, you can then instantiate the plugin by using the following Javascript:

const backgroundVideo = new BackgroundVideo('.bv-video', {
  src: [
    'MY/EXAMPLE/PATH/SAMPLE.mp4',
    'MY/EXAMPLE/PATH/SAMPLE.webm'
  ]
});

The src array is the only mandatory option.

You can also install and use via npm:

npm install background-video

Please see the examples for how to use the callback options and multiple videos on one page (Note: The examples are written in ES6/ES2015 so these will not work in older browsers e.g. Internet Explorer).

Options

Option Type Default Description
parallax.effect number 1.5 The intensity of the parallax effect (1: fixed). Number must be >= 1.
preventContextMenu boolean false Prevents the user from viewing the context menu on the video (prevent right-click/secondary-click)
onBeforeReady() callback null Run code before the video is ready
onReady() callback null Run code when the plugin has loaded - e.g. prevent loading flickers (see examples folder for useage)

Dependencies

None :)

License

Copyright (c) 2016 Sam Linnett

Licensed under the MIT license.

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.