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