Skip to content
Merged
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
34 changes: 24 additions & 10 deletions www/video/compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,6 @@
}
#videoContainer
{
<?php
if ( $stickyFilmstrip ) {
?>
position: sticky;
top: 0;
z-index: 9999;

<?php
}
?>
<?php
echo "background: #$bgcolor;\n";
echo "color: #$color;\n"
Expand All @@ -150,6 +140,14 @@
margin-right: auto;
width: 100%;
}
<?php if ( $stickyFilmstrip ) { ?>
body:not(.viewport-too-short-for-sticky-filmstrip) #videoContainer {
position: sticky;
top: 0;
z-index: 9999;
}
<?php } ?>

#videoContainer td
{
margin: 2px;
Expand Down Expand Up @@ -454,6 +452,22 @@ function UpdateScrollPosition() {
<?php
include "waterfall.js";
?>

const VIEWPORT_TO_FILMSTRIP_THRESHOLD = 100 / 60
function UpdateFilmstripStickyness(viewportTooShort) {
document.body.classList.toggle('viewport-too-short-for-sticky-filmstrip', viewportTooShort)
}
function WatchViewportToFilmstripThreshold(callback) {
const filmstrip = document.getElementById('videoContainer')
const viewportHeightThreshold = filmstrip.offsetHeight * VIEWPORT_TO_FILMSTRIP_THRESHOLD

const shortViewport = window.matchMedia(`(max-height: ${viewportHeightThreshold}px)`)
shortViewport.addEventListener('change', shortViewport =>
callback(shortViewport.matches)
)
callback(shortViewport.matches)
}
WatchViewportToFilmstripThreshold(UpdateFilmstripStickyness)
</script>
</body>
</html>
Expand Down