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 | 5. [Use CDN](https://cdnjs.com/libraries/vidage)
|
14 |
|
15 |
|
16 | ## Usage
|
17 |
|
18 | Preferred 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
|
44 | import Vidage from 'vidage'
|
45 |
|
46 | new Vidage('#vidage')
|
47 | ```
|
48 |
|
49 | ---
|
50 |
|
51 | Old 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 |
|
93 | Instance of Vidage accepts two arguments. First argument is
|
94 | the actual selector of the video, that instance will control.
|
95 | Second 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 |
|
117 | Yet to be determined. All modern browsers should be alright.
|