방위각 제한 (-180 ~ 180)
This commit is contained in:
parent
295694ee82
commit
a128b0b5bb
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useRef, useEffect, forwardRef } from 'react'
|
import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from 'react'
|
||||||
import { createCalculator } from '@/util/calc-utils'
|
import { createCalculator } from '@/util/calc-utils'
|
||||||
import '@/styles/calc.scss'
|
import '@/styles/calc.scss'
|
||||||
|
|
||||||
@ -294,9 +294,11 @@ export const CalculatorInput = forwardRef(
|
|||||||
} else {
|
} else {
|
||||||
calculator.currentOperand = filteredValue
|
calculator.currentOperand = filteredValue
|
||||||
setHasOperation(false)
|
setHasOperation(false)
|
||||||
|
// 연산자가 없는 순수 숫자일 때만 부모 컴포넌트의 onChange 호출
|
||||||
|
onChange(filteredValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(filteredValue)
|
//onChange(filteredValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -452,7 +452,16 @@ export const Orientation = forwardRef((props, ref) => {
|
|||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
value={inputCompasDeg}
|
value={inputCompasDeg}
|
||||||
readOnly={!hasAnglePassivity}
|
readOnly={!hasAnglePassivity}
|
||||||
onChange={(value) => setInputCompasDeg(value)}
|
onChange={(value) => {
|
||||||
|
// Convert to number and ensure it's within -180 to 180 range
|
||||||
|
const numValue = parseInt(value, 10);
|
||||||
|
if (!isNaN(numValue)) {
|
||||||
|
const clampedValue = Math.min(180, Math.max(-180, numValue));
|
||||||
|
setInputCompasDeg(String(clampedValue));
|
||||||
|
} else {
|
||||||
|
setInputCompasDeg(value);
|
||||||
|
}
|
||||||
|
}}
|
||||||
options={{
|
options={{
|
||||||
allowNegative: true,
|
allowNegative: true,
|
||||||
allowDecimal: false
|
allowDecimal: false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user