update cardpicker

This commit is contained in:
yehuozhili 2020-09-03 11:54:54 +08:00
parent 8ae5459130
commit 5eb072cdbd
2 changed files with 10 additions and 6 deletions

View File

@ -6,8 +6,12 @@ export interface calibrationTypes {
width: number; width: number;
height: 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 { direction, multiple } = props;
const [calibrationLength, setCalibration] = useState<calibrationTypes>({ width: 0, height: 0 }); const [calibrationLength, setCalibration] = useState<calibrationTypes>({ width: 0, height: 0 });
const calibrationRef = useRef<HTMLDivElement>(null); const calibrationRef = useRef<HTMLDivElement>(null);
@ -69,7 +73,7 @@ export default function Calibration(props) {
let arr = [...calibrationRef.current.querySelectorAll('.calibrationLine')]; let arr = [...calibrationRef.current.querySelectorAll('.calibrationLine')];
if (arr.length) { if (arr.length) {
if (direction === 'up') { 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 => { arr.forEach(el => {
let dom = [...el.querySelectorAll('.calibrationNumber')][0] as HTMLElement; let dom = [...el.querySelectorAll('.calibrationNumber')][0] as HTMLElement;
if (dom) { if (dom) {
@ -79,7 +83,7 @@ export default function Calibration(props) {
} }
}); });
} else { } else {
calibrationRef.current.style.height = multiple.toFixed(1) * height + 'px'; calibrationRef.current.style.height = parseFloat(multiple.toFixed(1)) * height + 'px';
arr.forEach(el => { arr.forEach(el => {
let dom = [...el.querySelectorAll('.calibrationNumber')][0] as HTMLElement; let dom = [...el.querySelectorAll('.calibrationNumber')][0] as HTMLElement;
if (dom) { if (dom) {

View File

@ -4,9 +4,9 @@ import Icon from '../Icon';
import styles from './index.less'; import styles from './index.less';
interface CardPickerType { interface CardPickerType {
type: any; type: string;
icons: Array<any>; icons: Array<string>;
onChange: any; onChange: (v: string) => void;
} }
export default memo((props: CardPickerType) => { export default memo((props: CardPickerType) => {