Skip to content

Commit

Permalink
Merge pull request #414 from UX-Alkosto/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
miguelcolmenares committed Feb 22, 2023
2 parents 1e47959 + 328419e commit 88d610d
Show file tree
Hide file tree
Showing 23 changed files with 937 additions and 6,018 deletions.
10 changes: 10 additions & 0 deletions components/banner-video/css/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { css } from 'lit';

const styles = css`
.full .lazy-iframe,
.left .lazy-iframe,
.left-cut .lazy-iframe,
.right .lazy-iframe,
.right-cut .lazy-iframe {
max-width: 100%;
object-fit: cover;
width: 100%;
}
.full iframe,
.left iframe,
.left-cut iframe,
Expand Down
32 changes: 29 additions & 3 deletions components/banner-video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,34 @@ export class BannerVideo extends Banner {
}
_getIframe({height, src, type}) {
if (!src.length) return;
return html`<section class="${type}">
<iframe allowfullscreen frameborder="0" height="${height}" src="${src}" loading="lazy"> </iframe>
</section>`;
return html`<section class="${type}">${this.lazyIframe({height, src})}</section>`;
}
lazyIframe({height, src}) {
// check if the browser supports IntersectionObserver
if ('IntersectionObserver' in window) {
// create a new IntersectionObserver
const observer = new IntersectionObserver(entries => {
// loop through the entries
entries.forEach(({ isIntersecting, target }) => {
// if the element is visible
if (isIntersecting) {
// add the iframe
const iframe = document.createElement('iframe');
iframe.allowFullscreen = true;
iframe.height = height;
iframe.src = src;
iframe.loading = 'lazy';
iframe.frameBorder = '0';
this.shadowRoot.querySelector('.lazy-iframe').appendChild(iframe);
// stop watching this element
observer.unobserve(target);
}
});
});
// start watching the element
observer.observe(this);
// return a placeholder
return html`<div class="lazy-iframe"></div>`;
}
}
}
4 changes: 2 additions & 2 deletions dist/components.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/*! webcomponents release: 2.0.7 */
import"./webcomponents-2.0.7-2def456f.js";
/*! webcomponents release: 2.1.0 */
import"./webcomponents-2.1.0-c115f97e.js";
2 changes: 0 additions & 2 deletions dist/webcomponents-2.0.7-2def456f.js

This file was deleted.

2 changes: 0 additions & 2 deletions dist/webcomponents-2.0.7-3674756e.js

This file was deleted.

2 changes: 0 additions & 2 deletions dist/webcomponents-2.0.7-a295759c.js

This file was deleted.

2 changes: 0 additions & 2 deletions dist/webcomponents-2.0.7-ce7908e1.js

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/webcomponents-2.1.0-1f42011b.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88d610d

Please sign in to comment.