Merge pull request #15 from MrXujiang/yehuozhiliwork

update cardpicker
This commit is contained in:
yehuozhili 2020-09-03 11:57:45 +08:00 committed by GitHub
commit 973a9d9590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -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<calibrationTypes>({ width: 0, height: 0 });
const calibrationRef = useRef<HTMLDivElement>(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) {

View File

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