Skip to content

Commit 6a1f8e5

Browse files
committed
docs(VideoLoader): adding documentation for Video Loader
1 parent 453c0c0 commit 6a1f8e5

File tree

1 file changed

+109
-18
lines changed

1 file changed

+109
-18
lines changed

README.md

Lines changed: 109 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,65 @@
11
# Angular Image Loader
22
[![Build Status][travis-badge]][travis-badge-url]
33
[![Coverage Status][coveralls-badge]][coveralls-badge-url]
4+
[![Commitizen friendly][commitizen-badge]][commitizen]
45

5-
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.5.4.
6+
This project was generated with [Angular CLI][angular-cli] version 1.5.4.
67

78
A simple progressive/responsive/lazy loading image library for [Angular][angular] that detects browser size and loads the appropriate image only when the element is in view. Classes are attributed and events emited on image loads. This package requires [@thisissoon/angular-inviewport][angular-inviewport].
89

910
<img src="https://raw.githubusercontent.com/thisissoon/angular-image-loader/master/src/assets/example.gif" alt="example">
1011

11-
This is a simple library for [Angular][angular], implemented in the [Angular Package Format v5.0](https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx).
12+
This is a simple library for [Angular][angular], implemented in the [Angular Package Format v5.0][apfv5].
1213

1314

1415
## Install
1516

17+
### via NPM
18+
1619
`npm i @thisissoon/{angular-image-loader,angular-inviewport} --save`
1720

21+
### via Yarn
22+
23+
`yarn add @thisissoon/angular-image-loader @thisissoon/angular-inviewport `
24+
1825
`app.module.ts`
1926
```ts
20-
import { ImageLoaderModule } from '@thisissoon/angular-image-loader';
27+
import { ImageLoaderModule, VideoLoaderModule } from '@thisissoon/angular-image-loader';
2128
import { InViewportModule, WindowRef } from '@thisissoon/angular-inviewport';
2229

23-
// Provide window object for browser and a suitable replacement
24-
// on other platforms
25-
export const getWindow = () => window;
30+
// Provide window object for platform browser
2631
export const providers: Provider[] = [
27-
{ provide: WindowRef, useFactory: (getWindow) }
32+
{ provide: WindowRef, useFactory: () => window }
2833
];
2934

3035
@NgModule({
3136
imports: [
3237
InViewportModule.forRoot(providers),
33-
ImageLoaderModule
38+
ImageLoaderModule, // Only this import required if using just the image loader
39+
VideoLoaderModule // Only this import required if using just the video loader
40+
]
41+
})
42+
export class AppModule { }
43+
```
44+
45+
`app.server.module.ts` (Only needed if using Angular Universal)
46+
```ts
47+
import { ImageLoaderModule } from '@thisissoon/angular-image-loader';
48+
import { InViewportModule, WindowRef } from '@thisissoon/angular-inviewport';
49+
50+
@NgModule({
51+
imports: [
52+
// No need to provide WindowRef
53+
InViewportModule.forRoot(),
54+
ImageLoaderModule,
55+
VideoLoaderModule
3456
]
3557
})
3658
export class AppModule { }
3759
```
3860

3961

40-
## Example
62+
## Image Loader Example
4163

