Skip to content

Commit

Permalink
fix: update time for all time aware layers if value changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahennr committed Jan 23, 2025
1 parent 6519b5c commit 255d8b8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export const TimeLayerSliderPanel: React.FC<TimeLayerSliderPanelProps> = ({
const newValue = value.clone();

if (_isFinite(playbackSpeed)) {
wmsTimeHandler(newValue.clone().add(playbackSpeed, playbackSpeedUnit));
onTimeChanged(newValue.clone().add(playbackSpeed, playbackSpeedUnit));
} else {
const time = dayjs(
Expand All @@ -258,13 +257,11 @@ export const TimeLayerSliderPanel: React.FC<TimeLayerSliderPanelProps> = ({
.add(1, playbackSpeedUnit)
.format()
);
wmsTimeHandler(time);
onTimeChanged(time);
}
}, 1000);

return () => clearInterval(interval);
}, [autoPlayActive, value, endDate, playbackSpeed, wmsTimeHandler, onChange, playbackSpeedUnit, onTimeChanged]);
}, [autoPlayActive, endDate, playbackSpeed, wmsTimeHandler, onChange, playbackSpeedUnit, onTimeChanged, value]);

useEffect(() => {
setStartDate(min);
Expand All @@ -277,6 +274,11 @@ export const TimeLayerSliderPanel: React.FC<TimeLayerSliderPanelProps> = ({
}
}, [timeAwareLayers, findRangeForLayers]);

useEffect(() => {
// update time for all time aware layers if value changes
wmsTimeHandler(value);
}, [value, wmsTimeHandler]);

const futureClass = useMemo(() => {
if (Array.isArray(value)) {
return '';
Expand Down

0 comments on commit 255d8b8

Please sign in to comment.