방위각 제한 (-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 '@/styles/calc.scss'
|
||||
|
||||
@ -294,9 +294,11 @@ export const CalculatorInput = forwardRef(
|
||||
} else {
|
||||
calculator.currentOperand = filteredValue
|
||||
setHasOperation(false)
|
||||
// 연산자가 없는 순수 숫자일 때만 부모 컴포넌트의 onChange 호출
|
||||
onChange(filteredValue)
|
||||
}
|
||||
|
||||
onChange(filteredValue)
|
||||
//onChange(filteredValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -452,7 +452,16 @@ export const Orientation = forwardRef((props, ref) => {
|
||||
className="input-origin block"
|
||||
value={inputCompasDeg}
|
||||
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={{
|
||||
allowNegative: true,
|
||||
allowDecimal: false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user