@justinribeiro/lite-youtube
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -35,3 +35,4 @@ /** | ||
get autoLoad(): boolean; | ||
set autoLoad(value: boolean); | ||
get noCookie(): boolean; | ||
set noCookie(value: boolean); | ||
get posterQuality(): string; | ||
@@ -38,0 +39,0 @@ set posterQuality(quality: string); |
@@ -59,8 +59,11 @@ /** | ||
} | ||
set autoLoad(value) { | ||
get noCookie() { | ||
return this.hasAttribute('nocookie'); | ||
} | ||
set noCookie(value) { | ||
if (value) { | ||
this.setAttribute('autoload', ''); | ||
this.setAttribute('nocookie', ''); | ||
} | ||
else { | ||
this.removeAttribute('autoload'); | ||
this.removeAttribute('nocookie'); | ||
} | ||
@@ -221,6 +224,7 @@ } | ||
const autoplay = isIntersectionObserver ? 0 : 1; | ||
const wantsNoCookie = this.noCookie ? '-nocookie' : ''; | ||
const iframeHTML = ` | ||
<iframe frameborder="0" | ||
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen | ||
src="https://www.youtube.com/embed/${this.videoId}?autoplay=${autoplay}&${this.params}" | ||
src="https://www.youtube${wantsNoCookie}.com/embed/${this.videoId}?autoplay=${autoplay}&${this.params}" | ||
></iframe>`; | ||
@@ -230,2 +234,9 @@ this.domRefFrame.insertAdjacentHTML('beforeend', iframeHTML); | ||
this.iframeLoaded = true; | ||
this.dispatchEvent(new CustomEvent('liteYoutubeIframeLoaded', { | ||
detail: { | ||
videoId: this.videoId, | ||
}, | ||
bubbles: true, | ||
cancelable: true, | ||
})); | ||
} | ||
@@ -232,0 +243,0 @@ } |
@@ -22,3 +22,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "lite-youtube.js", | ||
@@ -25,0 +25,0 @@ "module": "lite-youtube.js", |
@@ -1,5 +0,3 @@ | ||
[![npm version](https://badge.fury.io/js/%40justinribeiro%2Flite-youtube.svg)](https://badge.fury.io/js/%40justinribeiro%2Flite-youtube) [![min+gzip](https://badgen.net/bundlephobia/minzip/@justinribeiro/lite-youtube)](https://bundlephobia.com/result?p=@justinribeiro/lite-youtube) | ||
[![npm version](https://badge.fury.io/js/@justinribeiro%2Flite-youtube.svg)](https://badge.fury.io/js/@justinribeiro%2Flite-youtube) [![min+gzip](https://badgen.net/bundlephobia/minzip/@justinribeiro/lite-youtube)](https://bundlephobia.com/result?p=@justinribeiro/lite-youtube) [![](https://data.jsdelivr.com/v1/package/npm/@justinribeiro/lite-youtube/badge)](https://www.jsdelivr.com/package/npm/@justinribeiro/lite-youtube) | ||
[![](https://data.jsdelivr.com/v1/package/npm/@justinribeiro/lite-youtube/badge)](https://www.jsdelivr.com/package/npm/@justinribeiro/lite-youtube) | ||
# \<lite-youtube\> | ||
@@ -45,3 +43,3 @@ | ||
```html | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@justinribeiro/lite-youtube@1.0.0/lite-youtube.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@justinribeiro/lite-youtube@1.1.0/lite-youtube.js"></script> | ||
``` | ||
@@ -127,3 +125,13 @@ | ||
| `posterquality`| Set thumbnail poster quality (maxresdefault, sddefault, mqdefault, hqdefault) | `hqdefault` | | ||
| `nocookie` | Use youtube-nocookie.com as iframe embed uri | `false` | | ||
| `autoload` | Use Intersection Observer to load iframe when scrolled into view | `false` | | ||
| `params` | Set YouTube query parameters | `` | | ||
## Events | ||
The web component allows certain attributes to be give a little additional | ||
flexibility. | ||
| Event Name | Description | Returns | | ||
| -------------- | ---------------------------------------------------------------- | ------- | | ||
| `liteYoutubeIframeLoaded` | When the iframe is loaded, allowing us of JS API | `detail: { videoId: this.videoId }` | |
Sorry, the diff of this file is not supported yet
27245
410
136