• Stars
    star
    1,582
  • Rank 29,572 (Top 0.6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Your solution to full-screen background video & image combined.

Vidage

This JS module will treat video as a background. It will determine when to hide/show & pause/play the video. Touch devices and/or smaller devices with width of 34em will display image provided as fallback.

Installation (pick one)

  • npm i @dvlden/vidage
  • pnpm i @dvlden/vidage
  • yarn add @dvlden/vidage

CDN (pick one)

  1. JSDelivr
  2. UNPKG

Usage

Preferred way...

Add base structure and replace video source paths

<div class="vidage">
  <video id="vidage" class="vidage-video" preload="metadata" loop autoplay muted>
    <source src="videos/bg.webm" type="video/webm">
    <source src="videos/bg.mp4" type="video/mp4">
  </video>
</div>

Setup and import required styles

// set the fallback-cover image
$vdg-fallback-image: url('../images/fallback.jpg');

// import package
@import '~vidage/src/styles/vidage';

Import the JS module and create new instance

import Vidage from 'vidage'

new Vidage('#vidage')

Old fashioned way...

Below you will find complete html example...

<!doctype html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Document</title>

    <link rel="stylesheet" href="dist/vidage.css">
    <style>
      /* Override the cover image. Set the path to the actual image... */
      .vidage::before {
        background-image: url('images/fallback.jpg');
      }
    </style>
  </head>

  <body>
    <div class="vidage">
      <video id="vidage" class="vidage-video" preload="metadata" loop autoplay muted>
        <source src="videos/bg.webm" type="video/webm">
        <source src="videos/bg.mp4" type="video/mp4">
      </video>
    </div>

    <!-- START: Rest of your site content -->
    ...
    <!-- END: Rest of your site content -->

    <script src="dist/vidage.js"></script>
    <script>
      new Vidage('#vidage')
    </script>
  </body>
</html>

JS Arguments

Instance of Vidage accepts two arguments. First argument is the actual selector of the video, that instance will control. Second argument is the actual object for the options.

Argument Required Type
selector string/node
options object
Key Default Value Required Type
helperClass vidage-ready string
videoRemoval false bool

SCSS Variables

Variable Default Value
$vdg-fallback-image url('../images/cover.jpg')

Browser Support

Yet to be determined. All modern browsers should be alright.

More Repositories

1

ultrawideo

Upscale or stretch any video on the web, to make it look great on UltraWide screens.
JavaScript
111
star
2

webpack-config

Webpack 5 configuration for static projects...
JavaScript
98
star
3

slope

Sass mixin that helps you build sloped section edges with a consistent angle.
SCSS
91
star
4

differs-sass

WIP: Building CSS framework using Sass...
SCSS
71
star
5

macos-config

Setup for macOS that I've built for personal use case.
Shell
32
star
6

alfred-themes

Alfred Powerpack Themes that I built for personal use. Feel free to use them too, if you like it!
21
star
7

arena-of-valor-data-scraper

Scrape data from Arena of Valor's official website.
JavaScript
11
star
8

is-webview

Detect if a visitor is coming through a webview or a native browser using user-agent.
TypeScript
9
star
9

aspecter

A utility module for Node & Browser that calculates aspect ratio and decimal fraction based on width and height and alongside provides normalized aspect.
TypeScript
8
star
10

rustlings

My solutions to the small exercises for Rust. πŸ¦€
Makefile
8
star
11

asb-detect

Simple Android stock-browser detection.
TypeScript
7
star
12

ps-awake

Keep PlanetScale database awake on free tier...
TypeScript
7
star
13

await-it

A wrapper for async/await calls without the need of try/catch block.
TypeScript
7
star
14

numen

Check the length of numerical value.
TypeScript
7
star
15

webpack-lib-config

Personal Webpack configuration for library building...
JavaScript
6
star
16

web3-campaign

Second application that attempts to solve Kickstarter's main issue.
TypeScript
6
star
17

simple-portfolio-page

Simple portfolio website built with Vue.
Vue
6
star
18

tuts-rape

ScRape Tutsplus courses, so you can continue watching offline.
Python
6
star
19

web3-lottery

First application that allows people to gamble.
Vue
6
star
20

gulpfile

My workflow configuration with Gulp & Babel
JavaScript
6
star
21

rollup-lib-config

Personal Rollup configuration for library building...
JavaScript
6
star
22

gulp-tasks

Personally crafted Gulp-Tasks for simple websites...
JavaScript
5
star
23

alea

Pseudorandom number generator based on Alea algorithm.
TypeScript
5
star
24

ify

Simple link shortener that serves as API only. Built for my personal needs.
TypeScript
5
star
25

config

2
star
26

seeran

Simple pseudorandom number generator that takes a seed as string or number.
TypeScript
2
star
27

modulz

Starting point of a new module for public or private use.
TypeScript
1
star
28

mla-api

MultiloginApp - API wrapper that aims to cover everything that they offer, with type safety in mind.
TypeScript
1
star