feat: support video banner
This commit is contained in:
parent
29f69dcc2a
commit
11edca1890
4 changed files with 70 additions and 4 deletions
|
@ -42,3 +42,27 @@
|
||||||
{%- include functions.html func='get_value' -%}
|
{%- include functions.html func='get_value' -%}
|
||||||
{% assign banner_subheading_style = return %}
|
{% assign banner_subheading_style = return %}
|
||||||
|
|
||||||
|
{%- include functions.html func='log' level='debug' msg='Get banner_video value' -%}
|
||||||
|
{% assign name = 'banner.video' %}
|
||||||
|
{%- include functions.html func='get_value' -%}
|
||||||
|
{% assign banner_video = return %}
|
||||||
|
|
||||||
|
{%- include functions.html func='log' level='debug' msg='Get banner_loop value' -%}
|
||||||
|
{% assign name = 'banner.loop' %}
|
||||||
|
{%- include functions.html func='get_value' default=true -%}
|
||||||
|
{% assign banner_loop = return %}
|
||||||
|
|
||||||
|
{%- include functions.html func='log' level='debug' msg='Get banner_volume value' -%}
|
||||||
|
{% assign name = 'banner.volume' %}
|
||||||
|
{%- include functions.html func='get_value' default=0 -%}
|
||||||
|
{% assign banner_volume = return %}
|
||||||
|
|
||||||
|
{%- include functions.html func='log' level='debug' msg='Get banner_start_at value' -%}
|
||||||
|
{% assign name = 'banner.start_at' %}
|
||||||
|
{%- include functions.html func='get_value' default=0 -%}
|
||||||
|
{% assign banner_start_at = return %}
|
||||||
|
|
||||||
|
{% if banner_image or banner_video %}
|
||||||
|
{% assign has_banner = true %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{%- include functions.html func='get_banner' -%}
|
{%- include functions.html func='get_banner' -%}
|
||||||
|
|
||||||
{%- if banner_image -%}
|
{%- if has_banner -%}
|
||||||
{%- if banner_background -%}
|
{%- if banner_background -%}
|
||||||
<style>
|
<style>
|
||||||
html .page-banner {
|
html .page-banner {
|
||||||
|
@ -65,8 +65,45 @@
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<section class="page-banner">
|
<section class="page-banner">
|
||||||
<div class="page-banner-img">
|
<div class="page-banner-img">
|
||||||
<div style="background-image: url({{ banner_image }})"></div>
|
{%- if banner_video -%}
|
||||||
<img class="img-placeholder" src="{{ banner_image }}"></div>
|
<video
|
||||||
|
autoplay=""
|
||||||
|
poster="{{ banner_image }}"
|
||||||
|
>
|
||||||
|
<source src="{{ banner_video }}">
|
||||||
|
</video>
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var video = document.querySelector('.page-banner .page-banner-img > video');
|
||||||
|
var videoPlay = function() {
|
||||||
|
try {
|
||||||
|
video.play();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
window.removeEventListener('focus', videoPlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('focus', videoPlay);
|
||||||
|
|
||||||
|
video.onloadstart = function() {
|
||||||
|
video.volume = {{ banner_volume }};
|
||||||
|
video.currentTime = {{ banner_start_at }};
|
||||||
|
}
|
||||||
|
|
||||||
|
video.onended = function() {
|
||||||
|
video.currentTime = {{ banner_start_at }};
|
||||||
|
video.volume = 0;
|
||||||
|
{%- if banner_loop -%}
|
||||||
|
video.play();
|
||||||
|
{%- endif -%}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{%- else -%}
|
||||||
|
<div style="background-image: url({{ banner_image }})"></div>
|
||||||
|
<img class="img-placeholder" src="{{ banner_image }}">
|
||||||
|
{%- endif -%}
|
||||||
</div>
|
</div>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="page-banner-inner">
|
<div class="page-banner-inner">
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{%- include functions.html func='get_value' default=true -%}
|
{%- include functions.html func='get_value' default=true -%}
|
||||||
{%- assign header_transparent = return -%}
|
{%- assign header_transparent = return -%}
|
||||||
|
|
||||||
{%- if banner_image and header_transparent -%}
|
{%- if has_banner and header_transparent -%}
|
||||||
{%- assign header_transparent_class = "site-header-transparent" -%}
|
{%- assign header_transparent_class = "site-header-transparent" -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
|
|
|
@ -575,6 +575,11 @@ html {
|
||||||
transition: 0.1s all ease-in-out;
|
transition: 0.1s all ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& > video {
|
||||||
|
width: 100vw;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
& > img.img-placeholder {
|
& > img.img-placeholder {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue