Skip to content

Commit b30a766

Browse files
Merge pull request #27 from tomik23:local
feat: Provide local as a global variable
2 parents a3c6cb5 + 075d34e commit b30a766

25 files changed

+273
-277
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
Lazy loading youtube
33
</h1>
44

5-
<p align="center">
6-
Lazy loading youtube on lightbox
7-
</p>
8-
95
<p align="center">
106
<img src="https://img.shields.io/github/package-json/v/tomik23/lazy-youtube">
117
<img src="https://img.shields.io/github/size/tomik23/lazy-youtube/dist/js/youtubeLazy.min.js">
@@ -14,6 +10,10 @@
1410
</a>
1511
</p>
1612

13+
<p align="center">
14+
The script prevents all files from being downloaded from yotube while the page is loading. Only by clicking on the appropriate movie, you recharge the necessary codes to display the movie. It's also possible to put a movie on a layer and a few other options to control the appearance - all info below.
15+
</p>
16+
1717
<p align="center">
1818
<img src="static/01.png">
1919
</p>
@@ -39,17 +39,17 @@ See the demo - [example](https://tomik23.github.io/lazy-youtube/)
3939
#### You can download from CDN as well
4040
```html
4141
<!-- CSS -->
42-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tomik23/[email protected].3/dist/css/youtubeLazy.min.css"/>
42+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tomik23/[email protected].4/dist/css/youtubeLazy.min.css"/>
4343

4444
<!-- JS -->
45-
<script src="https://cdn.jsdelivr.net/gh/tomik23/[email protected].3/dist/js/youtubeLazy.min.js"></script>
45+
<script src="https://cdn.jsdelivr.net/gh/tomik23/[email protected].4/dist/js/youtubeLazy.min.js"></script>
4646
```
4747

4848

4949
### Add a div with the appropriate json
5050

5151
- **"id": "TUIbj4mviXU"** - id is the id of the movie you can find it in every youtube link
52-
- **"local": true** - parameter that tells the library that the movie should play in the same div as the thumbnail, not in the lightbox
52+
- **"local": true** - parameter that tells the library that the movie should play in the same div as the thumbnail, not in the lightbox, default: true for all videos
5353
- **"maxWidth": 50** - the video opens to the given width, it is a percentage, in this example 50%, if there is no number then the video opens to the whole window - 100%. You can also set a global `maxWidth` for all videos that open in the lightbox. Just add the same `maxWidth: 80` parameter to option, see the example below
5454
- **"openIn"** - this parameter allows you to display a button which, when clicked, directly opens the youtube page with the movie. For full functionality you need the corresponding parameter also added to js, see below `createWatchIn: () => {}`
5555
- **"title"** - the title of the video, it is displayed top of container`
@@ -59,8 +59,8 @@ See the demo - [example](https://tomik23.github.io/lazy-youtube/)
5959
<!-- default -->
6060
<div class="ytLazy__item" data-yt='{ "id": "TUIbj4mviXU" }'></div>
6161

62-
<!-- open in same place what thumbnail is -->
63-
<div class="ytLazy__item" data-yt='{ "id": "XHeDps0fX6c", "local": true }'></div>
62+
<!-- open the movie in lightbox layer -->
63+
<div class="ytLazy__item" data-yt='{ "id": "XHeDps0fX6c", "local": false }'></div>
6464

6565
<!-- set max-width -->
6666
<div class="ytLazy__item" data-yt='{ "id": "XHeDps0fX6c", "maxWidth": 50 }'></div>
@@ -101,12 +101,19 @@ See the demo - [example](https://tomik23.github.io/lazy-youtube/)
101101
// hide overflow to body when open lightbox
102102
// default false
103103
overflow: true,
104+
105+
// open the movie in a local place
106+
// default local: true
107+
local: false,
104108
105109
// genereate picture > source
106110
picture: true,
107111
108112
// create your own button to open youtube video page
109-
createWatchIn: ({ link, template }) => {
113+
createWatchIn: ({ index, link, template }) => {
114+
// based on the index, you can insert
115+
// a different template with the button's
116+
// appearance or color change
110117
template(`
111118
<div class="ytLazy__watch-in">
112119
<a href='${link}' class="ytLazy__watch-in-link" target="_blank">
@@ -149,8 +156,8 @@ If you need IE support, add this pollyfil to html
149156

150157
### cdn
151158

152-
- https://cdn.jsdelivr.net/gh/tomik23/[email protected].3/dist/js/youtubeLazy.ie.min.js
153-
- https://cdn.jsdelivr.net/gh/tomik23/[email protected].3/dist/css/youtubeLazy.ie.min.css
159+
- https://cdn.jsdelivr.net/gh/tomik23/[email protected].4/dist/js/youtubeLazy.ie.min.js
160+
- https://cdn.jsdelivr.net/gh/tomik23/[email protected].4/dist/css/youtubeLazy.ie.min.css
154161

155162
## License
156163

dist/css/youtubeLazy.ie.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)