Font working
This commit is contained in:
@@ -280,6 +280,7 @@ export function ParameterField({ layer, parameter, onParameterChange }) {
|
||||
<input
|
||||
type="text"
|
||||
maxLength={parameter.maxLength ?? 64}
|
||||
placeholder={parameter.defaultValue ? `Default: ${parameter.defaultValue}` : ""}
|
||||
value={draftValue ?? ""}
|
||||
onFocus={beginInteraction}
|
||||
onChange={(event) => sendValue(event.target.value)}
|
||||
|
||||
@@ -5,33 +5,34 @@ function valuesMatch(left, right) {
|
||||
}
|
||||
|
||||
export function useThrottledParameterValue(parameter, onParameterChange) {
|
||||
const [draftValue, setDraftValue] = useState(parameter.value);
|
||||
const [appliedValue, setAppliedValue] = useState(parameter.value);
|
||||
const currentValue = parameter.value === undefined ? parameter.defaultValue : parameter.value;
|
||||
const [draftValue, setDraftValue] = useState(currentValue);
|
||||
const [appliedValue, setAppliedValue] = useState(currentValue);
|
||||
const pendingTimeoutRef = useRef(null);
|
||||
const latestDraftRef = useRef(parameter.value);
|
||||
const latestDraftRef = useRef(currentValue);
|
||||
const lastSentAtRef = useRef(0);
|
||||
const isInteractingRef = useRef(false);
|
||||
const isDirtyRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDraftValue(parameter.value);
|
||||
setAppliedValue(parameter.value);
|
||||
latestDraftRef.current = parameter.value;
|
||||
setDraftValue(currentValue);
|
||||
setAppliedValue(currentValue);
|
||||
latestDraftRef.current = currentValue;
|
||||
lastSentAtRef.current = 0;
|
||||
isInteractingRef.current = false;
|
||||
isDirtyRef.current = false;
|
||||
}, [parameter.id]);
|
||||
|
||||
useEffect(() => {
|
||||
setAppliedValue(parameter.value);
|
||||
setAppliedValue(currentValue);
|
||||
latestDraftRef.current = draftValue;
|
||||
if (isDirtyRef.current && valuesMatch(parameter.value, latestDraftRef.current)) {
|
||||
if (isDirtyRef.current && valuesMatch(currentValue, latestDraftRef.current)) {
|
||||
isDirtyRef.current = false;
|
||||
}
|
||||
if (!isInteractingRef.current && !isDirtyRef.current) {
|
||||
setDraftValue(parameter.value);
|
||||
setDraftValue(currentValue);
|
||||
}
|
||||
}, [draftValue, parameter.value]);
|
||||
}, [draftValue, currentValue]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user