Refactor PropertiesOperations duplicate
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Eric NGUYEN 2022-08-16 11:43:31 +02:00
parent 0e7e8a47ce
commit 8759c77042

View file

@ -97,33 +97,26 @@ export function OnPropertiesSubmit(
// Assign container properties
for (const property in container.properties) {
const input = (event.target as HTMLFormElement).querySelector(`#${property}`);
if (input instanceof HTMLInputElement) {
(container.properties as any)[property] = input.value;
const input: HTMLInputElement | null = (event.target as HTMLFormElement).querySelector(`#${property}`);
if (INPUT_TYPES[property] === 'number') {
(container.properties as any)[property] = Number(input.value);
if (input === null) {
continue;
}
(container.properties as any)[property] = input.value;
if (INPUT_TYPES[property] === 'number') {
(container.properties as any)[property] = Number(input.value);
}
}
// Assign cssproperties
for (const styleProperty in container.properties.style) {
const input = (event.target as HTMLFormElement).querySelector(`#${styleProperty}`);
if (input instanceof HTMLInputElement) {
(container.properties.style as any)[styleProperty] = input.value;
if (INPUT_TYPES[styleProperty] === 'number') {
(container.properties.style as any)[styleProperty] = Number(input.value);
const input: HTMLInputElement | null = (event.target as HTMLFormElement).querySelector(`#${styleProperty}`);
if (input === null) {
continue;
}
(container.properties.style as any)[styleProperty] = input.value;
}
}
if (container.properties.isRigidBody) {
RecalculatePhysics(container);