Skip to content

Commit

Permalink
Merge branch 'main' into fix_overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Jun 10, 2024
2 parents cea744d + 1a3299e commit a6c8628
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions web/js/refresh.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,17 @@
var intervalId;

<?php
// If the table container hasn't already been scrolled, and it's scrollable,
// then scroll so that the current time is visible.
// If the table container is scrollable, then scroll so that the current time is visible.
?>
function scrollToCurrentSlot() {
var table = $('.dwm_main');
var timelineVertical = table.find('thead').data('timeline-vertical');
var container = table.parent();
var scroll, scrollTo, scrollable;
var scrollTo, scrollable;

if (timelineVertical)
{
scroll = container.scrollLeft();
scrollable = container.isHScrollable();
}
else
{
scroll = container.scrollTop();
scrollable = container.isVScrollable();
}
scrollable = (timelineVertical) ? container.isHScrollable() : container.isVScrollable();

if ((scroll === 0) && scrollable)
if (scrollable)
{
var slots = table.find('thead').data('slots');
var nowSlotIndices = Timeline.search(slots);
Expand Down Expand Up @@ -595,9 +585,14 @@ function getIndices(slots, time) {
var bottom = $('.dwm_main thead tr:first th:first').outerHeight();
$('.dwm_main thead tr:nth-child(2) th').css('top', bottom + 'px');

scrollToCurrentSlot();

}).trigger('tableload');

<?php
// Do this on page_ready, rather than tableload, so that the scrolling doesn't happen after
// every automatic refresh. That would be a problem if the user has deliberately scrolled
// somewhere else after the automatic scroll.
?>
scrollToCurrentSlot();

});

0 comments on commit a6c8628

Please sign in to comment.