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