mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-03 13:29:06 +00:00
folow selected
This commit is contained in:
@@ -57,7 +57,6 @@ $item-height: 3.5rem;
|
|||||||
bottom: 1.5rem;
|
bottom: 1.5rem;
|
||||||
bottom: calc(1.5rem + env(safe-area-inset-bottom));
|
bottom: calc(1.5rem + env(safe-area-inset-bottom));
|
||||||
right: $view-inline-padding;
|
right: $view-inline-padding;
|
||||||
left: 0;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: end;
|
justify-content: end;
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { IoPencil } from 'react-icons/io5';
|
import { IoPencil } from 'react-icons/io5';
|
||||||
import { EntryId, OntimeEvent, Playback } from 'ontime-types';
|
import { EntryId, OntimeEvent, Playback } from 'ontime-types';
|
||||||
|
|
||||||
import Button from '../../common/components/buttons/Button';
|
import Button from '../../common/components/buttons/Button';
|
||||||
import { useFadeOutOnInactivity } from '../../common/hooks/useFadeOutOnInactivity';
|
import { useFadeOutOnInactivity } from '../../common/hooks/useFadeOutOnInactivity';
|
||||||
|
import useFollowComponent from '../../common/hooks/useFollowComponent';
|
||||||
import { useCurrentDay, useRuntimeOffset } from '../../common/hooks/useSocket';
|
import { useCurrentDay, useRuntimeOffset } from '../../common/hooks/useSocket';
|
||||||
import { ViewExtendedTimer } from '../../common/models/TimeManager.type';
|
import { ViewExtendedTimer } from '../../common/models/TimeManager.type';
|
||||||
import { cx } from '../../common/utils/styleUtils';
|
import { cx } from '../../common/utils/styleUtils';
|
||||||
|
import FollowButton from '../../features/operator/follow-button/FollowButton';
|
||||||
import ClockTime from '../../features/viewers/common/clock-time/ClockTime';
|
import ClockTime from '../../features/viewers/common/clock-time/ClockTime';
|
||||||
import { getPropertyValue } from '../../features/viewers/common/viewUtils';
|
import { getPropertyValue } from '../../features/viewers/common/viewUtils';
|
||||||
import { useTranslation } from '../../translation/TranslationProvider';
|
import { useTranslation } from '../../translation/TranslationProvider';
|
||||||
@@ -25,10 +28,35 @@ interface CountdownSubscriptionsProps {
|
|||||||
|
|
||||||
export default function CountdownSubscriptions(props: CountdownSubscriptionsProps) {
|
export default function CountdownSubscriptions(props: CountdownSubscriptionsProps) {
|
||||||
const { time, events, selectedId, goToEditMode } = props;
|
const { time, events, selectedId, goToEditMode } = props;
|
||||||
const { secondarySource, subscriptions, showProjected } = useCountdownOptions();
|
const { followSelected, secondarySource, subscriptions, showProjected } = useCountdownOptions();
|
||||||
const showFab = useFadeOutOnInactivity(true);
|
const showFab = useFadeOutOnInactivity(true);
|
||||||
|
|
||||||
// TODO: add follow selected
|
const [lockAutoScroll, setLockAutoScroll] = useState(false);
|
||||||
|
const selectedRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const scrollRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const scrollToComponent = useFollowComponent({
|
||||||
|
followRef: selectedRef,
|
||||||
|
scrollRef,
|
||||||
|
doFollow: !lockAutoScroll,
|
||||||
|
topOffset: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
// reset scroll if nothing is selected
|
||||||
|
useEffect(() => {
|
||||||
|
if (!selectedId) {
|
||||||
|
if (!lockAutoScroll) {
|
||||||
|
scrollRef.current?.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [selectedId, lockAutoScroll, scrollRef]);
|
||||||
|
|
||||||
|
// scroll to component if user clicks the Follow button
|
||||||
|
const handleOffset = () => {
|
||||||
|
if (selectedId) {
|
||||||
|
scrollToComponent();
|
||||||
|
}
|
||||||
|
setLockAutoScroll(false);
|
||||||
|
};
|
||||||
|
|
||||||
// gather data
|
// gather data
|
||||||
const subscribedEvents = getOrderedSubscriptions(subscriptions, events);
|
const subscribedEvents = getOrderedSubscriptions(subscriptions, events);
|
||||||
@@ -64,6 +92,7 @@ export default function CountdownSubscriptions(props: CountdownSubscriptionsProp
|
|||||||
<IoPencil /> Edit
|
<IoPencil /> Edit
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<FollowButton isVisible={lockAutoScroll} onClickHandler={handleOffset} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user