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

fix(storyTimeSlider): keep time set by the story slide #732

Merged
merged 1 commit into from
Nov 3, 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
11 changes: 8 additions & 3 deletions src/scripts/components/layers/time-slider/time-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ import styles from './time-slider.styl';

interface Props {
className?: string;
noTimeClamp?: boolean;
}

// debounce the time update
const DELAY = 200;

// eslint-disable-next-line complexity
const TimeSlider: FunctionComponent<Props> = ({className = ''}) => {
const TimeSlider: FunctionComponent<Props> = ({
className = '',
noTimeClamp
}) => {
const selectedLayerIds = useSelector(selectedLayerIdsSelector);
const {mainId, compareId} = selectedLayerIds;
const dispatch = useDispatch();
Expand Down Expand Up @@ -96,11 +100,12 @@ const TimeSlider: FunctionComponent<Props> = ({className = ''}) => {
);

// clamp globe time to min/max of the active layers when a layer changes
// dont clamp in story mode where time is set by slide
useEffect(() => {
if (clampedTime !== time) {
if (!noTimeClamp && clampedTime !== time) {
dispatch(setGlobeTime(clampedTime));
}
}, [clampedTime, time, dispatch]);
}, [noTimeClamp, clampedTime, time, dispatch]);

// stop playback when layer changes
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/components/stories/story/story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Story: FunctionComponent = () => {
backgroundColor={'#000000'}
/>
<div className={styles.layerDetails}>
<TimeSlider className={styles.storySlider} />
<TimeSlider noTimeClamp className={styles.storySlider} />
{slide.layerDescription && (
<LayerDescription layerDescription={slide.layerDescription} />
)}
Expand Down