Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MozFest homepage video contrls fixes & align banner text #4315

Merged
merged 5 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="background-wrapper">
<div class="overlay"></div>
{% if banner_video_type == "hardcoded" %}
<video class="banner-video" playsinline autoplay muted loop preload poster="" >
<video class="banner-video" playsinline muted loop preload poster="" >
<source
src="https://s3.amazonaws.com/mofo-assets/foundation/video/mozfest-banner-video.mp4"
type="video/mp4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{% block page_title %}{{page.title}}{% endblock%}

{% block mozfest_body_id %}home{% endblock %}
{% block bodyclass %}mozfest {% if banner_video_type %}banner-type-{{banner_video_type}}{% endif %}{% endblock %}

{% block hero_guts %}
{% include "partials/primary_heroguts.html" with root=root page=page homepage=True banner_video_type=banner_video_type %}
Expand Down
38 changes: 17 additions & 21 deletions source/js/mozfest-event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,35 @@ const bindHomeBannerHandlers = () => {
let playButton = homepageBanner.querySelector(".btn-video-control.btn-play");

if (video && pauseButton && playButton) {
let showVideoControls = () => {
const classToToggle = `d-none`;
let autoplayStarted =
video.played.length == 0 && video.readyState >= video.HAVE_FUTURE_DATA;

if (video.readyState < video.HAVE_FUTURE_DATA) {
// don't show any video controls as the video isn't ready to play
playButton.classList.add(classToToggle);
pauseButton.classList.add(classToToggle);
} else if (!video.paused || autoplayStarted) {
playButton.classList.add(classToToggle);
pauseButton.classList.remove(classToToggle);
} else {
pauseButton.classList.add(classToToggle);
playButton.classList.remove(classToToggle);
}
const HIDE = `d-none`;

const showPauseButton = () => {
playButton.classList.add(HIDE);
pauseButton.classList.remove(HIDE);
};

const showPlayButton = () => {
pauseButton.classList.add(HIDE);
playButton.classList.remove(HIDE);
};

pauseButton.addEventListener(`click`, () => {
video.pause();
showVideoControls();
});

playButton.addEventListener(`click`, () => {
video.play();
showVideoControls();
});

showVideoControls();
video.addEventListener(`pause`, () => {
showPlayButton();
});

video.addEventListener(`canplay`, () => {
showVideoControls();
video.addEventListener(`playing`, () => {
showPauseButton();
});

video.play();
}
};

Expand Down
6 changes: 5 additions & 1 deletion source/sass/mozfest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ body.mozfest {
}
}

.homepage-banner-content {
.homepage-banner-content.container {
z-index: $banner-background-z-index + 3;

@media screen and (max-width: $bp-sm) {
width: 100%;
}

@media screen and (min-width: $bp-md) {
padding-bottom: $cutoff-offset;
}
Expand Down