UNPKG

2.79 kBMarkdownView Raw
1# Vidage
2
3This JS module will treat video as a background. It will determine when to hide/show & pause/play the video.
4Touch devices and/or smaller devices with width of **34em** will display image provided as fallback.
5
6
7## Installation (pick one)
8
91. [Download latest release](https://github.com/dvlden/vidage/releases)
102. `git clone https://github.com/dvlden/vidage.git`
113. `yarn add vidage`
124. `npm i vidage`
135. [Use CDN](https://cdnjs.com/libraries/vidage)
14
15
16## Usage
17
18Preferred way...
19
20> Add base structure and replace video source paths
21
22```html
23<div class="vidage">
24 <video id="vidage" class="vidage-video" preload="metadata" loop autoplay muted>
25 <source src="videos/bg.webm" type="video/webm">
26 <source src="videos/bg.mp4" type="video/mp4">
27 </video>
28</div>
29```
30
31> Setup and import required styles
32
33```scss
34// set the fallback-cover image
35$vdg-fallback-image: url('../images/fallback.jpg');
36
37// import package
38@import '~vidage/src/styles/vidage';
39```
40
41> Import the JS module and create new instance
42
43```js
44import Vidage from 'vidage'
45
46new Vidage('#vidage')
47```
48
49---
50
51Old fashioned way...
52
53> Below you will find complete `html` example...
54
55```html
56<!doctype html>
57 <html lang="en">
58 <head>
59 <meta charset="utf-8">
60 <title>Document</title>
61
62 <link rel="stylesheet" href="dist/vidage.css">
63 <style>
64 /* Override the cover image. Set the path to the actual image... */
65 .vidage::before {
66 background-image: url('images/fallback.jpg');
67 }
68 </style>
69 </head>
70
71 <body>
72 <div class="vidage">
73 <video id="vidage" class="vidage-video" preload="metadata" loop autoplay muted>
74 <source src="videos/bg.webm" type="video/webm">
75 <source src="videos/bg.mp4" type="video/mp4">
76 </video>
77 </div>
78
79 <!-- START: Rest of your site content -->
80 ...
81 <!-- END: Rest of your site content -->
82
83 <script src="dist/vidage.js"></script>
84 <script>
85 new Vidage('#vidage')
86 </script>
87 </body>
88</html>
89```
90
91## JS Arguments
92
93Instance of Vidage accepts two arguments. First argument is
94the actual selector of the video, that instance will control.
95Second argument is the actual object for the options.
96
97| Argument | Required Type |
98| ---------- | ------------- |
99| `selector` | `string/node` |
100| `options` | `object` |
101
102| Key | Default Value | Required Type |
103| -------------- | -------------- | ------------- |
104| `helperClass` | `vidage-ready` | `string` |
105| `videoRemoval` | `false` | `bool` |
106
107
108## SCSS Variables
109
110| Variable | Default Value |
111| --------------------- | ---------------------------- |
112| `$vdg-fallback-image` | `url('../images/cover.jpg')` |
113
114
115## Browser Support
116
117Yet to be determined. All modern browsers should be alright.