Skip to content

Commit

Permalink
Merge pull request #480 from biati-digital/v4-beta-video-alternative
Browse files Browse the repository at this point in the history
feat: V4 beta video alternative
  • Loading branch information
biati-digital authored Sep 7, 2024
2 parents d5849d1 + 7ae45bf commit 60c7fdf
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 83 deletions.
3 changes: 2 additions & 1 deletion packages/glightbox/src/glightbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ export default class GLightbox {
this.trigger('slide_before_change', { current: this.state.get('prevActiveSlideIndex'), next: index });
}

await this.preloadSlide(index, !first);
const effect = this.options.appearance?.slideEffect;
const openEffect = this.options.appearance?.openEffect;
const scrollAnim = effect !== 'slide' || first ? 'instant' : 'smooth';

slideNode.scrollIntoView({ behavior: scrollAnim, block: 'start', inline: 'start' });

await this.preloadSlide(index, !first);

removeClass(media, 'gl-animation-ended');

if (first && openEffect) {
Expand Down
21 changes: 21 additions & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@ export function windowSize() {
};
}


export function createIframe(config) {
const { url, attrs, appendTo } = config;
const iframe = document.createElement('iframe');
iframe.className = 'gl-iframe';
iframe.src = url;
iframe.style.width = '100%';
iframe.style.height = '100%';

if (attrs) {
for (const [key, value] of Object.entries(attrs)) {
iframe.setAttribute(key, value as string);
}
}
if (appendTo) {
appendTo.appendChild(iframe);
}
return iframe
}


/**
* Inject videos api
* used for video player
Expand Down
3 changes: 2 additions & 1 deletion packages/video/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"glightbox"
],
"dependencies": {
"@glightbox/plugin-core": "1.0.0-beta.3"
"@glightbox/plugin-core": "1.0.0-beta.3",
"@glightbox/utils": "1.0.0-beta.1"
},
"license": "GPLV3"
}
Loading

0 comments on commit 60c7fdf

Please sign in to comment.