// Copyright (C) 2020 Intel Corporation // // SPDX-License-Identifier: MIT import React, { useState, useEffect } from 'react'; import { Row, Col } from 'antd/lib/grid'; import Icon from 'antd/lib/icon'; import Slider, { SliderValue } from 'antd/lib/slider'; import Tooltip from 'antd/lib/tooltip'; import InputNumber from 'antd/lib/input-number'; import Text from 'antd/lib/typography/Text'; import { clamp } from 'utils/math'; interface Props { startFrame: number; stopFrame: number; frameNumber: number; inputFrameRef: React.RefObject; onSliderChange(value: SliderValue): void; onInputChange(value: number): void; onURLIconClick(): void; } function PlayerNavigation(props: Props): JSX.Element { const { startFrame, stopFrame, frameNumber, inputFrameRef, onSliderChange, onInputChange, onURLIconClick, } = props; const [frameInputValue, setFrameInputValue] = useState(frameNumber); useEffect(() => { if (frameNumber !== frameInputValue) { setFrameInputValue(frameNumber); } }, [frameNumber]); return ( <> filename.png { if (typeof (value) === 'number') { setFrameInputValue(Math.floor( clamp(value, startFrame, stopFrame), )); } }} onBlur={() => { onInputChange(frameInputValue); }} onPressEnter={() => { onInputChange(frameInputValue); }} ref={inputFrameRef} /> ); } export default React.memo(PlayerNavigation);