From 5eb072cdbd869413601f09a3191dd980ebb2a97a Mon Sep 17 00:00:00 2001 From: yehuozhili Date: Thu, 3 Sep 2020 11:54:54 +0800 Subject: [PATCH] update cardpicker --- src/components/Calibration/index.tsx | 10 +++++++--- src/components/CardPicker/index.tsx | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/Calibration/index.tsx b/src/components/Calibration/index.tsx index b751636..d71a3f4 100644 --- a/src/components/Calibration/index.tsx +++ b/src/components/Calibration/index.tsx @@ -6,8 +6,12 @@ export interface calibrationTypes { width: number; height: number; } +export type CalibrationTypes = { + direction: 'up' | 'left'; + multiple: number; +}; -export default function Calibration(props) { +export default function Calibration(props: CalibrationTypes) { const { direction, multiple } = props; const [calibrationLength, setCalibration] = useState({ width: 0, height: 0 }); const calibrationRef = useRef(null); @@ -69,7 +73,7 @@ export default function Calibration(props) { let arr = [...calibrationRef.current.querySelectorAll('.calibrationLine')]; if (arr.length) { if (direction === 'up') { - calibrationRef.current.style.width = multiple.toFixed(1) * width + 'px'; + calibrationRef.current.style.width = parseFloat(multiple.toFixed(1)) * width + 'px'; arr.forEach(el => { let dom = [...el.querySelectorAll('.calibrationNumber')][0] as HTMLElement; if (dom) { @@ -79,7 +83,7 @@ export default function Calibration(props) { } }); } else { - calibrationRef.current.style.height = multiple.toFixed(1) * height + 'px'; + calibrationRef.current.style.height = parseFloat(multiple.toFixed(1)) * height + 'px'; arr.forEach(el => { let dom = [...el.querySelectorAll('.calibrationNumber')][0] as HTMLElement; if (dom) { diff --git a/src/components/CardPicker/index.tsx b/src/components/CardPicker/index.tsx index f97bfbb..195483b 100644 --- a/src/components/CardPicker/index.tsx +++ b/src/components/CardPicker/index.tsx @@ -4,9 +4,9 @@ import Icon from '../Icon'; import styles from './index.less'; interface CardPickerType { - type: any; - icons: Array; - onChange: any; + type: string; + icons: Array; + onChange: (v: string) => void; } export default memo((props: CardPickerType) => {