4264
A working example can be found inside [/src](https://github.com/thisissoon/angular-image-loader/tree/master/src) folder.
4365

@@ -47,7 +69,7 @@ A working example can be found inside [/src](https://github.com/thisissoon/angul
4769
<sn-image-loader
4870
[image]="image"
4971
[sizes]="sizes"
50-
imgClass="foo"
72+
imgClass="img"
5173
alt="lorem ipsum"
5274
(placeholderLoaded)="onPlaceholderLoad($event)"
5375
(imageLoaded)="onImageLoad($event)">
@@ -59,9 +81,9 @@ A working example can be found inside [/src](https://github.com/thisissoon/angul
5981
```ts
6082
export class AppComponent {
6183
sizes: Breakpoint[] = [
62-
{ size: 'xs', width: 0},
63-
{ size: 'md', width: 768},
64-
{ size: 'lg', width: 992},
84+
{ size: 'xs', width: 0 },
85+
{ size: 'md', width: 768 },
86+
{ size: 'lg', width: 992 },
6587
];
6688

6789
image: ResponsiveImage = {
@@ -103,15 +125,66 @@ export class AppComponent {
103125
transition: all .35s ease-in-out;
104126
}
105127

106-
.sn-image-not-loaded /deep/ .foo {
128+
.sn-image-not-loaded ::ng-deep .img {
107129
filter: blur(20px);
108130
}
109131

110-
.sn-image-loaded /deep/ .foo {
132+
.sn-image-loaded ::ng-deep .img {
111133
filter: blur(0px);
112134
}
113135
```
114136

137+
## Video Loader Example
138+
139+
### `app.component.html`
140+
141+
```html
142+
<sn-video-loader
143+
[sizes]="sizes"
144+
[video]="video"
145+
[loop]="true"
146+
[muted]="true"
147+
[autoplay]="true"
148+
[controls]="true"
149+
[playsInline]="true"
150+
type="video/mp4"
151+
videoClass="video"
152+
posterClass="img">
153+
</sn-video-loader>
154+
```
155+
156+
### `app.component.ts`
157+
158+
```ts
159+
export class AppComponent {
160+
sizes: Breakpoint[] = [
161+
{ size: 'xs', width: 0 },
162+
{ size: 'md', width: 768 },
163+
{ size: 'lg', width: 992 },
164+
];
165+
166+
video: ResponsiveVideo = {
167+
videos: [
168+
{
169+
size: 'xs',
170+
url: 'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_568,q_80,w_320/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4'
171+
},
172+
{
173+
size: 'md',
174+
url: 'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_1024,q_80,w_768/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4'
175+
},
176+
{
177+
size: 'lg',
178+
url: 'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_720,q_80,w_1280/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4'
179+
}
180+
],
181+
poster: {
182+
// Responsive image, the same object as used for the image loader
183+
}
184+
};
185+
}
186+
```
187+
115188

116189
## Development server
117190

@@ -127,15 +200,24 @@ Run `ng build` to build the project. The build artifacts will be stored in the `
127200

128201
## Running unit tests
129202

130-
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
203+
Run `ng test` to execute the unit tests via [Karma][karma].
131204

132205
## Running end-to-end tests
133206

134-
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
207+
Run `ng e2e` to execute the end-to-end tests via [Protractor][protractor].
208+
209+
## Making Commits
210+
211+
This repo uses [Commitizen CLI][commitizen] and [Conventional Changelog][conventional-changelog] to create commits and generate changelogs. Instead of running `git commit` run `git cz` and follow the prompts. Changelogs will then be generated when creating new releases by running `npm run release`.
212+
213+
## Making Releases
214+
215+
Run `npm run release` to create a new release. This will use [Standard Version][standard-version] to create a new release. [Standard Version][standard-version] will generate / update the changelog based on commits generated using [Commitizen CLI][commitizen], update the version number following semantic versioning rules and then commit and tag the commit for the release. Simply run `git push --follow-tags origin master`.
216+
135217

136218
## Further help
137219

138-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
220+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README][angular-cli-readme].
139221

140222

141223
[travis-badge]: https://travis-ci.org/thisissoon/angular-image-loader.svg?branch=master
@@ -144,3 +226,12 @@ To get more help on the Angular CLI use `ng help` or go check out the [Angular C
144226
[coveralls-badge-url]: https://coveralls.io/github/thisissoon/angular-image-loader?branch=master
145227
[angular]: https://angular.io/
146228
[angular-inviewport]: https://github.com/thisissoon/angular-inviewport
229+
[commitizen]:http://commitizen.github.io/cz-cli/
230+
[commitizen-badge]:https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
231+
[conventional-changelog]:https://github.com/conventional-changelog/conventional-changelog
232+
[standard-version]:https://github.com/conventional-changelog/standard-version
233+
[karma]:https://karma-runner.github.io
234+
[protractor]:http://www.protractortest.org/
235+
[angular-cli]:https://github.com/angular/angular-cli
236+
[angular-cli-readme]:https://github.com/angular/angular-cli/blob/master/README.md
237+
[apfv5]:(https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx)

0 commit comments

Comments
 (0)