Skip to content

Commit

Permalink
fix(storyTimeSlider): keep time set by the story slide (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
KatvonRivia authored Nov 3, 2020
1 parent 98ed69d commit d6b86da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit d6b86da

Please sign in to comment.