diff --git a/src/actions/vis-state-actions.d.ts b/src/actions/vis-state-actions.d.ts index cc5593eebb..fa8f003623 100644 --- a/src/actions/vis-state-actions.d.ts +++ b/src/actions/vis-state-actions.d.ts @@ -292,12 +292,13 @@ export function updateLayerAnimationSpeed( speed: number ): Merge; -export type ToggleLayerAnimationUpdaterAction = { - idx; -}; -export function toggleLayerAnimation( - idx: number -): Merge; +export type ToggleLayerAnimationUpdaterAction = {}; +export function toggleLayerAnimation(): + Merge; + +export type ToggleLayerAnimationControlUpdaterAction = {}; +export function toggleLayerAnimationControl(): + Merge; export type EnlargeFilterUpdaterAction = { idx: number; diff --git a/src/actions/vis-state-actions.js b/src/actions/vis-state-actions.js index 01cef993de..a0ff67681d 100644 --- a/src/actions/vis-state-actions.js +++ b/src/actions/vis-state-actions.js @@ -499,12 +499,32 @@ export function updateLayerAnimationSpeed(speed) { }; } +/** + * start end end layer animation + * @memberof visStateActions + * @type {typeof import('./vis-state-actions').toggleLayerAnimation} + * @returns action + * @public + */ export function toggleLayerAnimation() { return { type: ActionTypes.TOGGLE_LAYER_ANIMATION }; } +/** + * hide and show layer animation control + * @memberof visStateActions + * @type {typeof import('./vis-state-actions').toggleLayerAnimationControl} + * @returns action + * @public + */ +export function toggleLayerAnimationControl() { + return { + type: ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL + }; +} + /** * Show larger time filter at bottom for time playback (apply to time filter only) * @memberof visStateActions diff --git a/src/components/bottom-widget.js b/src/components/bottom-widget.js index a0f3c99208..6e176c2b65 100644 --- a/src/components/bottom-widget.js +++ b/src/components/bottom-widget.js @@ -124,6 +124,8 @@ BottomWidgetFactory.deps = [ FilterAnimationControllerFactory, LayerAnimationControllerFactory ]; + +/* eslint-disable complexity */ export default function BottomWidgetFactory( TimeWidget, AnimationControl, @@ -165,7 +167,8 @@ export default function BottomWidgetFactory( Array.isArray(animationConfig.domain) && Number.isFinite(animationConfig.currentTime); // if animation control is showing, hide time display in time slider const showFloatingTimeDisplay = !animatableLayer.length; - const showAnimationControl = animatableLayer.length && readyToAnimation; + const showAnimationControl = + animatableLayer.length && readyToAnimation && !animationConfig.hideControl; const showTimeWidget = enlargedFilterIdx > -1 && Object.keys(datasets).length > 0; // if filter is not animating, pass in enlarged filter here because @@ -236,3 +239,4 @@ export default function BottomWidgetFactory( return BottomWidget; } +/* eslint-enable complexity */ diff --git a/src/components/common/time-slider-marker.js b/src/components/common/time-slider-marker.js index 26d9b8ee6f..536ffb5ef5 100644 --- a/src/components/common/time-slider-marker.js +++ b/src/components/common/time-slider-marker.js @@ -19,7 +19,7 @@ // THE SOFTWARE. import React, {useRef, useEffect, useMemo} from 'react'; -import moment from 'moment'; +import moment from 'moment-timezone'; import PropTypes from 'prop-types'; import {scaleUtc} from 'd3-scale'; import {select} from 'd3-selection'; diff --git a/src/constants/action-types.d.ts b/src/constants/action-types.d.ts index 80a97488f2..6052500fa5 100644 --- a/src/constants/action-types.d.ts +++ b/src/constants/action-types.d.ts @@ -40,6 +40,7 @@ export type ActionType = { UPDATE_LAYER_ANIMATION_SPEED: string; TOGGLE_LAYER_CONFIG_ACTIVE: string; TOGGLE_LAYER_ANIMATION: string; + TOGGLE_LAYER_ANIMATION_CONTROL: string; ENLARGE_FILTER: string; TOGGLE_FILTER_FEATURE: string; SET_VISIBLE_LAYERS_FOR_MAP: string; diff --git a/src/constants/action-types.js b/src/constants/action-types.js index d7afbb3303..3f0f5aabc8 100644 --- a/src/constants/action-types.js +++ b/src/constants/action-types.js @@ -91,6 +91,7 @@ const ActionTypes = { UPDATE_ANIMATION_SPEED: `${ACTION_PREFIX}UPDATE_ANIMATION_SPEED`, UPDATE_LAYER_ANIMATION_SPEED: `${ACTION_PREFIX}UPDATE_LAYER_ANIMATION_SPEED`, TOGGLE_LAYER_ANIMATION: `${ACTION_PREFIX}TOGGLE_LAYER_ANIMATION`, + TOGGLE_LAYER_ANIMATION_CONTROL: `${ACTION_PREFIX}TOGGLE_LAYER_ANIMATION_CONTROL`, TOGGLE_LAYER_CONFIG_ACTIVE: `${ACTION_PREFIX}TOGGLE_LAYER_CONFIG_ACTIVE`, ENLARGE_FILTER: `${ACTION_PREFIX}ENLARGE_FILTER`, TOGGLE_FILTER_FEATURE: `${ACTION_PREFIX}TOGGLE_FILTER_FEATURE`, diff --git a/src/reducers/vis-state-updaters.d.ts b/src/reducers/vis-state-updaters.d.ts index 1b61316d0b..8c87cc36d0 100644 --- a/src/reducers/vis-state-updaters.d.ts +++ b/src/reducers/vis-state-updaters.d.ts @@ -177,6 +177,8 @@ export type AnimationConfig = { timeFormat?: string | null; // custom ui input timezone?: string | null; + // hide or show control + hideControl?: boolean; }; export type BaseInteraction = { @@ -321,6 +323,10 @@ export function toggleLayerAnimationUpdater( state: VisState, action: VisStateActions.ToggleLayerAnimationUpdaterAction ): VisState; +export function toggleLayerAnimationControlUpdater( + state: VisState, + action: VisStateActions.ToggleLayerAnimationControlUpdaterAction +): VisState; export function interactionConfigChangeUpdater( state: VisState, action: VisStateActions.InteractionConfigChangeUpdaterAction diff --git a/src/reducers/vis-state-updaters.js b/src/reducers/vis-state-updaters.js index 670ea0118b..9082efbf3f 100644 --- a/src/reducers/vis-state-updaters.js +++ b/src/reducers/vis-state-updaters.js @@ -780,6 +780,21 @@ export const toggleLayerAnimationUpdater = state => ({ isAnimating: !state.animationConfig.isAnimating } }); + +/** + * Hide and show layer animation control + * @memberof visStateUpdaters + * @type {typeof import('./vis-state-updaters').toggleLayerAnimationControlUpdater} + * @public + */ +export const toggleLayerAnimationControlUpdater = state => ({ + ...state, + animationConfig: { + ...state.animationConfig, + hideControl: !state.animationConfig.hideControl + } +}); + /** * Change filter animation speed * @memberof visStateUpdaters diff --git a/src/reducers/vis-state.js b/src/reducers/vis-state.js index c9c675c464..5e842f0883 100644 --- a/src/reducers/vis-state.js +++ b/src/reducers/vis-state.js @@ -55,6 +55,8 @@ const actionHandler = { [ActionTypes.TOGGLE_LAYER_ANIMATION]: visStateUpdaters.toggleLayerAnimationUpdater, + [ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL]: visStateUpdaters.toggleLayerAnimationControlUpdater, + [ActionTypes.LOAD_FILES]: visStateUpdaters.loadFilesUpdater, [ActionTypes.LOAD_FILES_ERR]: visStateUpdaters.loadFilesErrUpdater,